diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2018-02-17 03:45:17 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2018-02-17 03:45:17 +0000 |
commit | 3642751efdc205fb08bcc4f5c4d5879fc6077a72 (patch) | |
tree | 3fab82cb61b0b029eba5792d7467b4b01249d95a /converter | |
parent | 2c8fdc6afca5f3b43f6f6b650832d53db09dc9bf (diff) | |
download | netpbm-mirror-3642751efdc205fb08bcc4f5c4d5879fc6077a72.tar.gz netpbm-mirror-3642751efdc205fb08bcc4f5c4d5879fc6077a72.tar.xz netpbm-mirror-3642751efdc205fb08bcc4f5c4d5879fc6077a72.zip |
Release 10.81.03
git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@3155 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter')
-rw-r--r-- | converter/pbm/g3topbm.c | 11 | ||||
-rw-r--r-- | converter/pbm/mrftopbm.c | 15 |
2 files changed, 19 insertions, 7 deletions
diff --git a/converter/pbm/g3topbm.c b/converter/pbm/g3topbm.c index 2b486324..2a4d84e5 100644 --- a/converter/pbm/g3topbm.c +++ b/converter/pbm/g3topbm.c @@ -788,7 +788,6 @@ main(int argc, const char * argv[]) { struct BitStream bitStream; unsigned int rows, cols; unsigned char ** packedBits; - int row; pm_proginit(&argc, argv); @@ -814,9 +813,13 @@ main(int argc, const char * argv[]) { pm_close(ifP); - pbm_writepbminit(stdout, cols, rows, 0); - for (row = 0; row < rows; ++row) - pbm_writepbmrow_packed(stdout, packedBits[row], cols, 0); + if (cols > 0 && rows > 0) { + unsigned int row; + pbm_writepbminit(stdout, cols, rows, 0); + for (row = 0; row < rows; ++row) + pbm_writepbmrow_packed(stdout, packedBits[row], cols, 0); + } else + pm_error("No image data in input"); pm_close(stdout); 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) |