From 195fc44b112f7e40f66e3ef682065fa66a0994ad36703391b976b31fde559c76 Mon Sep 17 00:00:00 2001 From: Pedro Monreal Gonzalez Date: Fri, 2 Feb 2024 09:12:34 +0000 Subject: [PATCH] Accepting request 1143208 from home:pgajdos - version update to 11.5.2 Release 11.05.02 + ppmtowinicon: fix array overrun with 4 and 8 bits per pixel. Release 11.05.01 Fix typo in ppmforge test case. Release 11.05.00 + pnmpad: Add -color, -promote, -extend-edge, -detect-background . + pnmconvol: Restore ability of convolution matrix to be a pseudo-plain-PNM with samples that exceed the maxval. Lost in 10.30 (October 2005) because maxval-checking code was added to libnetpbm. (Was fixed in 10.47.08 in November 2010, but only in the 10.47 series). + pnmindex: Improve failure mode when -size or -across is zero. + pnmindex: Make -plain work. + pnmpad: fix behavior with -left, -right, and -width together or -top, -bottom, -height together: ignores -width where it should fail. Broken in Netpbm 10.72 (September 2015). + pamtosvg: fix "zero determinant" failure. Introduced in Netpbm 11.04 (September 2023). + pjtoppm: fix crash based on uninitialized variable. Introduced in Netpbm 11.04 (September 2023). + ppmtopcxl: fix incorrect output with > 256 colors. Always broken. (Program was added in primordial Netpbm in 1990). + pbmtext: fix buffer overrun with insanely large input. + picttoppm: fix buffer overrun with insanely wide input. + ppmtoxpm: fix incorrect output with insanely large number of colors. + pnmscalefixed: fix incorrect output with really big image and -pixels option. + ppmdither: fix buffer overrun with insanely large dithering OBS-URL: https://build.opensuse.org/request/show/1143208 OBS-URL: https://build.opensuse.org/package/show/graphics/netpbm?expand=0&rev=145 --- netpbm-11.2.0-documentation.tar.bz2 | 3 - netpbm-11.2.0-nohpcdtoppm-noppmtompeg.tar.bz2 | 3 - netpbm-11.5.2-documentation.tar.bz2 | 3 + netpbm-11.5.2-nohpcdtoppm-noppmtompeg.tar.bz2 | 3 + netpbm-gcc-warnings.patch | 26 +- netpbm-security-code.patch | 1178 ++++++----------- netpbm.changes | 96 ++ netpbm.spec | 6 +- 8 files changed, 539 insertions(+), 779 deletions(-) delete mode 100644 netpbm-11.2.0-documentation.tar.bz2 delete mode 100644 netpbm-11.2.0-nohpcdtoppm-noppmtompeg.tar.bz2 create mode 100644 netpbm-11.5.2-documentation.tar.bz2 create mode 100644 netpbm-11.5.2-nohpcdtoppm-noppmtompeg.tar.bz2 diff --git a/netpbm-11.2.0-documentation.tar.bz2 b/netpbm-11.2.0-documentation.tar.bz2 deleted file mode 100644 index e783cf4..0000000 --- a/netpbm-11.2.0-documentation.tar.bz2 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:a7e45f7d20052acf13f11d72e031dbef709884f18354c3bffd4d089ac4cd0631 -size 12263828 diff --git a/netpbm-11.2.0-nohpcdtoppm-noppmtompeg.tar.bz2 b/netpbm-11.2.0-nohpcdtoppm-noppmtompeg.tar.bz2 deleted file mode 100644 index 2aae54a..0000000 --- a/netpbm-11.2.0-nohpcdtoppm-noppmtompeg.tar.bz2 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c67e4ff7af6436c669b0acb750b65990fb9c1043186ed4e1c3449dca06ba1ef5 -size 2008164 diff --git a/netpbm-11.5.2-documentation.tar.bz2 b/netpbm-11.5.2-documentation.tar.bz2 new file mode 100644 index 0000000..6302759 --- /dev/null +++ b/netpbm-11.5.2-documentation.tar.bz2 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fd3414f2b7043add99ad4cb4d9c7245c316c198c00ccf469c27ecbe4334f0443 +size 12265487 diff --git a/netpbm-11.5.2-nohpcdtoppm-noppmtompeg.tar.bz2 b/netpbm-11.5.2-nohpcdtoppm-noppmtompeg.tar.bz2 new file mode 100644 index 0000000..e9f16be --- /dev/null +++ b/netpbm-11.5.2-nohpcdtoppm-noppmtompeg.tar.bz2 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9338190116a6bb4fb32611843fb64b71e1f50e5760a9a161bf127ec92085e3c8 +size 2011337 diff --git a/netpbm-gcc-warnings.patch b/netpbm-gcc-warnings.patch index 39a20a9..3a51188 100644 --- a/netpbm-gcc-warnings.patch +++ b/netpbm-gcc-warnings.patch @@ -1,8 +1,8 @@ -Index: netpbm-11.2.0/converter/other/pngx.c +Index: netpbm-11.5.2/converter/other/pngx.c =================================================================== ---- netpbm-11.2.0.orig/converter/other/pngx.c -+++ netpbm-11.2.0/converter/other/pngx.c -@@ -368,6 +368,7 @@ pngx_srgbIntentDesc(pngx_srgbIntent cons +--- netpbm-11.5.2.orig/converter/other/pngx.c ++++ netpbm-11.5.2/converter/other/pngx.c +@@ -370,6 +370,7 @@ pngx_srgbIntentDesc(pngx_srgbIntent cons case PNGX_ABSOLUTE_COLORIMETRIC: return "ABSOLUTE_COLORIMETRIC"; } assert(false); @@ -10,7 +10,7 @@ Index: netpbm-11.2.0/converter/other/pngx.c } -@@ -383,6 +384,7 @@ const libpngSrgbIntentCode(pngx_srgbInte +@@ -385,6 +386,7 @@ const libpngSrgbIntentCode(pngx_srgbInte } assert(false); /* All cases above return */ @@ -18,10 +18,10 @@ Index: netpbm-11.2.0/converter/other/pngx.c } -Index: netpbm-11.2.0/lib/libpm.c +Index: netpbm-11.5.2/lib/libpm.c =================================================================== ---- netpbm-11.2.0.orig/lib/libpm.c -+++ netpbm-11.2.0/lib/libpm.c +--- netpbm-11.5.2.orig/lib/libpm.c ++++ netpbm-11.5.2/lib/libpm.c @@ -440,6 +440,7 @@ pm_maxvaltobits(int const maxval) { pm_error( "maxval of %d is too large!", maxval ); @@ -29,12 +29,12 @@ Index: netpbm-11.2.0/lib/libpm.c + return 0; } - int -Index: netpbm-11.2.0/lib/libpnm3.c + +Index: netpbm-11.5.2/lib/libpnm3.c =================================================================== ---- netpbm-11.2.0.orig/lib/libpnm3.c -+++ netpbm-11.2.0/lib/libpnm3.c -@@ -433,6 +433,8 @@ pnm_bittoxel(bit const inputBit, +--- netpbm-11.5.2.orig/lib/libpnm3.c ++++ netpbm-11.5.2/lib/libpnm3.c +@@ -446,6 +446,8 @@ pnm_bittoxel(bit const inputBit, case PBM_WHITE: return pnm_whitexel(maxval, PBM_TYPE); break; default: assert(false); diff --git a/netpbm-security-code.patch b/netpbm-security-code.patch index 745e2d1..a30a53e 100644 --- a/netpbm-security-code.patch +++ b/netpbm-security-code.patch @@ -1,51 +1,51 @@ -Index: netpbm-11.2.0/analyzer/pgmtexture.c +Index: netpbm-11.5.2/analyzer/pgmtexture.c =================================================================== ---- netpbm-11.2.0.orig/analyzer/pgmtexture.c -+++ netpbm-11.2.0/analyzer/pgmtexture.c -@@ -63,7 +63,7 @@ vector(unsigned int const nl, +--- netpbm-11.5.2.orig/analyzer/pgmtexture.c ++++ netpbm-11.5.2/analyzer/pgmtexture.c +@@ -98,7 +98,7 @@ vector(unsigned int const nl, unsigned int i; - assert(nh >= nl); + assert(nh >= nl); assert(nh <= UINT_MAX-1); - + overflow_add(nh - nl, 1); MALLOCARRAY(v, (unsigned) (nh - nl + 1)); if (v == NULL) -@@ -97,6 +97,7 @@ matrix (unsigned int const nrl, - assert(nrh >= nrl); +@@ -136,6 +136,7 @@ matrix (unsigned int const nrl, + assert(nrh >= nrl); assert(nrh <= UINT_MAX-1); /* allocate pointers to rows */ + overflow_add(nrh - nrl, 1); - MALLOCARRAY(m, (unsigned) (nrh - nrl + 1)); - if (m == NULL) + MALLOCARRAY(matrix, (unsigned) (nrh - nrl + 1)); + if (matrix == NULL) pm_error("Unable to allocate memory for a matrix."); -@@ -104,7 +105,7 @@ matrix (unsigned int const nrl, - m -= ncl; +@@ -143,7 +144,7 @@ matrix (unsigned int const nrl, + matrix -= ncl; - assert (nch >= ncl); + assert (nch >= ncl); assert(nch <= UINT_MAX-1); - + overflow_add(nch - ncl, 1); /* allocate rows and set pointers to them */ for (i = nrl; i <= nrh; ++i) { - MALLOCARRAY(m[i], (unsigned) (nch - ncl + 1)); -Index: netpbm-11.2.0/converter/other/gemtopnm.c + MALLOCARRAY(matrix[i], (unsigned) (nch - ncl + 1)); +Index: netpbm-11.5.2/converter/other/gemtopnm.c =================================================================== ---- netpbm-11.2.0.orig/converter/other/gemtopnm.c -+++ netpbm-11.2.0/converter/other/gemtopnm.c -@@ -105,7 +105,7 @@ main(argc, argv) +--- netpbm-11.5.2.orig/converter/other/gemtopnm.c ++++ netpbm-11.5.2/converter/other/gemtopnm.c +@@ -152,7 +152,7 @@ main(int argc, const char ** argv) { type = PPM_TYPE; - pnm_writepnminit( stdout, cols, rows, MAXVAL, type, 0 ); + pnm_writepnminit(stdout, cols, rows, MAXVAL, type, 0); - + overflow_add(cols, padright); { /* allocate input row data structure */ - int plane; -Index: netpbm-11.2.0/converter/other/jpegtopnm.c + unsigned int plane; +Index: netpbm-11.5.2/converter/other/jpegtopnm.c =================================================================== ---- netpbm-11.2.0.orig/converter/other/jpegtopnm.c -+++ netpbm-11.2.0/converter/other/jpegtopnm.c -@@ -883,6 +883,8 @@ convertImage(FILE * +--- netpbm-11.5.2.orig/converter/other/jpegtopnm.c ++++ netpbm-11.5.2/converter/other/jpegtopnm.c +@@ -894,6 +894,8 @@ convertImage(FILE * /* Calculate output image dimensions so we can allocate space */ jpeg_calc_output_dimensions(cinfoP); @@ -54,23 +54,23 @@ Index: netpbm-11.2.0/converter/other/jpegtopnm.c /* Start decompressor */ jpeg_start_decompress(cinfoP); -Index: netpbm-11.2.0/converter/other/pbmtopgm.c +Index: netpbm-11.5.2/converter/other/pbmtopgm.c =================================================================== ---- netpbm-11.2.0.orig/converter/other/pbmtopgm.c -+++ netpbm-11.2.0/converter/other/pbmtopgm.c -@@ -60,6 +60,7 @@ main(int argc, char *argv[]) { - +--- netpbm-11.5.2.orig/converter/other/pbmtopgm.c ++++ netpbm-11.5.2/converter/other/pbmtopgm.c +@@ -88,6 +88,7 @@ main(int argc, const char ** argv) { + up = cmdline.convRows / 2; down = cmdline.convRows - up; outrow = pgm_allocrow(cols) ; -+ overflow2(width, height); - maxval = MIN(PGM_OVERALLMAXVAL, width*height); ++ overflow2(cmdline.convCols, cmdline.convRows); + maxval = MIN(PGM_OVERALLMAXVAL, cmdline.convCols * cmdline.convRows); pgm_writepgminit(stdout, cols, rows, maxval, 0) ; -Index: netpbm-11.2.0/converter/other/pnmtoddif.c +Index: netpbm-11.5.2/converter/other/pnmtoddif.c =================================================================== ---- netpbm-11.2.0.orig/converter/other/pnmtoddif.c -+++ netpbm-11.2.0/converter/other/pnmtoddif.c -@@ -629,6 +629,7 @@ main(int argc, char *argv[]) { +--- netpbm-11.5.2.orig/converter/other/pnmtoddif.c ++++ netpbm-11.5.2/converter/other/pnmtoddif.c +@@ -627,6 +627,7 @@ main(int argc, char *argv[]) { switch (PNM_FORMAT_TYPE(format)) { case PBM_TYPE: ip.bits_per_pixel = 1; @@ -78,7 +78,7 @@ Index: netpbm-11.2.0/converter/other/pnmtoddif.c ip.bytes_per_line = (cols + 7) / 8; ip.spectral = 2; ip.components = 1; -@@ -644,6 +645,7 @@ main(int argc, char *argv[]) { +@@ -642,6 +643,7 @@ main(int argc, char *argv[]) { ip.polarity = 2; break; case PPM_TYPE: @@ -86,71 +86,49 @@ Index: netpbm-11.2.0/converter/other/pnmtoddif.c ip.bytes_per_line = 3 * cols; ip.bits_per_pixel = 24; ip.spectral = 5; -Index: netpbm-11.2.0/converter/other/pnmtojpeg.c +Index: netpbm-11.5.2/converter/other/pnmtojpeg.c =================================================================== ---- netpbm-11.2.0.orig/converter/other/pnmtojpeg.c -+++ netpbm-11.2.0/converter/other/pnmtojpeg.c -@@ -606,7 +606,11 @@ read_scan_script(j_compress_ptr const ci - want JPOOL_PERMANENT. - */ - const unsigned int scan_info_size = nscans * sizeof(jpeg_scan_info); -- jpeg_scan_info * const scan_info = -+ const jpeg_scan_info * scan_info; -+ -+ overflow2(nscans, sizeof(jpeg_scan_info)); -+ -+ scan_info = - (jpeg_scan_info *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - scan_info_size); -@@ -938,6 +942,8 @@ compute_rescaling_array(JSAMPLE ** const - const long half_maxval = maxval / 2; - long val; +--- netpbm-11.5.2.orig/converter/other/pnmtojpeg.c ++++ netpbm-11.5.2/converter/other/pnmtojpeg.c +@@ -1068,6 +1068,7 @@ computeRescalingArray(JSAMPLE ** + JSAMPLE * rescale; + long val; -+ overflow_add(maxval, 1); -+ overflow2(maxval+1, sizeof(JSAMPLE)); - *rescale_p = (JSAMPLE *) - (cinfo.mem->alloc_small) ((j_common_ptr) &cinfo, JPOOL_IMAGE, - (size_t) (((long) maxval + 1L) * -@@ -1016,6 +1022,7 @@ convert_scanlines(struct jpeg_compress_s - */ ++ overflow_add(maxval, 1); + MALLOCARRAY(rescale, maxval + 1); - /* Allocate the libpnm output and compressor input buffers */ -+ overflow2(cinfo_p->image_width, cinfo_p->input_components); - buffer = (*cinfo_p->mem->alloc_sarray) - ((j_common_ptr) cinfo_p, JPOOL_IMAGE, - (unsigned int) cinfo_p->image_width * cinfo_p->input_components, -Index: netpbm-11.2.0/converter/other/pnmtops.c + if (!rescale) +Index: netpbm-11.5.2/converter/other/pnmtops.c =================================================================== ---- netpbm-11.2.0.orig/converter/other/pnmtops.c -+++ netpbm-11.2.0/converter/other/pnmtops.c -@@ -294,17 +294,21 @@ parseCommandLine(int argc, const char ** - validateCompDimension(width, 72, "-width value"); - validateCompDimension(height, 72, "-height value"); +--- netpbm-11.5.2.orig/converter/other/pnmtops.c ++++ netpbm-11.5.2/converter/other/pnmtops.c +@@ -298,17 +298,21 @@ parseCommandLine(int argc, const char ** + validateCompDimension(width, psScaleFactor, "-width value"); + validateCompDimension(height, psScaleFactor, "-height value"); + overflow2(width, 72); - cmdlineP->width = width * 72; + cmdlineP->width = width * psScaleFactor; + overflow2(height, 72); - cmdlineP->height = height * 72; + cmdlineP->height = height * psScaleFactor; if (imagewidthSpec) { - validateCompDimension(imagewidth, 72, "-imagewidth value"); + validateCompDimension(imagewidth, psScaleFactor, "-imagewidth value"); + overflow2(imagewidth, 72); - cmdlineP->imagewidth = imagewidth * 72; + cmdlineP->imagewidth = imagewidth * psScaleFactor; } else cmdlineP->imagewidth = 0; if (imageheightSpec) { -- validateCompDimension(imagewidth, 72, "-imageheight value"); -+ validateCompDimension(imageheight, 72, "-imageheight value"); +- validateCompDimension(imagewidth, psScaleFactor, "-imageheight value"); ++ validateCompDimension(imageheight, psScaleFactor, "-imageheight value"); + overflow2(imageheight, 72); - cmdlineP->imageheight = imageheight * 72; + cmdlineP->imageheight = imageheight * psScaleFactor; } else -Index: netpbm-11.2.0/converter/other/pnmtorle.c +Index: netpbm-11.5.2/converter/other/pnmtorle.c =================================================================== ---- netpbm-11.2.0.orig/converter/other/pnmtorle.c -+++ netpbm-11.2.0/converter/other/pnmtorle.c +--- netpbm-11.5.2.orig/converter/other/pnmtorle.c ++++ netpbm-11.5.2/converter/other/pnmtorle.c @@ -19,6 +19,8 @@ * If you modify this software, you should include a notice giving the * name of the person performing the modification, the date of modification, @@ -160,10 +138,10 @@ Index: netpbm-11.2.0/converter/other/pnmtorle.c */ /* * pnmtorle - A program which will convert pbmplus (ppm or pgm) images -Index: netpbm-11.2.0/converter/other/pnmtosgi.c +Index: netpbm-11.5.2/converter/other/pnmtosgi.c =================================================================== ---- netpbm-11.2.0.orig/converter/other/pnmtosgi.c -+++ netpbm-11.2.0/converter/other/pnmtosgi.c +--- netpbm-11.5.2.orig/converter/other/pnmtosgi.c ++++ netpbm-11.5.2/converter/other/pnmtosgi.c @@ -185,6 +185,7 @@ buildChannels(FILE * const ifP, ScanElem * temp; @@ -172,10 +150,10 @@ Index: netpbm-11.2.0/converter/other/pnmtosgi.c MALLOCARRAY_NOFAIL(table, channels * rows); } else table = NULL; -Index: netpbm-11.2.0/converter/other/rletopnm.c +Index: netpbm-11.5.2/converter/other/rletopnm.c =================================================================== ---- netpbm-11.2.0.orig/converter/other/rletopnm.c -+++ netpbm-11.2.0/converter/other/rletopnm.c +--- netpbm-11.5.2.orig/converter/other/rletopnm.c ++++ netpbm-11.5.2/converter/other/rletopnm.c @@ -19,6 +19,8 @@ * If you modify this software, you should include a notice giving the * name of the person performing the modification, the date of modification, @@ -185,10 +163,10 @@ Index: netpbm-11.2.0/converter/other/rletopnm.c */ /* * rletopnm - A conversion program to convert from Utah's "rle" image format -Index: netpbm-11.2.0/converter/other/sgitopnm.c +Index: netpbm-11.5.2/converter/other/sgitopnm.c =================================================================== ---- netpbm-11.2.0.orig/converter/other/sgitopnm.c -+++ netpbm-11.2.0/converter/other/sgitopnm.c +--- netpbm-11.5.2.orig/converter/other/sgitopnm.c ++++ netpbm-11.5.2/converter/other/sgitopnm.c @@ -377,10 +377,14 @@ readChannels(FILE * const ifP, MALLOCARRAY_NOFAIL(image, head->ysize); } else { @@ -205,26 +183,14 @@ Index: netpbm-11.2.0/converter/other/sgitopnm.c for (channel = 0; channel < maxchannel; ++channel) { unsigned int row; -Index: netpbm-11.2.0/converter/other/sirtopnm.c +Index: netpbm-11.5.2/converter/other/tifftopnm.c =================================================================== ---- netpbm-11.2.0.orig/converter/other/sirtopnm.c -+++ netpbm-11.2.0/converter/other/sirtopnm.c -@@ -69,6 +69,7 @@ char* argv[]; - } - break; - case PPM_TYPE: -+ overflow3(cols, rows, 3); - picsize = cols * rows * 3; - planesize = cols * rows; - if ( !( sirarray = (unsigned char*) malloc( picsize ) ) ) -Index: netpbm-11.2.0/converter/other/tifftopnm.c -=================================================================== ---- netpbm-11.2.0.orig/converter/other/tifftopnm.c -+++ netpbm-11.2.0/converter/other/tifftopnm.c -@@ -1372,7 +1372,9 @@ convertRasterByRows(pnmOut * const - if (scanbuf == NULL) - pm_error("can't allocate memory for scanline buffer"); - +--- netpbm-11.5.2.orig/converter/other/tifftopnm.c ++++ netpbm-11.5.2/converter/other/tifftopnm.c +@@ -1358,7 +1358,9 @@ convertRasterByRows(pnmOut * const + if (UINT_MAX/cols < spp) + pm_error("Image is too wide/deep (%u x %u) for computations", + cols, spp); - MALLOCARRAY(samplebuf, cols * spp); + /* samplebuf is unsigned int * !!! */ + samplebuf = (unsigned int *) malloc3(cols , sizeof(unsigned int) , spp); @@ -232,11 +198,11 @@ Index: netpbm-11.2.0/converter/other/tifftopnm.c if (samplebuf == NULL) pm_error("can't allocate memory for row buffer"); -Index: netpbm-11.2.0/converter/other/xwdtopnm.c +Index: netpbm-11.5.2/converter/other/xwdtopnm.c =================================================================== ---- netpbm-11.2.0.orig/converter/other/xwdtopnm.c -+++ netpbm-11.2.0/converter/other/xwdtopnm.c -@@ -210,6 +210,10 @@ processX10Header(X10WDFileHeader * cons +--- netpbm-11.5.2.orig/converter/other/xwdtopnm.c ++++ netpbm-11.5.2/converter/other/xwdtopnm.c +@@ -224,6 +224,10 @@ processX10Header(X10WDFileHeader * cons *colorsP = pnm_allocrow(2); PNM_ASSIGN1((*colorsP)[0], 0); PNM_ASSIGN1((*colorsP)[1], *maxvalP); @@ -246,38 +212,38 @@ Index: netpbm-11.2.0/converter/other/xwdtopnm.c + overflow2((((h10P->pixmap_width + 15) / 16) * 16 - h10P->pixmap_width), 8); *padrightP = (((h10P->pixmap_width + 15) / 16) * 16 - h10P->pixmap_width) * 8; - *bits_per_itemP = 16; -@@ -638,6 +642,7 @@ processX11Header(X11WDFileHeader * cons - - *colsP = h11FixedP->pixmap_width; - *rowsP = h11FixedP->pixmap_height; + *bitsPerItemP = 16; +@@ -673,6 +677,7 @@ processX11Header(const X11WDFileHeader * + "%u bits per pixel, which is too many for this program " + "to compute", + h11FixedP->pixmap_width, h11FixedP->bits_per_pixel); + overflow2(h11FixedP->bytes_per_line, 8); *padrightP = h11FixedP->bytes_per_line * 8 - h11FixedP->pixmap_width * h11FixedP->bits_per_pixel; -Index: netpbm-11.2.0/converter/pbm/mdatopbm.c +Index: netpbm-11.5.2/converter/pbm/mdatopbm.c =================================================================== ---- netpbm-11.2.0.orig/converter/pbm/mdatopbm.c -+++ netpbm-11.2.0/converter/pbm/mdatopbm.c -@@ -245,10 +245,13 @@ main(int argc, char **argv) { - pm_readlittleshort(infile, &yy); nInCols = yy; +--- netpbm-11.5.2.orig/converter/pbm/mdatopbm.c ++++ netpbm-11.5.2/converter/pbm/mdatopbm.c +@@ -283,10 +283,13 @@ main(int argc, const char **argv) { + pm_readlittleshort(ifP, &yy); nInCols = yy; } - + + overflow2(nOutCols, 8); nOutCols = 8 * nInCols; nOutRows = nInRows; -- if (bScale) -+ if (bScale) { +- if (bScale) ++ if (bScale){ + overflow2(nOutRows, 2); nOutRows *= 2; + } data = pbm_allocarray(nOutCols, nOutRows); - -Index: netpbm-11.2.0/converter/pbm/mgrtopbm.c + +Index: netpbm-11.5.2/converter/pbm/mgrtopbm.c =================================================================== ---- netpbm-11.2.0.orig/converter/pbm/mgrtopbm.c -+++ netpbm-11.2.0/converter/pbm/mgrtopbm.c +--- netpbm-11.5.2.orig/converter/pbm/mgrtopbm.c ++++ netpbm-11.5.2/converter/pbm/mgrtopbm.c @@ -105,6 +105,8 @@ readMgrHeader(FILE * const ifP, interpHdrWidth (head, colsP); interpHdrHeight(head, rowsP); @@ -287,10 +253,10 @@ Index: netpbm-11.2.0/converter/pbm/mgrtopbm.c *padrightP = ((*colsP + pad - 1) / pad) * pad - *colsP; } -Index: netpbm-11.2.0/converter/pbm/pbmtogem.c +Index: netpbm-11.5.2/converter/pbm/pbmtogem.c =================================================================== ---- netpbm-11.2.0.orig/converter/pbm/pbmtogem.c -+++ netpbm-11.2.0/converter/pbm/pbmtogem.c +--- netpbm-11.5.2.orig/converter/pbm/pbmtogem.c ++++ netpbm-11.5.2/converter/pbm/pbmtogem.c @@ -79,6 +79,7 @@ putinit (int const rows, int const cols) bitsperitem = 0; bitshift = 7; @@ -299,10 +265,10 @@ Index: netpbm-11.2.0/converter/pbm/pbmtogem.c outmax = (cols + 7) / 8; outrow = (unsigned char *) pm_allocrow (outmax, sizeof (unsigned char)); lastrow = (unsigned char *) pm_allocrow (outmax, sizeof (unsigned char)); -Index: netpbm-11.2.0/converter/pbm/pbmtogo.c +Index: netpbm-11.5.2/converter/pbm/pbmtogo.c =================================================================== ---- netpbm-11.2.0.orig/converter/pbm/pbmtogo.c -+++ netpbm-11.2.0/converter/pbm/pbmtogo.c +--- netpbm-11.5.2.orig/converter/pbm/pbmtogo.c ++++ netpbm-11.5.2/converter/pbm/pbmtogo.c @@ -158,6 +158,7 @@ main(int argc, bitrow = pbm_allocrow(cols); @@ -311,11 +277,11 @@ Index: netpbm-11.2.0/converter/pbm/pbmtogo.c rucols = ( cols + 7 ) / 8; bytesperrow = rucols; /* GraphOn uses bytes */ rucols = rucols * 8; -Index: netpbm-11.2.0/converter/pbm/pbmtolj.c +Index: netpbm-11.5.2/converter/pbm/pbmtolj.c =================================================================== ---- netpbm-11.2.0.orig/converter/pbm/pbmtolj.c -+++ netpbm-11.2.0/converter/pbm/pbmtolj.c -@@ -120,7 +120,11 @@ parseCommandLine(int argc, char ** argv, +--- netpbm-11.5.2.orig/converter/pbm/pbmtolj.c ++++ netpbm-11.5.2/converter/pbm/pbmtolj.c +@@ -122,7 +122,11 @@ parseCommandLine(int argc, const char ** static void allocateBuffers(unsigned int const cols) { @@ -327,23 +293,23 @@ Index: netpbm-11.2.0/converter/pbm/pbmtolj.c packBufferSize = rowBufferSize + (rowBufferSize + 127) / 128 + 1; deltaBufferSize = rowBufferSize + rowBufferSize / 8 + 10; -Index: netpbm-11.2.0/converter/pbm/pbmtomda.c +Index: netpbm-11.5.2/converter/pbm/pbmtomda.c =================================================================== ---- netpbm-11.2.0.orig/converter/pbm/pbmtomda.c -+++ netpbm-11.2.0/converter/pbm/pbmtomda.c -@@ -179,6 +179,7 @@ int main(int argc, char **argv) - - nOutRowsUnrounded = bScale ? nInRows/2 : nInRows; +--- netpbm-11.5.2.orig/converter/pbm/pbmtomda.c ++++ netpbm-11.5.2/converter/pbm/pbmtomda.c +@@ -206,6 +206,7 @@ main(int argc, const char ** argv) { + + nOutRowsUnrounded = cmdline.dscale ? nInRows/2 : nInRows; + overflow_add(nOutRowsUnrounded, 3); nOutRows = ((nOutRowsUnrounded + 3) / 4) * 4; - /* MDA wants rows a multiple of 4 */ + /* MDA wants rows a multiple of 4 */ nOutCols = nInCols / 8; -Index: netpbm-11.2.0/converter/pbm/pbmtoppa/pbm.c +Index: netpbm-11.5.2/converter/pbm/pbmtoppa/pbm.c =================================================================== ---- netpbm-11.2.0.orig/converter/pbm/pbmtoppa/pbm.c -+++ netpbm-11.2.0/converter/pbm/pbmtoppa/pbm.c -@@ -154,6 +154,7 @@ pbm_readline(pbm_stat * const pbmSt +--- netpbm-11.5.2.orig/converter/pbm/pbmtoppa/pbm.c ++++ netpbm-11.5.2/converter/pbm/pbmtoppa/pbm.c +@@ -157,6 +157,7 @@ pbm_readline(pbm_stat * const pbmSt break; case P4: { int tmp, tmp2; @@ -351,7 +317,7 @@ Index: netpbm-11.2.0/converter/pbm/pbmtoppa/pbm.c tmp = (pbmStatP->width+7)/8; tmp2 = fread(data,1,tmp,pbmStatP->fptr); if (tmp2 == tmp) { -@@ -186,6 +187,7 @@ pbm_unreadline(pbm_stat * const pbmStatP +@@ -189,6 +190,7 @@ pbm_unreadline(pbm_stat * const pbmStatP if (!pbmStatP->unread) { pbmStatP->unread = 1; @@ -359,79 +325,34 @@ Index: netpbm-11.2.0/converter/pbm/pbmtoppa/pbm.c pbmStatP->revdata = malloc ((pbmStatP->width+7)/8); memcpy(pbmStatP->revdata, data, (pbmStatP->width+7)/8); --pbmStatP->current_line; -Index: netpbm-11.2.0/converter/pbm/pbmtoppa/pbmtoppa.c +Index: netpbm-11.5.2/converter/pbm/pbmtoppa/pbmtoppa.c =================================================================== ---- netpbm-11.2.0.orig/converter/pbm/pbmtoppa/pbmtoppa.c -+++ netpbm-11.2.0/converter/pbm/pbmtoppa/pbmtoppa.c -@@ -453,6 +453,7 @@ main(int argc, char *argv[]) { +--- netpbm-11.5.2.orig/converter/pbm/pbmtoppa/pbmtoppa.c ++++ netpbm-11.5.2/converter/pbm/pbmtoppa/pbmtoppa.c +@@ -456,6 +456,7 @@ main(int argc, char *argv[]) { pm_error("main(): unrecognized parameter '%s'", argv[argn]); } + overflow_add(Width, 7); - Pwidth=(Width+7)/8; - printer.fptr=out; + Pwidth = (Width+7)/8; + printer.fptr = ofP; -Index: netpbm-11.2.0/converter/pbm/pbmtoxbm.c +Index: netpbm-11.5.2/converter/pbm/thinkjettopbm.l =================================================================== ---- netpbm-11.2.0.orig/converter/pbm/pbmtoxbm.c -+++ netpbm-11.2.0/converter/pbm/pbmtoxbm.c -@@ -353,6 +353,8 @@ convertRaster(FILE * const ifP, - unsigned char * bitrow; - unsigned int row; - -+ overflow_add(cols, padright); -+ - putinit(xbmVersion); - - bitrow = pbm_allocrow_packed(cols + padright); -Index: netpbm-11.2.0/converter/pbm/pbmto4425.c -=================================================================== ---- netpbm-11.2.0.orig/converter/pbm/pbmto4425.c -+++ netpbm-11.2.0/converter/pbm/pbmto4425.c -@@ -2,6 +2,7 @@ - - #include "nstring.h" - #include "pbm.h" -+#include - - static char bit_table[2][3] = { - {1, 4, 0x10}, -@@ -160,7 +161,7 @@ main(int argc, char * argv[]) { - xres = vmap_width * 2; - yres = vmap_height * 3; - -- vmap = malloc(vmap_width * vmap_height * sizeof(char)); -+ vmap = malloc3(vmap_width, vmap_height, sizeof(char)); - if(vmap == NULL) - { - pm_error( "Cannot allocate memory" ); -Index: netpbm-11.2.0/converter/pbm/pktopbm.c -=================================================================== ---- netpbm-11.2.0.orig/converter/pbm/pktopbm.c -+++ netpbm-11.2.0/converter/pbm/pktopbm.c -@@ -280,6 +280,7 @@ main(int argc, char *argv[]) { - if (flagbyte == 7) { /* long form preamble */ - integer packetlength = get32() ; /* character packet length */ - car = get32() ; /* character number */ -+ overflow_add(packetlength, pktopbm_pkloc); - endofpacket = packetlength + pktopbm_pkloc; - /* calculate end of packet */ - if ((car >= MAXPKCHAR) || !filename[car]) { -Index: netpbm-11.2.0/converter/pbm/thinkjettopbm.l -=================================================================== ---- netpbm-11.2.0.orig/converter/pbm/thinkjettopbm.l -+++ netpbm-11.2.0/converter/pbm/thinkjettopbm.l -@@ -114,7 +114,9 @@ DIG [0-9] +--- netpbm-11.5.2.orig/converter/pbm/thinkjettopbm.l ++++ netpbm-11.5.2/converter/pbm/thinkjettopbm.l +@@ -115,8 +115,10 @@ DIG [0-9] \033\*b{DIG}+W { int l; if (rowCount >= rowCapacity) { + overflow_add(rowCapacity, 100); - rowCapacity += 100; + if (rowCapacity > INT_MAX-100) + pm_error("Too many rows to count"); + overflow2(rowCapacity, sizeof *rows); - rows = realloc (rows, rowCapacity * sizeof *rows); + rowCapacity += 100; + REALLOCARRAY(rows, rowCapacity); if (rows == NULL) - pm_error ("Out of memory."); -@@ -226,6 +228,8 @@ yywrap (void) +@@ -232,6 +234,8 @@ yywrap (void) /* * Quite simple since ThinkJet bit arrangement matches PBM */ @@ -440,54 +361,43 @@ Index: netpbm-11.2.0/converter/pbm/thinkjettopbm.l pbm_writepbminit(stdout, maxRowLength*8, rowCount, 0); packed_bitrow = malloc(maxRowLength); -Index: netpbm-11.2.0/converter/pgm/lispmtopgm.c +Index: netpbm-11.5.2/converter/pgm/lispmtopgm.c =================================================================== ---- netpbm-11.2.0.orig/converter/pgm/lispmtopgm.c -+++ netpbm-11.2.0/converter/pgm/lispmtopgm.c -@@ -58,6 +58,7 @@ main( argc, argv ) - pm_error( "depth (%d bits) is too large", depth); - - pgm_writepgminit( stdout, cols, rows, (gray) maxval, 0 ); -+ overflow_add(cols, 7); - grayrow = pgm_allocrow( ( cols + 7 ) / 8 * 8 ); - - for ( row = 0; row < rows; ++row ) -@@ -102,7 +103,9 @@ getinit( file, colsP, rowsP, depthP, pad - - if ( *depthP == 0 ) - *depthP = 1; /* very old file */ -- -+ -+ overflow_add((int)colsP, 31); -+ - *padrightP = ( ( *colsP + 31 ) / 32 ) * 32 - *colsP; - - if ( *colsP != (cols_32 - *padrightP) ) { -Index: netpbm-11.2.0/converter/pgm/psidtopgm.c -=================================================================== ---- netpbm-11.2.0.orig/converter/pgm/psidtopgm.c -+++ netpbm-11.2.0/converter/pgm/psidtopgm.c -@@ -78,6 +78,7 @@ main(int argc, - pm_error("bits/sample (%d) is too large.", bitspersample); +--- netpbm-11.5.2.orig/converter/pgm/lispmtopgm.c ++++ netpbm-11.5.2/converter/pgm/lispmtopgm.c +@@ -167,6 +167,7 @@ main(int argc, const char ** argv) { pgm_writepgminit(stdout, cols, rows, maxval, 0); -+ overflow_add(cols, 7); - grayrow = pgm_allocrow((cols + 7) / 8 * 8); - for (row = 0; row < rows; ++row) { - unsigned int col; -Index: netpbm-11.2.0/converter/ppm/ilbmtoppm.c -=================================================================== ---- netpbm-11.2.0.orig/converter/ppm/ilbmtoppm.c -+++ netpbm-11.2.0/converter/ppm/ilbmtoppm.c -@@ -608,6 +608,7 @@ decode_row(FILE * const ifP, - rawtype *chp; - cols = bmhdP->w; ++ overflow_add(cols, 7); + grayrow = pgm_allocrow(ROUNDUP(cols, 8)); + + for (row = 0; row < rows; ++row) { +Index: netpbm-11.5.2/converter/pgm/psidtopgm.c +=================================================================== +--- netpbm-11.5.2.orig/converter/pgm/psidtopgm.c ++++ netpbm-11.5.2/converter/pgm/psidtopgm.c +@@ -81,6 +81,7 @@ main(int argc, + + pgm_writepgminit(stdout, cols, rows, maxval, 0); + ++ overflow_add(cols, 7); + grayrow = pgm_allocrow(ROUNDUP(cols, 8)); + + for (row = 0; row < rows; ++row) { +Index: netpbm-11.5.2/converter/ppm/ilbmtoppm.c +=================================================================== +--- netpbm-11.5.2.orig/converter/ppm/ilbmtoppm.c ++++ netpbm-11.5.2/converter/ppm/ilbmtoppm.c +@@ -617,6 +617,7 @@ decodeRow(FILE * const ifP, + rawtype * chP; + + cols = bmhdP->w; + overflow_add(cols, 15); - bytes = RowBytes(cols); - for( plane = 0; plane < nPlanes; plane++ ) { - int mask; -@@ -695,6 +696,23 @@ decode_mask(FILE * const ifP, + bytes = ilbm_rowByteCt(cols); + + for (plane = 0; plane < nPlanes; ++plane) { +@@ -711,6 +712,23 @@ decodeMask(FILE * const ifP, Multipalette handling ****************************************************************************/ @@ -511,69 +421,30 @@ Index: netpbm-11.2.0/converter/ppm/ilbmtoppm.c static void multi_adjust(ColorMap * const cmapP, -@@ -1363,6 +1381,10 @@ dcol_to_ppm(FILE * const ifP, - if( redmaxval != maxval || greenmaxval != maxval || bluemaxval != maxval ) - pm_message("scaling colors to %d bits", pm_maxvaltobits(maxval)); - -+ overflow_add(redmaxval, 1); -+ overflow_add(greenmaxval, 1); -+ overflow_add(bluemaxval, 1); -+ - MALLOCARRAY_NOFAIL(redtable, redmaxval +1); - MALLOCARRAY_NOFAIL(greentable, greenmaxval +1); - MALLOCARRAY_NOFAIL(bluetable, bluemaxval +1); -@@ -1802,7 +1824,9 @@ PCHG_ConvertSmall(PCHGHeader * const - ChangeCount32 = *data++; - remDataSize -= 2; - -+ overflow_add(ChangeCount16, ChangeCount32); - changes = ChangeCount16 + ChangeCount32; -+ overflow_add(changes, 1); - for (i = 0; i < changes; ++i) { - if (totalchanges >= pchgP->TotalChanges) goto fail; - if (remDataSize < 2) goto fail; -@@ -2067,6 +2091,9 @@ read_pchg(FILE * const ifP, - cmap->mp_change[i] = NULL; - if( PCHG.StartLine < 0 ) { - int nch; -+ if(PCHG.MaxReg < PCHG.MinReg) -+ pm_error("assert: MinReg > MaxReg"); -+ overflow_add(PCHG.MaxReg-PCHG.MinReg, 2); - nch = PCHG.MaxReg - PCHG.MinReg +1; - MALLOCARRAY_NOFAIL(cmap->mp_init, nch + 1); - for( i = 0; i < nch; i++ ) -@@ -2143,6 +2170,7 @@ process_body( FILE * const ifP, - if (typeid == ID_ILBM) { - int isdeep; - -+ overflow_add(bmhdP->w, 15); - MALLOCARRAY_NOFAIL(ilbmrow, RowBytes(bmhdP->w)); - *viewportmodesP |= fakeviewport; /* -isham/-isehb */ - -Index: netpbm-11.2.0/converter/ppm/imgtoppm.c +Index: netpbm-11.5.2/converter/ppm/imgtoppm.c =================================================================== ---- netpbm-11.2.0.orig/converter/ppm/imgtoppm.c -+++ netpbm-11.2.0/converter/ppm/imgtoppm.c -@@ -84,6 +84,7 @@ main(int argc, char ** argv) { - len = atoi((char*) buf ); - if ( fread( buf, len, 1, ifp ) != 1 ) - pm_error( "bad colormap buf" ); +--- netpbm-11.5.2.orig/converter/ppm/imgtoppm.c ++++ netpbm-11.5.2/converter/ppm/imgtoppm.c +@@ -85,6 +85,7 @@ main(int argc, const char ** argv) { + len = atoi((char*) buf); + if (fread(buf, len, 1, ifP) != 1) + pm_error("bad colormap buf"); + overflow2(cmaplen, 3); - if ( cmaplen * 3 != len ) - { + if (len != cmaplen * 3) { pm_message( -@@ -105,6 +106,7 @@ main(int argc, char ** argv) { - pm_error( "bad pixel data header" ); + "cmaplen (%u) and colormap buf length (%u) do not match", +@@ -105,6 +106,7 @@ main(int argc, const char ** argv) { + pm_error("bad pixel data header"); buf[8] = '\0'; - len = atoi((char*) buf ); + len = atoi((char*) buf); + overflow2(cols, rows); - if ( len != cols * rows ) + if (len != cols * rows) pm_message( - "pixel data length (%d) does not match image size (%d)", -Index: netpbm-11.2.0/converter/ppm/Makefile + "pixel data length (%u) does not match image size (%u)", +Index: netpbm-11.5.2/converter/ppm/Makefile =================================================================== ---- netpbm-11.2.0.orig/converter/ppm/Makefile -+++ netpbm-11.2.0/converter/ppm/Makefile +--- netpbm-11.5.2.orig/converter/ppm/Makefile ++++ netpbm-11.5.2/converter/ppm/Makefile @@ -11,7 +11,7 @@ SUBDIRS = hpcdtoppm ppmtompeg PORTBINARIES = 411toppm eyuvtoppm gouldtoppm ilbmtoppm imgtoppm \ @@ -583,102 +454,52 @@ Index: netpbm-11.2.0/converter/ppm/Makefile ppmtoacad ppmtoapplevol ppmtoarbtxt ppmtoascii \ ppmtobmp ppmtoeyuv ppmtogif ppmtoicr ppmtoilbm \ ppmtoleaf ppmtolj ppmtomitsu ppmtoneo \ -Index: netpbm-11.2.0/converter/ppm/pcxtoppm.c +Index: netpbm-11.5.2/converter/ppm/pcxtoppm.c =================================================================== ---- netpbm-11.2.0.orig/converter/ppm/pcxtoppm.c -+++ netpbm-11.2.0/converter/ppm/pcxtoppm.c -@@ -409,6 +409,7 @@ pcx_planes_to_pixels(pixels, bitplanes, - /* - * clear the pixel buffer - */ -+ overflow2(bytesperline, 8); - npixels = (bytesperline * 8) / bitsperpixel; - p = pixels; - while (--npixels >= 0) -@@ -470,6 +471,7 @@ pcx_16col_to_ppm(FILE * const ifP, - } +--- netpbm-11.5.2.orig/converter/ppm/pcxtoppm.c ++++ netpbm-11.5.2/converter/ppm/pcxtoppm.c +@@ -375,6 +375,7 @@ pcxPlanesToPixels(unsigned char * const + pm_error("can't handle more than 1 bit per pixel"); + + /* Clear the pixel buffer - initial value */ ++ overflow2(bytesPerLine, 8); + for (i = 0; i < npixels; ++i) + pixels[i] = 0; + +@@ -452,6 +453,7 @@ pcx16ColToPpm(FILE * const ifP, + bytesPerLine); + + /* bytesPerLine should be >= bBitsPerPixel * cols / 8 */ ++ overflow2(bytesPerLine, 8); + rawcols = bytesPerLine * 8 / bitsPerPixel; - /* BytesPerLine should be >= BitsPerPixel * cols / 8 */ -+ overflow2(BytesPerLine, 8); - rawcols = BytesPerLine * 8 / BitsPerPixel; if (headerCols > rawcols) { - pm_message("warning - BytesPerLine = %d, " -Index: netpbm-11.2.0/converter/ppm/picttoppm.c +Index: netpbm-11.5.2/converter/ppm/picttoppm.c =================================================================== ---- netpbm-11.2.0.orig/converter/ppm/picttoppm.c -+++ netpbm-11.2.0/converter/ppm/picttoppm.c +--- netpbm-11.5.2.orig/converter/ppm/picttoppm.c ++++ netpbm-11.5.2/converter/ppm/picttoppm.c @@ -1,3 +1,5 @@ +#error "Unfixable. Don't ship me" + /* * picttoppm.c -- convert a MacIntosh PICT file to PPM format. * -Index: netpbm-11.2.0/converter/ppm/pjtoppm.c +Index: netpbm-11.5.2/converter/ppm/ppmtoeyuv.c =================================================================== ---- netpbm-11.2.0.orig/converter/ppm/pjtoppm.c -+++ netpbm-11.2.0/converter/ppm/pjtoppm.c -@@ -168,14 +168,20 @@ main(int argc, const char ** argv) { - case 'V': /* send plane */ - case 'W': /* send last plane */ - if (row >= rowsX || image == NULL) { -- if (row >= rowsX) -+ if (row >= rowsX) { -+ overflow_add(rows, 100); - rowsX += 100; -+ } - if (image == NULL) { -- MALLOCARRAY(image, uintProduct(rowsX, planes)); -- MALLOCARRAY(imlen, uintProduct(rowsX, planes)); -+ image = (unsigned char **) -+ malloc3(rowsX , planes , sizeof(unsigned char *)); -+ imlen = (int *) malloc3(rowsX , planes, sizeof(int)); - } else { -- REALLOCARRAY(image, uintProduct(rowsX, planes)); -- REALLOCARRAY(imlen, uintProduct(rowsX, planes)); -+ overflow2(rows,planes); -+ image = (unsigned char **) -+ realloc2(image, rowsX * planes, -+ sizeof(unsigned char *)); -+ imlen = (int *) realloc2(imlen, rowsX * planes, sizeof(int)); - } - } - if (image == NULL || imlen == NULL) -@@ -263,8 +269,10 @@ main(int argc, const char ** argv) { - col += 2) - for (cmd = image[plane + row * planes][col], - val = image[plane + row * planes][col+1]; -- cmd >= 0 && i < newcols; cmd--, i++) -+ cmd >= 0 && i < newcols; cmd--, i++) { - buf[i] = val; -+ overflow_add(i, 1); -+ } - cols = MAX(cols, i); - free(image[plane + row * planes]); - /* -@@ -275,6 +283,7 @@ main(int argc, const char ** argv) { - image[plane + row * planes] = realloc(buf, i); - } - } -+ overflow2(cols, 8); - cols *= 8; - } - -Index: netpbm-11.2.0/converter/ppm/ppmtoeyuv.c -=================================================================== ---- netpbm-11.2.0.orig/converter/ppm/ppmtoeyuv.c -+++ netpbm-11.2.0/converter/ppm/ppmtoeyuv.c -@@ -114,6 +114,7 @@ create_multiplication_tables(const pixva - - int index; +--- netpbm-11.5.2.orig/converter/ppm/ppmtoeyuv.c ++++ netpbm-11.5.2/converter/ppm/ppmtoeyuv.c +@@ -117,6 +117,7 @@ chrominanceBlue(pixel const p) { + static void + createMultiplicationTables(pixval const maxval) { + overflow_add(maxval, 1); MALLOCARRAY_NOFAIL(mult299 , maxval+1); MALLOCARRAY_NOFAIL(mult587 , maxval+1); MALLOCARRAY_NOFAIL(mult114 , maxval+1); -Index: netpbm-11.2.0/converter/ppm/ppmtoilbm.c +Index: netpbm-11.5.2/converter/ppm/ppmtoilbm.c =================================================================== ---- netpbm-11.2.0.orig/converter/ppm/ppmtoilbm.c -+++ netpbm-11.2.0/converter/ppm/ppmtoilbm.c +--- netpbm-11.5.2.orig/converter/ppm/ppmtoilbm.c ++++ netpbm-11.5.2/converter/ppm/ppmtoilbm.c @@ -188,6 +188,7 @@ makeValTable(int const oldmaxval, unsigned int i; int * table; @@ -687,7 +508,7 @@ Index: netpbm-11.2.0/converter/ppm/ppmtoilbm.c MALLOCARRAY_NOFAIL(table, oldmaxval + 1); for (i = 0; i <= oldmaxval; ++i) table[i] = ROUNDDIV(i * newmaxval, oldmaxval); -@@ -1625,6 +1626,7 @@ ppmToRgb8(FILE * const ifP, +@@ -1626,6 +1627,7 @@ ppmToRgb8(FILE * const ifP, maskmethod = 0; /* no masking - RGB8 uses genlock bits */ compmethod = 4; /* RGB8 files are always compressed */ @@ -695,7 +516,7 @@ Index: netpbm-11.2.0/converter/ppm/ppmtoilbm.c MALLOCARRAY_NOFAIL(compr_row, cols * 4); if( maxval != 255 ) { -@@ -1716,6 +1718,7 @@ ppmToRgbn(FILE * const ifP, +@@ -1717,6 +1719,7 @@ ppmToRgbn(FILE * const ifP, maskmethod = 0; /* no masking - RGBN uses genlock bits */ compmethod = 4; /* RGBN files are always compressed */ @@ -703,35 +524,37 @@ Index: netpbm-11.2.0/converter/ppm/ppmtoilbm.c MALLOCARRAY_NOFAIL(compr_row, cols * 2); if( maxval != 15 ) { -@@ -2277,8 +2280,10 @@ main(int argc, char ** argv) { - MALLOCARRAY_NOFAIL(coded_rowbuf, RowBytes(cols)); - for (i = 0; i < RowBytes(cols); ++i) +@@ -2278,10 +2281,12 @@ main(int argc, char ** argv) { + MALLOCARRAY_NOFAIL(coded_rowbuf, ilbm_rowByteCt(cols)); + for (i = 0; i < ilbm_rowByteCt(cols); ++i) coded_rowbuf[i] = 0; - if (DO_COMPRESS) + if (DO_COMPRESS) { + overflow_add(cols,15); - pm_rlenc_allocoutbuf(&compr_rowbuf, RowBytes(cols), PM_RLE_PACKBITS); + pm_rlenc_allocoutbuf(&compr_rowbuf, + ilbm_rowByteCt(cols), + PM_RLE_PACKBITS); + } } switch (mode) { -Index: netpbm-11.2.0/converter/ppm/ppmtolj.c +Index: netpbm-11.5.2/converter/ppm/ppmtolj.c =================================================================== ---- netpbm-11.2.0.orig/converter/ppm/ppmtolj.c -+++ netpbm-11.2.0/converter/ppm/ppmtolj.c -@@ -182,6 +182,7 @@ int main(int argc, char *argv[]) { - ppm_readppminit( ifp, &cols, &rows, &maxval, &format ); - pixelrow = ppm_allocrow( cols ); +--- netpbm-11.5.2.orig/converter/ppm/ppmtolj.c ++++ netpbm-11.5.2/converter/ppm/ppmtolj.c +@@ -212,6 +212,7 @@ printRaster(FILE * const ifP, + pm_error("Image is uncomputably wide (%u columns)", cols); + } + overflow2(cols, 6); obuf = (unsigned char *) pm_allocrow(cols * 3, sizeof(unsigned char)); cbuf = (unsigned char *) pm_allocrow(cols * 6, sizeof(unsigned char)); - if (mode == C_TRANS_MODE_DELTA) -Index: netpbm-11.2.0/converter/ppm/ppmtomitsu.c + +Index: netpbm-11.5.2/converter/ppm/ppmtomitsu.c =================================================================== ---- netpbm-11.2.0.orig/converter/ppm/ppmtomitsu.c -+++ netpbm-11.2.0/converter/ppm/ppmtomitsu.c -@@ -685,6 +685,8 @@ main(int argc, char * argv[]) { +--- netpbm-11.5.2.orig/converter/ppm/ppmtomitsu.c ++++ netpbm-11.5.2/converter/ppm/ppmtomitsu.c +@@ -68,6 +68,8 @@ mediaSize(const char * const media, medias = MSize_User; if (dpi300) { @@ -740,10 +563,10 @@ Index: netpbm-11.2.0/converter/ppm/ppmtomitsu.c medias.maxcols *= 2; medias.maxrows *= 2; } -Index: netpbm-11.2.0/converter/ppm/ppmtopcx.c +Index: netpbm-11.5.2/converter/ppm/ppmtopcx.c =================================================================== ---- netpbm-11.2.0.orig/converter/ppm/ppmtopcx.c -+++ netpbm-11.2.0/converter/ppm/ppmtopcx.c +--- netpbm-11.5.2.orig/converter/ppm/ppmtopcx.c ++++ netpbm-11.5.2/converter/ppm/ppmtopcx.c @@ -410,6 +410,9 @@ writeRaster16Color(FILE * const ofP, unsigned int row; @@ -754,176 +577,107 @@ Index: netpbm-11.2.0/converter/ppm/ppmtopcx.c MALLOCARRAY_NOFAIL(indexRow, cols); MALLOCARRAY(planesrow, bytesPerLine); -Index: netpbm-11.2.0/converter/ppm/ppmtopict.c +Index: netpbm-11.5.2/converter/ppm/ppmtopjxl.c =================================================================== ---- netpbm-11.2.0.orig/converter/ppm/ppmtopict.c -+++ netpbm-11.2.0/converter/ppm/ppmtopict.c -@@ -450,6 +450,8 @@ main(int argc, const char ** argv) { - putShort(stdout, 0); /* mode */ - - /* Finally, write out the data. */ -+ overflow_add(cols/MAX_COUNT, 1); -+ overflow_add(cols, cols/MAX_COUNT+1); - outBuf = malloc((unsigned)(cols+cols/MAX_COUNT+1)); - for (row = 0, oc = 0; row < rows; ++row) { - unsigned int rowSize; -Index: netpbm-11.2.0/converter/ppm/ppmtopj.c -=================================================================== ---- netpbm-11.2.0.orig/converter/ppm/ppmtopj.c -+++ netpbm-11.2.0/converter/ppm/ppmtopj.c -@@ -179,6 +179,7 @@ char *argv[]; - pixels = ppm_readppm( ifp, &cols, &rows, &maxval ); - - pm_close( ifp ); -+ overflow2(cols,2); - obuf = (unsigned char *) pm_allocrow(cols, sizeof(unsigned char)); - cbuf = (unsigned char *) pm_allocrow(cols * 2, sizeof(unsigned char)); - -Index: netpbm-11.2.0/converter/ppm/ppmtopjxl.c -=================================================================== ---- netpbm-11.2.0.orig/converter/ppm/ppmtopjxl.c -+++ netpbm-11.2.0/converter/ppm/ppmtopjxl.c -@@ -266,6 +266,8 @@ main(int argc, const char * argv[]) { +--- netpbm-11.5.2.orig/converter/ppm/ppmtopjxl.c ++++ netpbm-11.5.2/converter/ppm/ppmtopjxl.c +@@ -535,6 +535,8 @@ main(int argc, const char * argv[]) { pm_error("image too large; reduce with ppmscale"); if (maxval > PCL_MAXVAL) pm_error("color range too large; reduce with ppmcscale"); + if (cols < 0 || rows < 0) + pm_error("negative size is not possible"); - /* Figure out the colormap. */ - pm_message("Computing colormap..."); -@@ -286,6 +288,8 @@ main(int argc, const char * argv[]) { - case 0: /* direct mode (no palette) */ - bpp = bitsperpixel(maxval); /* bits per pixel */ - bpg = bpp; bpb = bpp; -+ overflow2(bpp, 3); -+ overflow_add(bpp*3, 7); - bpp = (bpp*3+7)>>3; /* bytes per pixel now */ - bpr = (bpp<<3)-bpg-bpb; - bpp *= cols; /* bytes per row now */ -@@ -295,9 +299,13 @@ main(int argc, const char * argv[]) { - case 3: case 7: pclindex++; - default: - bpp = 8/pclindex; -+ overflow_add(cols, bpp); -+ if(bpp == 0) -+ pm_error("assert: no bpp"); - bpp = (cols+bpp-1)/bpp; /* bytes per row */ - } - } -+ overflow2(bpp,2); - inrow = (char *)malloc((unsigned)bpp); - outrow = (char *)malloc((unsigned)bpp*2); - runcnt = (signed char *)malloc((unsigned)bpp); -Index: netpbm-11.2.0/converter/ppm/ppmtowinicon.c -=================================================================== ---- netpbm-11.2.0.orig/converter/ppm/ppmtowinicon.c -+++ netpbm-11.2.0/converter/ppm/ppmtowinicon.c -@@ -12,6 +12,7 @@ + computeColormap(pixels, cols, rows, MAXCOLORS, &chv, &cht, &colorCt); +Index: netpbm-11.5.2/converter/ppm/ppmtowinicon.c +=================================================================== +--- netpbm-11.5.2.orig/converter/ppm/ppmtowinicon.c ++++ netpbm-11.5.2/converter/ppm/ppmtowinicon.c +@@ -13,6 +13,7 @@ + #include #include #include +#include #include "pm_c_util.h" #include "winico.h" -@@ -214,6 +215,7 @@ createAndBitmap (gray ** const ba, int c - MALLOCARRAY_NOFAIL(rowData, rows); - icBitmap->xBytes = xBytes; - icBitmap->data = rowData; -+ overflow2(xBytes, rows); - icBitmap->size = xBytes * rows; - for (y=0;yxBytes = xBytes; - icBitmap->data = rowData; -+ overflow2(xBytes, rows); - icBitmap->size = xBytes * rows; +@@ -208,6 +209,7 @@ newAndBitmap(gray ** const ba, + MALLOCARRAY_NOFAIL(rowData, rows); + icBitmapP->xBytes = xByteCt; + icBitmapP->data = rowData; ++ overflow2(xByteCt, rows); + icBitmapP->size = xByteCt * rows; + for (row = 0; row < rows; ++row) { + u1 * thisRow; /* malloc'ed */ +@@ -410,6 +412,7 @@ newBitmap(unsigned int const bpp, - for (y=0;yxBytes = xBytes; - icBitmap->data = rowData; -+ overflow2(xBytes, rows); - icBitmap->size = xBytes * rows; + icBitmapP->xBytes = xByteCt; + icBitmapP->data = rowData; ++ overflow2(xByteCt, rows); + icBitmapP->size = xByteCt * rows; - for (y=0;ybitcount = bpp; - entry->ih = createInfoHeader(entry, xorBitmap, andBitmap); - entry->colors = palette->colors; -+ overflow2(4, entry->color_count); -+ overflow_add(xorBitmap->size, andBitmap->size); -+ overflow_add(xorBitmap->size + andBitmap->size, 40); -+ overflow_add(xorBitmap->size + andBitmap->size + 40, 4 * entry->color_count); - entry->size_in_bytes = - xorBitmap->size + andBitmap->size + 40 + (4 * entry->color_count); - if (verbose) -Index: netpbm-11.2.0/converter/ppm/ppmtoxpm.c + unsigned int const assumedBpp = (pa == NULL) ? 1 : bpp; +@@ -700,6 +703,10 @@ addEntryToIcon(MS_Ico * const MSIcon + /* all the icons I looked at ignored this value */ + entryP->ih = newInfoHeader(*entryP); + entryP->colors = paletteP->colors; ++ overflow2(4, entryP->color_count); ++ overflow_add(xorBitmapP->size, andBitmapP->size); ++ overflow_add(xorBitmapP->size + andBitmapP->size, 40); ++ overflow_add(xorBitmapP->size + andBitmapP->size + 40, 4 * entryP->color_count); + entryP->size_in_bytes = + xorBitmapP->size + andBitmapP->size + 40 + (4 * entryCols); + if (verbose) +Index: netpbm-11.5.2/converter/ppm/ppmtoxpm.c =================================================================== ---- netpbm-11.2.0.orig/converter/ppm/ppmtoxpm.c -+++ netpbm-11.2.0/converter/ppm/ppmtoxpm.c -@@ -198,6 +198,7 @@ genNumstr(unsigned int const input, int +--- netpbm-11.5.2.orig/converter/ppm/ppmtoxpm.c ++++ netpbm-11.5.2/converter/ppm/ppmtoxpm.c +@@ -195,6 +195,7 @@ numstr(unsigned int const input, unsigned int i; /* Allocate memory for printed number. Abort if error. */ -+ overflow_add(digits, 1); - if (!(str = (char *) malloc(digits + 1))) - pm_error("out of memory"); ++ overflow_add(digitCt, 1); + MALLOCARRAY_NOFAIL(str, digitCt + 1); -@@ -315,6 +316,7 @@ genCmap(colorhist_vector const chv, + i = input; /* initial value */ +@@ -310,6 +311,7 @@ genCmap(colorhist_vector const chv, unsigned int charsPerPixel; unsigned int xpmMaxval; - + + if (includeTransparent) overflow_add(ncolors, 1); MALLOCARRAY(cmap, cmapSize); if (cmapP == NULL) - pm_error("Out of memory allocating %u bytes for a color map.", -Index: netpbm-11.2.0/converter/ppm/qrttoppm.c + pm_error("Can't get memory for a %u-entry color map", cmapSize); +Index: netpbm-11.5.2/converter/ppm/qrttoppm.c =================================================================== ---- netpbm-11.2.0.orig/converter/ppm/qrttoppm.c -+++ netpbm-11.2.0/converter/ppm/qrttoppm.c -@@ -46,7 +46,7 @@ main( argc, argv ) +--- netpbm-11.5.2.orig/converter/ppm/qrttoppm.c ++++ netpbm-11.5.2/converter/ppm/qrttoppm.c +@@ -51,6 +51,7 @@ main(int argc, const char ** argv) { - ppm_writeppminit( stdout, cols, rows, maxval, 0 ); - pixelrow = ppm_allocrow( cols ); -- buf = (unsigned char *) malloc( 3 * cols ); -+ buf = (unsigned char *) malloc2( 3 , cols ); - if ( buf == (unsigned char *) 0 ) - pm_error( "out of memory" ); + pixelrow = ppm_allocrow(cols); -Index: netpbm-11.2.0/converter/ppm/sldtoppm.c ++ overflow2(3, cols); + MALLOCARRAY(buf, 3 * cols); + + if (!buf) +Index: netpbm-11.5.2/converter/ppm/sldtoppm.c =================================================================== ---- netpbm-11.2.0.orig/converter/ppm/sldtoppm.c -+++ netpbm-11.2.0/converter/ppm/sldtoppm.c -@@ -506,6 +506,8 @@ slider(slvecfn slvec, +--- netpbm-11.5.2.orig/converter/ppm/sldtoppm.c ++++ netpbm-11.5.2/converter/ppm/sldtoppm.c +@@ -542,6 +542,8 @@ slider(slvecfn slvec, /* Allocate image buffer and clear it to black. */ + overflow_add(ixdots,1); + overflow_add(iydots,1); - pixels = ppm_allocarray(pixcols = ixdots + 1, pixrows = iydots + 1); - PPM_ASSIGN(rgbcolor, 0, 0, 0); - ppmd_filledrectangle(pixels, pixcols, pixrows, pixmaxval, 0, 0, -Index: netpbm-11.2.0/converter/ppm/ximtoppm.c + pixcols = ixdots + 1; + pixrows = iydots + 1; + pixels = ppm_allocarray(pixcols, pixrows); +Index: netpbm-11.5.2/editor/pamcut.c =================================================================== ---- netpbm-11.2.0.orig/converter/ppm/ximtoppm.c -+++ netpbm-11.2.0/converter/ppm/ximtoppm.c -@@ -147,6 +147,7 @@ ReadXimHeader(FILE * const in_fp, - if (header->nchannels == 3 && header->bits_channel == 8) - header->ncolors = 0; - else if (header->nchannels == 1 && header->bits_channel == 8) { -+ overflow2(header->ncolors, sizeof(Color)); - header->colors = (Color *)calloc((unsigned int)header->ncolors, - sizeof(Color)); - if (header->colors == NULL) { -Index: netpbm-11.2.0/editor/pamcut.c -=================================================================== ---- netpbm-11.2.0.orig/editor/pamcut.c -+++ netpbm-11.2.0/editor/pamcut.c +--- netpbm-11.5.2.orig/editor/pamcut.c ++++ netpbm-11.5.2/editor/pamcut.c @@ -799,6 +799,8 @@ cutOneImage(FILE * const ifP outpam = inpam; /* Initial value -- most fields should be same */ @@ -933,10 +687,10 @@ Index: netpbm-11.2.0/editor/pamcut.c outpam.width = rightcol - leftcol + 1; outpam.height = bottomrow - toprow + 1; -Index: netpbm-11.2.0/editor/pbmreduce.c +Index: netpbm-11.5.2/editor/pbmreduce.c =================================================================== ---- netpbm-11.2.0.orig/editor/pbmreduce.c -+++ netpbm-11.2.0/editor/pbmreduce.c +--- netpbm-11.5.2.orig/editor/pbmreduce.c ++++ netpbm-11.5.2/editor/pbmreduce.c @@ -153,6 +153,7 @@ initializeFloydSteinberg(struct FS * co unsigned int col; struct pm_randSt randSt; @@ -945,10 +699,10 @@ Index: netpbm-11.2.0/editor/pbmreduce.c MALLOCARRAY(fsP->thiserr, newcols + 2); MALLOCARRAY(fsP->nexterr, newcols + 2); -Index: netpbm-11.2.0/editor/pnmgamma.c +Index: netpbm-11.5.2/editor/pnmgamma.c =================================================================== ---- netpbm-11.2.0.orig/editor/pnmgamma.c -+++ netpbm-11.2.0/editor/pnmgamma.c +--- netpbm-11.5.2.orig/editor/pnmgamma.c ++++ netpbm-11.5.2/editor/pnmgamma.c @@ -596,6 +596,7 @@ createGammaTables(enum transferFunction xelval ** const btableP) { @@ -957,11 +711,11 @@ Index: netpbm-11.2.0/editor/pnmgamma.c MALLOCARRAY(*rtableP, maxval+1); MALLOCARRAY(*gtableP, maxval+1); MALLOCARRAY(*btableP, maxval+1); -Index: netpbm-11.2.0/editor/pnmhisteq.c +Index: netpbm-11.5.2/editor/pnmhisteq.c =================================================================== ---- netpbm-11.2.0.orig/editor/pnmhisteq.c -+++ netpbm-11.2.0/editor/pnmhisteq.c -@@ -107,6 +107,7 @@ computeLuminosityHistogram(xel * const * +--- netpbm-11.5.2.orig/editor/pnmhisteq.c ++++ netpbm-11.5.2/editor/pnmhisteq.c +@@ -106,6 +106,7 @@ computeLuminosityHistogram(xel * const * unsigned int pixelCount; unsigned int * lumahist; @@ -969,11 +723,11 @@ Index: netpbm-11.2.0/editor/pnmhisteq.c MALLOCARRAY(lumahist, maxval + 1); if (lumahist == NULL) pm_error("Out of storage allocating array for %u histogram elements", -Index: netpbm-11.2.0/editor/pnmpad.c +Index: netpbm-11.5.2/editor/pnmpad.c =================================================================== ---- netpbm-11.2.0.orig/editor/pnmpad.c -+++ netpbm-11.2.0/editor/pnmpad.c -@@ -654,6 +654,8 @@ main(int argc, const char ** argv) { +--- netpbm-11.5.2.orig/editor/pnmpad.c ++++ netpbm-11.5.2/editor/pnmpad.c +@@ -1127,6 +1127,8 @@ main(int argc, const char ** argv) { computePadSizes(cmdline, cols, rows, &lpad, &rpad, &tpad, &bpad); @@ -982,20 +736,19 @@ Index: netpbm-11.2.0/editor/pnmpad.c newcols = cols + lpad + rpad; if (cmdline.reportonly) -Index: netpbm-11.2.0/editor/pnmremap.c +Index: netpbm-11.5.2/editor/pnmremap.c =================================================================== ---- netpbm-11.2.0.orig/editor/pnmremap.c -+++ netpbm-11.2.0/editor/pnmremap.c -@@ -469,7 +469,7 @@ fserr_init(struct pam * const pamP, +--- netpbm-11.5.2.orig/editor/pnmremap.c ++++ netpbm-11.5.2/editor/pnmremap.c +@@ -469,6 +469,7 @@ fserr_init(struct pam * const pamP, unsigned int plane; - unsigned int const fserrSize = pamP->width + 2; -- + unsigned int const fserrSz = pamP->width + 2; + overflow_add(pamP->width, 2); + fserrP->width = pamP->width; - MALLOCARRAY(fserrP->thiserr, pamP->depth); -@@ -508,6 +508,7 @@ floydInitRow(struct pam * const pamP, +@@ -508,6 +509,7 @@ floydInitRow(struct pam * const pamP, unsigned int col; @@ -1003,42 +756,10 @@ Index: netpbm-11.2.0/editor/pnmremap.c for (col = 0; col < pamP->width + 2; ++col) { unsigned int plane; for (plane = 0; plane < pamP->depth; ++plane) -Index: netpbm-11.2.0/editor/pnmscalefixed.c +Index: netpbm-11.5.2/editor/pnmshear.c =================================================================== ---- netpbm-11.2.0.orig/editor/pnmscalefixed.c -+++ netpbm-11.2.0/editor/pnmscalefixed.c -@@ -214,6 +214,8 @@ compute_output_dimensions(const struct c - const int rows, const int cols, - int * newrowsP, int * newcolsP) { - -+ overflow2(rows, cols); -+ - if (cmdline.pixels) { - if (rows * cols <= cmdline.pixels) { - *newrowsP = rows; -@@ -265,6 +267,8 @@ compute_output_dimensions(const struct c - - if (*newcolsP < 1) *newcolsP = 1; - if (*newrowsP < 1) *newrowsP = 1; -+ -+ overflow2(*newcolsP, *newrowsP); - } - - -@@ -446,6 +450,9 @@ main(int argc, char **argv ) { - unfilled. We can address that by stretching, whereas the other - case would require throwing away some of the input. - */ -+ -+ overflow2(newcols, SCALE); -+ overflow2(newrows, SCALE); - sxscale = SCALE * newcols / cols; - syscale = SCALE * newrows / rows; - -Index: netpbm-11.2.0/editor/pnmshear.c -=================================================================== ---- netpbm-11.2.0.orig/editor/pnmshear.c -+++ netpbm-11.2.0/editor/pnmshear.c +--- netpbm-11.5.2.orig/editor/pnmshear.c ++++ netpbm-11.5.2/editor/pnmshear.c @@ -15,6 +15,7 @@ #include #include @@ -1059,48 +780,23 @@ Index: netpbm-11.2.0/editor/pnmshear.c newcolsD = (double) rows * fabs(shearfac) + cols + 0.999999; if (newcolsD > INT_MAX-2) pm_error("angle is too close to +/-90 degrees; " -Index: netpbm-11.2.0/editor/ppmdither.c +Index: netpbm-11.5.2/editor/specialty/pamoil.c =================================================================== ---- netpbm-11.2.0.orig/editor/ppmdither.c -+++ netpbm-11.2.0/editor/ppmdither.c -@@ -355,7 +355,11 @@ dithMatrix(unsigned int const dithPower) - unsigned int const dithMatSize = - (dithDim * sizeof(*dithMat)) + /* pointers */ - (dithDim * dithDim * sizeof(**dithMat)); /* data */ -- -+ -+ overflow2(dithDim, sizeof(*dithMat)); -+ overflow3(dithDim, dithDim, sizeof(**dithMat)); -+ overflow_add(dithDim * sizeof(*dithMat), dithDim * dithDim * sizeof(**dithMat)); -+ - dithMat = malloc(dithMatSize); - - if (dithMat == NULL) -Index: netpbm-11.2.0/editor/specialty/pamoil.c -=================================================================== ---- netpbm-11.2.0.orig/editor/specialty/pamoil.c -+++ netpbm-11.2.0/editor/specialty/pamoil.c -@@ -112,6 +112,7 @@ main(int argc, char *argv[] ) { - tuples = pnm_readpam(ifp, &inpam, PAM_STRUCT_SIZE(tuple_type)); - pm_close(ifp); +--- netpbm-11.5.2.orig/editor/specialty/pamoil.c ++++ netpbm-11.5.2/editor/specialty/pamoil.c +@@ -185,6 +185,7 @@ main(int argc, const char ** argv) { + + tuples = pnm_readpam(ifP, &inpam, PAM_STRUCT_SIZE(tuple_type)); + overflow_add(inpam.maxval, 1); MALLOCARRAY(hist, inpam.maxval + 1); if (hist == NULL) pm_error("Unable to allocate memory for histogram."); -Index: netpbm-11.2.0/generator/pbmtext.c +Index: netpbm-11.5.2/generator/pbmtext.c =================================================================== ---- netpbm-11.2.0.orig/generator/pbmtext.c -+++ netpbm-11.2.0/generator/pbmtext.c -@@ -1144,6 +1144,7 @@ getText(PM_WCHAR const cmdli - "Cannot process", - lineCount, (unsigned int) MAXLINECHARS); - if (lineCount >= maxlines) { -+ overflow2(maxlines, 2); - maxlines *= 2; - REALLOCARRAY(textArray, maxlines); - if (textArray == NULL) -@@ -1184,6 +1185,7 @@ computeMargins(struct CmdlineInfo const +--- netpbm-11.5.2.orig/generator/pbmtext.c ++++ netpbm-11.5.2/generator/pbmtext.c +@@ -1193,6 +1193,7 @@ computeMargins(struct CmdlineInfo const *hmarginP = fontP->maxwidth; } else { *vmarginP = fontP->maxheight; @@ -1108,11 +804,11 @@ Index: netpbm-11.2.0/generator/pbmtext.c *hmarginP = 2 * fontP->maxwidth; } } -Index: netpbm-11.2.0/generator/pgmkernel.c +Index: netpbm-11.5.2/generator/pgmkernel.c =================================================================== ---- netpbm-11.2.0.orig/generator/pgmkernel.c -+++ netpbm-11.2.0/generator/pgmkernel.c -@@ -214,6 +214,7 @@ main(int argc, const char * argv[]) { +--- netpbm-11.5.2.orig/generator/pgmkernel.c ++++ netpbm-11.5.2/generator/pgmkernel.c +@@ -224,6 +224,7 @@ main(int argc, const char * argv[]) { /* Output matrix is symmetric vertically and horizontally. */ @@ -1120,39 +816,39 @@ Index: netpbm-11.2.0/generator/pgmkernel.c arows = (cmdline.rows + 1) / 2; /* Half the number of rows. Add 1 if odd. */ halfKernel = pgm_allocarray(cmdline.cols, arows); -Index: netpbm-11.2.0/lib/libpammap.c +Index: netpbm-11.5.2/lib/libpammap.c =================================================================== ---- netpbm-11.2.0.orig/lib/libpammap.c -+++ netpbm-11.2.0/lib/libpammap.c -@@ -108,6 +108,8 @@ allocTupleIntListItem(struct pam * const - */ - struct tupleint_list_item * retval; +--- netpbm-11.5.2.orig/lib/libpammap.c ++++ netpbm-11.5.2/lib/libpammap.c +@@ -111,6 +111,8 @@ allocTupleIntListItem(struct pam * const + if (pamP->depth > (UINT_MAX - sizeof(*retval)) / sizeof(sample)) + pm_error("Depth %u is too large for computation", pamP->depth); + overflow2(pamP->depth, sizeof(sample)); + overflow_add(sizeof(*retval)-sizeof(retval->tupleint.tuple), pamP->depth*sizeof(sample)); unsigned int const size = sizeof(*retval) - sizeof(retval->tupleint.tuple) + pamP->depth * sizeof(sample); -Index: netpbm-11.2.0/lib/libpbm1.c +Index: netpbm-11.5.2/lib/libpbm1.c =================================================================== ---- netpbm-11.2.0.orig/lib/libpbm1.c -+++ netpbm-11.2.0/lib/libpbm1.c -@@ -79,6 +79,7 @@ pbm_check(FILE * const fil - } else { +--- netpbm-11.5.2.orig/lib/libpbm1.c ++++ netpbm-11.5.2/lib/libpbm1.c +@@ -80,6 +80,7 @@ pbm_check(FILE * const fil + } else { pm_filepos const bytesPerRow = (cols+7)/8; pm_filepos const needRasterSize = rows * bytesPerRow; + overflow2(bytesPerRow, rows); pm_check(fileP, checkType, needRasterSize, retvalP); } } -Index: netpbm-11.2.0/lib/libpm.c +Index: netpbm-11.5.2/lib/libpm.c =================================================================== ---- netpbm-11.2.0.orig/lib/libpm.c -+++ netpbm-11.2.0/lib/libpm.c -@@ -892,4 +892,53 @@ pm_parse_height(const char * const arg) +--- netpbm-11.5.2.orig/lib/libpm.c ++++ netpbm-11.5.2/lib/libpm.c +@@ -904,6 +904,55 @@ pm_parse_height(const char * const arg) + return height; } - +/* + * Maths wrapping + */ @@ -1203,11 +899,13 @@ Index: netpbm-11.2.0/lib/libpm.c + return realloc(a, b*c); +} -Index: netpbm-11.2.0/lib/pm.h + + unsigned int +Index: netpbm-11.5.2/lib/pm.h =================================================================== ---- netpbm-11.2.0.orig/lib/pm.h -+++ netpbm-11.2.0/lib/pm.h -@@ -455,4 +455,11 @@ pm_parse_height(const char * const arg); +--- netpbm-11.5.2.orig/lib/pm.h ++++ netpbm-11.5.2/lib/pm.h +@@ -466,4 +466,11 @@ pm_parse_maxval(const char * const arg); #endif @@ -1219,11 +917,11 @@ Index: netpbm-11.2.0/lib/pm.h +void overflow_add(int, int); + #endif -Index: netpbm-11.2.0/other/pnmcolormap.c +Index: netpbm-11.5.2/other/pnmcolormap.c =================================================================== ---- netpbm-11.2.0.orig/other/pnmcolormap.c -+++ netpbm-11.2.0/other/pnmcolormap.c -@@ -1069,6 +1069,7 @@ colormapToSquare(struct pam * const pamP +--- netpbm-11.5.2.orig/other/pnmcolormap.c ++++ netpbm-11.5.2/other/pnmcolormap.c +@@ -1134,6 +1134,7 @@ colormapToSquare(struct pam * const pamP pamP->width = intsqrt; else pamP->width = intsqrt + 1; @@ -1231,10 +929,10 @@ Index: netpbm-11.2.0/other/pnmcolormap.c } { unsigned int const intQuotient = colormap.size / pamP->width; -Index: netpbm-11.2.0/urt/rle_addhist.c +Index: netpbm-11.5.2/urt/rle_addhist.c =================================================================== ---- netpbm-11.2.0.orig/urt/rle_addhist.c -+++ netpbm-11.2.0/urt/rle_addhist.c +--- netpbm-11.5.2.orig/urt/rle_addhist.c ++++ netpbm-11.5.2/urt/rle_addhist.c @@ -14,6 +14,8 @@ * If you modify this software, you should include a notice giving the * name of the person performing the modification, the date of modification, @@ -1244,45 +942,33 @@ Index: netpbm-11.2.0/urt/rle_addhist.c */ /* * rle_addhist.c - Add to the HISTORY comment in header -@@ -70,13 +72,19 @@ rle_addhist(char * argv[], - return; +@@ -58,14 +60,21 @@ newCommentLen(const char * const histoi + } - length = 0; -- for (i = 0; argv[i]; ++i) -+ for (i = 0; argv[i]; ++i) { -+ overflow_add(length, strlen(argv[i])); -+ overflow_add(length+1, strlen(argv[i])); - length += strlen(argv[i]) +1; /* length of each arg plus space. */ -+ } - - time(&temp); - timedate = ctime(&temp); - length += strlen(timedate); /* length of date and time in ASCII. */ + /* Add length of date and time in ASCII. */ ++ overflow_add(length, strlen(timedate)); + length += strlen(timedate); + /* Add length of padding, "on ", and length of history name plus "="*/ + overflow_add(strlen(padding), 4); + overflow_add(strlen(histoire), strlen(padding) + 4); + overflow_add(length, strlen(histoire) + strlen(padding) + 4); length += strlen(padding) + 3 + strlen(histoire) + 1; - /* length of padding, "on " and length of history name plus "="*/ - if (in_hdr) /* if we are interested in the old comments... */ -@@ -84,9 +92,12 @@ rle_addhist(char * argv[], - else - old = NULL; - if (old && *old) + if (old && *old) { -+ overflow_add(length, strlen(old)); ++ overflow_add(length, strlen(old)); length += strlen(old); /* add length if there. */ + } + overflow_add(length, 1); - ++length; /*Cater for the null. */ + ++length; /* Add size of terminating NUL. */ - MALLOCARRAY(newc, length); -Index: netpbm-11.2.0/urt/rle_getrow.c + return length; +Index: netpbm-11.5.2/urt/rle_getrow.c =================================================================== ---- netpbm-11.2.0.orig/urt/rle_getrow.c -+++ netpbm-11.2.0/urt/rle_getrow.c +--- netpbm-11.5.2.orig/urt/rle_getrow.c ++++ netpbm-11.5.2/urt/rle_getrow.c @@ -17,6 +17,8 @@ * * Modified at BRL 16-May-88 by Mike Muuss to avoid Alliant STDC desire @@ -1292,18 +978,18 @@ Index: netpbm-11.2.0/urt/rle_getrow.c */ /* * rle_getrow.c - Read an RLE file in. -@@ -164,6 +166,7 @@ rle_get_setup(rle_hdr * const the_hdr) { - char * cp; +@@ -73,6 +75,7 @@ readComments(rle_hdr * const hdrP) { + char * commentHeap; + unsigned int i; - VAXSHORT(comlen, infile); /* get comment length */ + overflow_add(comlen, 1); - evenlen = (comlen + 1) & ~1; /* make it even */ - if (evenlen) { - MALLOCARRAY(comment_buf, evenlen); -Index: netpbm-11.2.0/urt/rle_hdr.c + MALLOCARRAY(commentHeap, evenlen); + + if (commentHeap == NULL) { +Index: netpbm-11.5.2/urt/rle_hdr.c =================================================================== ---- netpbm-11.2.0.orig/urt/rle_hdr.c -+++ netpbm-11.2.0/urt/rle_hdr.c +--- netpbm-11.5.2.orig/urt/rle_hdr.c ++++ netpbm-11.5.2/urt/rle_hdr.c @@ -14,6 +14,8 @@ * If you modify this software, you should include a notice giving the * name of the person performing the modification, the date of modification, @@ -1339,10 +1025,10 @@ Index: netpbm-11.2.0/urt/rle_hdr.c size *= sizeof(char *); toHdrP->comments = malloc(size); if (!toHdrP->comments) -Index: netpbm-11.2.0/urt/rle.h +Index: netpbm-11.5.2/urt/rle.h =================================================================== ---- netpbm-11.2.0.orig/urt/rle.h -+++ netpbm-11.2.0/urt/rle.h +--- netpbm-11.5.2.orig/urt/rle.h ++++ netpbm-11.5.2/urt/rle.h @@ -14,6 +14,9 @@ * If you modify this software, you should include a notice giving the * name of the person performing the modification, the date of modification, @@ -1371,10 +1057,10 @@ Index: netpbm-11.2.0/urt/rle.h /* Declare RLE library routines. */ -Index: netpbm-11.2.0/urt/rle_open_f.c +Index: netpbm-11.5.2/urt/rle_open_f.c =================================================================== ---- netpbm-11.2.0.orig/urt/rle_open_f.c -+++ netpbm-11.2.0/urt/rle_open_f.c +--- netpbm-11.5.2.orig/urt/rle_open_f.c ++++ netpbm-11.5.2/urt/rle_open_f.c @@ -163,65 +163,7 @@ dealWithSubprocess(const char * const f FILE ** const fpP, bool * const noSubprocessP, @@ -1441,10 +1127,10 @@ Index: netpbm-11.2.0/urt/rle_open_f.c } -Index: netpbm-11.2.0/urt/rle_putcom.c +Index: netpbm-11.5.2/urt/rle_putcom.c =================================================================== ---- netpbm-11.2.0.orig/urt/rle_putcom.c -+++ netpbm-11.2.0/urt/rle_putcom.c +--- netpbm-11.5.2.orig/urt/rle_putcom.c ++++ netpbm-11.5.2/urt/rle_putcom.c @@ -14,6 +14,8 @@ * If you modify this software, you should include a notice giving the * name of the person performing the modification, the date of modification, @@ -1454,26 +1140,10 @@ Index: netpbm-11.2.0/urt/rle_putcom.c */ /* * rle_putcom.c - Add a picture comment to the header struct. -@@ -98,12 +100,14 @@ rle_putcom(const char * const value, - const char * v; - const char ** old_comments; - int i; -- for (i = 2, cp = the_hdr->comments; *cp != NULL; ++i, ++cp) -+ for (i = 2, cp = the_hdr->comments; *cp != NULL; ++i, ++cp) { -+ overflow_add(i, 1); - if (match(value, *cp) != NULL) { - v = *cp; - *cp = value; - return v; - } -+ } - /* Not found */ - /* Can't realloc because somebody else might be pointing to this - * comments block. Of course, if this were true, then the -Index: netpbm-11.2.0/urt/Runput.c +Index: netpbm-11.5.2/urt/Runput.c =================================================================== ---- netpbm-11.2.0.orig/urt/Runput.c -+++ netpbm-11.2.0/urt/Runput.c +--- netpbm-11.5.2.orig/urt/Runput.c ++++ netpbm-11.5.2/urt/Runput.c @@ -17,6 +17,8 @@ * * Modified at BRL 16-May-88 by Mike Muuss to avoid Alliant STDC desire @@ -1483,35 +1153,29 @@ Index: netpbm-11.2.0/urt/Runput.c */ /* * Runput.c - General purpose Run Length Encoding. -@@ -202,9 +204,12 @@ RunSetup(rle_hdr * the_hdr) - if ( the_hdr->background != 0 ) - { - int i; -- rle_pixel *background = -- (rle_pixel *)malloc( (unsigned)(the_hdr->ncolors + 1) ); -+ register rle_pixel *background; - int *bg_color; -+ -+ overflow_add(the_hdr->ncolors,1); -+ background = (rle_pixel *)malloc( (unsigned)(the_hdr->ncolors + 1) ); -+ - /* - * If even number of bg color bytes, put out one more to get to - * 16 bit boundary. -@@ -224,7 +229,7 @@ RunSetup(rle_hdr * the_hdr) - /* Big-endian machines are harder */ - int i, nmap = (1 << the_hdr->cmaplen) * - the_hdr->ncmap; -- char *h_cmap = (char *)malloc( nmap * 2 ); -+ char *h_cmap = (char *)malloc2( nmap, 2 ); - if ( h_cmap == NULL ) - { - fprintf( stderr, -Index: netpbm-11.2.0/lib/libpam.c +@@ -235,7 +237,7 @@ RunSetup(rle_hdr * const hdrP) { + rle_pixel * background; + int * bg_color; + +- assert(hdrP->ncolors < UINT_MAX); ++ overflow_add(hdrP->ncolors,1); + + MALLOCARRAY_NOFAIL(background, hdrP->ncolors + 1); + +@@ -262,7 +264,7 @@ RunSetup(rle_hdr * const hdrP) { + unsigned char * h_cmap; + unsigned int i; + +- MALLOCARRAY(h_cmap, nmap * 2); ++ h_cmap = (char *)malloc2( nmap, 2 ); + + if (!h_cmap) { + pm_error("Failed to allocate memory for color map of size %u, " +Index: netpbm-11.5.2/lib/libpam.c =================================================================== ---- netpbm-11.2.0.orig/lib/libpam.c -+++ netpbm-11.2.0/lib/libpam.c -@@ -248,7 +248,8 @@ allocPamRow(const struct pam * const pam +--- netpbm-11.5.2.orig/lib/libpam.c ++++ netpbm-11.5.2/lib/libpam.c +@@ -258,7 +258,8 @@ allocPamRow(const struct pam * const pam unsigned int const bytesPerTuple = allocationDepth(pamP) * sizeof(sample); tuple * tuplerow; diff --git a/netpbm.changes b/netpbm.changes index 04bf702..0bc3edf 100644 --- a/netpbm.changes +++ b/netpbm.changes @@ -1,3 +1,99 @@ +------------------------------------------------------------------- +Wed Jan 31 14:59:08 UTC 2024 - pgajdos@suse.com + +- version update to 11.5.2 + Release 11.05.02 + + ppmtowinicon: fix array overrun with 4 and 8 bits per pixel. + Release 11.05.01 + Fix typo in ppmforge test case. + Release 11.05.00 + + pnmpad: Add -color, -promote, -extend-edge, -detect-background . + + pnmconvol: Restore ability of convolution matrix to be a + pseudo-plain-PNM with samples that exceed the maxval. Lost in + 10.30 (October 2005) because maxval-checking code was added to + libnetpbm. (Was fixed in 10.47.08 in November 2010, but only in + the 10.47 series). + + pnmindex: Improve failure mode when -size or -across is zero. + + pnmindex: Make -plain work. + + pnmpad: fix behavior with -left, -right, and -width together or + -top, -bottom, -height together: ignores -width where it should + fail. Broken in Netpbm 10.72 (September 2015). + + pamtosvg: fix "zero determinant" failure. Introduced in + Netpbm 11.04 (September 2023). + + pjtoppm: fix crash based on uninitialized variable. + Introduced in Netpbm 11.04 (September 2023). + + ppmtopcxl: fix incorrect output with > 256 colors. Always + broken. (Program was added in primordial Netpbm in 1990). + + pbmtext: fix buffer overrun with insanely large input. + + picttoppm: fix buffer overrun with insanely wide input. + + ppmtoxpm: fix incorrect output with insanely large number of + colors. + + pnmscalefixed: fix incorrect output with really big image and + -pixels option. + + ppmdither: fix buffer overrun with insanely large dithering + matrix. + + pnmpad: no longer accept old-style options (e.g. -t50). + + libnetpbm: Add pm_feed_from_file, pm_accept_to_files, + pm_accept_to_filestream Standard Input feeder, Output accepter + for pm_system. + + libnetpbm, programs that use color maps: fix buffer overrun + with insanely deep images. + + merge build: Fix 'pnmcat'. Introduced in Netpbm 11.00 + (September 2023). + Release 11.04.00 + + pamaddnoise: add -salt. + + pamaddnoise: reject options that aren't meaningful for the type + of noise specified rather than just ignore them. + + ppmtosixel: Add -7bit, so it works on more terminals, including + xterms. Thanks Scott Pakin. + + g3topbm: Add -correctlong + + pnmtojpeg: minor improvement to error messages about bad files. + + pammixmulti: Remove disclaimer of patent license. + + pamstack: Fix bug: acts like -firstmaxval specified when it + wasn't. Introduced in Netpbm 11.03 (June 2023). + + pamstack: Fix -lcmmaxval: chooses wrong maxval. Always + broken (-lcmmaxval was new in Netpbm 11.03 (June 2023)). + + pamstack: Fail gracefully when total number of planes is too + large for unsigned integer. Always broken (Pamstack was new in + Netpbm 10.0 (June 2002). + + pamtosvg: fix hang. + + ppmfade: fix "file not found" crash for most fade modes. + Introduced in Netpbm 10.98 (March 2022). + + ppmfade: fix incorrect block mode fade. Always broken + (ppmfade was new in Netpbm 8.4 (April 2000)). + + pamaddnoise: fix very incorrect noise added for all types. + Introduced in Netpbm 10.94 (March 2021). + + ppmrough: fix buffer overrun. Always broken (Ppmrough was new + in Netpbm 10.9 (September 2002). + ppmrough: fix excessive roughness. Introduced in Netpbm 10.94 + (March 2021). + + pgmtexture: Fix buffer overflow with maxval > 255. Always + broken. Maxvals > 255 were possible starting in Netpbm 9.0 + (April 2000). + + pgmtexture: Fix bug: ignores -d. Introduced in Netpbm 10.56 + (September 2011). + + xwdtopnm Fix spurious output with really wide/deep rows. + + imgtoppm: Fix spurious output with really wide/deep rows. + + pbmtopgm: Fix error message for excessive -width. + + pbmtoxbm: Fix spurious output with really wide rows. + + tifftopnm: Fix incorrect output with insanely wide/deep rows. + + thinkjettopbm: Fix incorrect output with insanely wide rows. + + ybmtopbm: Fix incorrect output with insanely wide rows. + + pjtoppm: Fix incorrect output with insanely large number of rows. + + library: add check of maxval for computable size. + + Build: Include LDFLAGS in link of shared library. + * Release 11.03.00 + + pamstack: Add -firstmaxval, -lcmmaxval + + pnmcolormap: make result independent of how system's qsort + orders records with equal keys. Affects pnmquant. + + pamtopng: fix typo in error message about -chroma option. + + pamtopng, pnmtopng, pngtopam: fix error message when something + fails in libpng. Always broken (the programs were new in Netpbm + 8.1 (March 2000)). +- modified patches + % netpbm-gcc-warnings.patch (refreshed) + % netpbm-security-code.patch (refreshed) + ------------------------------------------------------------------- Fri Jun 23 09:11:02 UTC 2023 - pgajdos@suse.com diff --git a/netpbm.spec b/netpbm.spec index 84b46ba..6f4bb46 100644 --- a/netpbm.spec +++ b/netpbm.spec @@ -1,7 +1,7 @@ # # spec file for package netpbm # -# Copyright (c) 2023 SUSE LLC +# Copyright (c) 2024 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -20,10 +20,10 @@ %define asan_build 0 %define ubsan_build 0 %define libmaj 11 -%define libmin 102 +%define libmin 105 %define libver %{libmaj}.%{libmin} Name: netpbm -Version: 11.2.0 +Version: 11.5.2 Release: 0 Summary: A Graphics Conversion Package License: BSD-3-Clause AND GPL-2.0-or-later AND IJG AND MIT AND SUSE-Public-Domain