From 061f33baadeee64fb7e2cea902977e1cb5e3c0dc Mon Sep 17 00:00:00 2001 From: giraffedata Date: Sat, 17 Feb 2018 03:44:51 +0000 Subject: Release 10.73.18 git-svn-id: http://svn.code.sf.net/p/netpbm/code/stable@3154 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- converter/pbm/g3topbm.c | 11 +++++++---- converter/pbm/mrftopbm.c | 15 ++++++++++++--- doc/HISTORY | 8 ++++++++ version.mk | 2 +- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/converter/pbm/g3topbm.c b/converter/pbm/g3topbm.c index b0d08f9e..fcac1981 100644 --- a/converter/pbm/g3topbm.c +++ b/converter/pbm/g3topbm.c @@ -753,7 +753,6 @@ main(int argc, char * argv[]) { struct bitStream bitStream; unsigned int rows, cols; unsigned char ** packedBits; - int row; pbm_init(&argc, argv); @@ -779,9 +778,13 @@ main(int argc, 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) diff --git a/doc/HISTORY b/doc/HISTORY index d9fab8a1..76272b0b 100644 --- a/doc/HISTORY +++ b/doc/HISTORY @@ -4,6 +4,14 @@ Netpbm. CHANGE HISTORY -------------- +18.02.17 BJH Release 10.73.18 + + g3topbm: Fix bug - produces invalid empty PBM image if input + image is empty. + + mrftopbm: Fix bug - wrong error messages or output when input + invalidly short. + 17.10.28 BJH Release 10.73.17 sldtoppm: -lib and -dir don't work - always says slide not diff --git a/version.mk b/version.mk index e7e1df61..f6364e3b 100644 --- a/version.mk +++ b/version.mk @@ -1,3 +1,3 @@ NETPBM_MAJOR_RELEASE = 10 NETPBM_MINOR_RELEASE = 73 -NETPBM_POINT_RELEASE = 17 +NETPBM_POINT_RELEASE = 18 -- cgit 1.4.1