kbd-2.4.0-covscan-fixes.patch 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. diff -up kbd-2.4.0/src/libkfont/psffontop.c.orig kbd-2.4.0/src/libkfont/psffontop.c
  2. --- kbd-2.4.0/src/libkfont/psffontop.c.orig 2020-04-27 17:53:01.000000000 +0200
  3. +++ kbd-2.4.0/src/libkfont/psffontop.c 2021-04-27 09:59:14.170153676 +0200
  4. @@ -235,6 +235,7 @@ kfont_read_psffont(struct kfont_context
  5. if (psfhdr->mode > PSF1_MAXMODE) {
  6. KFONT_ERR(ctx, _("Unsupported psf file mode (%d)"), psfhdr->mode);
  7. + free(psfhdr);
  8. return -EX_DATAERR;
  9. }
  10. fontlen = ((psfhdr->mode & PSF1_MODE512) ? 512 : 256);
  11. @@ -251,6 +252,7 @@ kfont_read_psffont(struct kfont_context
  12. if (psfhdr.version > PSF2_MAXVERSION) {
  13. KFONT_ERR(ctx, _("Unsupported psf version (%d)"), psfhdr.version);
  14. + free(inputbuf);
  15. return -EX_DATAERR;
  16. }
  17. fontlen = assemble_uint32((unsigned char *)&psfhdr.length);
  18. @@ -260,16 +262,20 @@ kfont_read_psffont(struct kfont_context
  19. ftoffset = assemble_uint32((unsigned char *)&psfhdr.headersize);
  20. fontwidth = assemble_uint32((unsigned char *)&psfhdr.width);
  21. utf8 = 1;
  22. - } else
  23. + } else {
  24. + free(inputbuf);
  25. return -EX_DATAERR; /* not psf */
  26. + }
  27. /* tests required - we divide by these */
  28. if (fontlen == 0) {
  29. KFONT_ERR(ctx, _("zero input font length?"));
  30. + free(inputbuf);
  31. return -EX_DATAERR;
  32. }
  33. if (charsize == 0) {
  34. KFONT_ERR(ctx, _("zero input character size?"));
  35. + free(inputbuf);
  36. return -EX_DATAERR;
  37. }
  38. @@ -277,6 +283,7 @@ kfont_read_psffont(struct kfont_context
  39. if (i > inputlth || (!hastable && i != inputlth)) {
  40. KFONT_ERR(ctx, _("Input file: bad input length (%d)"), inputlth);
  41. + free(inputbuf);
  42. return -EX_DATAERR;
  43. }