diff options
-rw-r--r-- | converter/pbm/mrftopbm.c | 15 | ||||
-rw-r--r-- | doc/HISTORY | 3 |
2 files changed, 15 insertions, 3 deletions
diff --git a/converter/pbm/mrftopbm.c b/converter/pbm/mrftopbm.c index 51281028..32f36ef3 100644 --- a/converter/pbm/mrftopbm.c +++ b/converter/pbm/mrftopbm.c @@ -31,7 +31,12 @@ bit_init(void) { static int bit_input(FILE * const in) { if (bitsleft == 0) { - bitbox = fgetc(in); + int rc; + rc = fgetc(in); + if (rc == EOF) + pm_error("Unexpected EOF reading image data."); + + bitbox = rc; bitsleft = 8; } --bitsleft; @@ -133,11 +138,15 @@ readMrfImage(FILE * const ifP, unsigned int w64, h64; unsigned char * image; + unsigned int bytesRead; - fread(buf, 1, 13, ifP); + bytesRead = fread(buf, 1, 13, ifP); + if (bytesRead != 13) + pm_error("Input in not an MRF image. We know this because it is less " + "than 13 bytes, the size of an MRF header"); if (memcmp(buf, "MRF1", 4) != 0) - pm_error("Input is not an mrf image. " + pm_error("Input is not an MRF image. " "We know this because it does not start with 'MRF1'."); if (buf[12] != 0) diff --git a/doc/HISTORY b/doc/HISTORY index c161aaa8..09086e2d 100644 --- a/doc/HISTORY +++ b/doc/HISTORY @@ -35,6 +35,9 @@ not yet BJH Release 10.82.00 ppmpat: Fix bug - crash or junk output with -camo or -anticamo and no -color. Introduced in Netpbm 10.78 (March 2017). + mrftopbm: Fix bug - wrong error messages or output when input + invalidly short. + Build: fix compile failure on systems without strnlen (such as MacOS X before 10.7). Broken in 10.81 (December 2017). |