diff --git a/.gitignore b/.gitignore
index 8c6b1cc..f4510f8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -26,3 +26,7 @@
/netpbm-11.00.00.tar.xz
/netpbm-11.01.00.tar.xz
/netpbm-11.02.00.tar.xz
+/netpbm-11.09.00.tar.xz
+/netpbm-11.10.00.tar.xz
+/netpbm-11.12.00.tar.xz
+/netpbm-11.13.00.tar.xz
diff --git a/fix.patch b/fix.patch
new file mode 100644
index 0000000..b3c3cb9
--- /dev/null
+++ b/fix.patch
@@ -0,0 +1,1336 @@
+diff --git a/analyzer/pgmtexture.c b/analyzer/pgmtexture.c
+index c69643e..2e09dde 100644
+--- a/analyzer/pgmtexture.c
++++ b/analyzer/pgmtexture.c
+@@ -54,6 +54,7 @@ vector(unsigned int const nl,
+
+ assert(nh >= nl);
+
++ overflow_add(nh - nl, 1);
+ MALLOCARRAY(v, (unsigned) (nh - nl + 1));
+
+ if (v == NULL)
+@@ -85,6 +86,7 @@ matrix (unsigned int const nrl,
+ assert(nrh >= nrl);
+
+ /* allocate pointers to rows */
++ overflow_add(nrh - nrl, 1);
+ MALLOCARRAY(m, (unsigned) (nrh - nrl + 1));
+ if (m == NULL)
+ pm_error("Unable to allocate memory for a matrix.");
+@@ -93,6 +95,7 @@ matrix (unsigned int const nrl,
+
+ assert (nch >= ncl);
+
++ 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));
+diff --git a/converter/other/gemtopnm.c b/converter/other/gemtopnm.c
+index 6bbfcc0..24199cb 100644
+--- a/converter/other/gemtopnm.c
++++ b/converter/other/gemtopnm.c
+@@ -106,6 +106,7 @@ main(argc, argv)
+
+ pnm_writepnminit( stdout, cols, rows, MAXVAL, type, 0 );
+
++ overflow_add(cols, padright);
+ {
+ /* allocate input row data structure */
+ int plane;
+diff --git a/converter/other/jpegtopnm.c b/converter/other/jpegtopnm.c
+index 98552c0..311298c 100644
+--- a/converter/other/jpegtopnm.c
++++ b/converter/other/jpegtopnm.c
+@@ -862,6 +862,8 @@ convertImage(FILE * const ofP,
+ /* Calculate output image dimensions so we can allocate space */
+ jpeg_calc_output_dimensions(cinfoP);
+
++ overflow2(cinfoP->output_width, cinfoP->output_components);
++
+ /* Start decompressor */
+ jpeg_start_decompress(cinfoP);
+
+diff --git a/converter/other/pbmtopgm.c b/converter/other/pbmtopgm.c
+index 817fb5b..8baaa57 100644
+--- a/converter/other/pbmtopgm.c
++++ b/converter/other/pbmtopgm.c
+@@ -60,6 +60,7 @@ main(int argc, char *argv[]) {
+
+
+ outrow = pgm_allocrow(cols) ;
++ overflow2(width, height);
+ maxval = MIN(PGM_OVERALLMAXVAL, width*height);
+ pgm_writepgminit(stdout, cols, rows, maxval, 0) ;
+
+diff --git a/converter/other/pnmtoddif.c b/converter/other/pnmtoddif.c
+index b7b942b..52be0e4 100644
+--- a/converter/other/pnmtoddif.c
++++ b/converter/other/pnmtoddif.c
+@@ -629,6 +629,7 @@ main(int argc, char *argv[]) {
+ switch (PNM_FORMAT_TYPE(format)) {
+ case PBM_TYPE:
+ ip.bits_per_pixel = 1;
++ overflow_add(cols, 7);
+ ip.bytes_per_line = (cols + 7) / 8;
+ ip.spectral = 2;
+ ip.components = 1;
+@@ -644,6 +645,7 @@ main(int argc, char *argv[]) {
+ ip.polarity = 2;
+ break;
+ case PPM_TYPE:
++ overflow2(cols, 3);
+ ip.bytes_per_line = 3 * cols;
+ ip.bits_per_pixel = 24;
+ ip.spectral = 5;
+diff --git a/converter/other/pnmtojpeg.c b/converter/other/pnmtojpeg.c
+index e345831..39038f8 100644
+--- a/converter/other/pnmtojpeg.c
++++ b/converter/other/pnmtojpeg.c
+@@ -605,8 +605,10 @@ read_scan_script(j_compress_ptr const cinfo,
+ data, but if you want to compress multiple images you'd
+ want JPOOL_PERMANENT.
+ */
++ overflow2(nscans, sizeof(jpeg_scan_info));
+ const unsigned int scan_info_size = nscans * sizeof(jpeg_scan_info);
+- jpeg_scan_info * const scan_info =
++ const jpeg_scan_info * scan_info;
++ scan_info =
+ (jpeg_scan_info *)
+ (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
+ scan_info_size);
+@@ -938,6 +940,8 @@ compute_rescaling_array(JSAMPLE ** const rescale_p, const pixval maxval,
+ const long half_maxval = maxval / 2;
+ 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 +1020,7 @@ convert_scanlines(struct jpeg_compress_struct * const cinfo_p,
+ */
+
+ /* 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,
+diff --git a/converter/other/pnmtops.c b/converter/other/pnmtops.c
+index 45d856d..5b04eeb 100644
+--- a/converter/other/pnmtops.c
++++ b/converter/other/pnmtops.c
+@@ -294,17 +294,21 @@ parseCommandLine(int argc, const char ** argv,
+ validateCompDimension(width, 72, "-width value");
+ validateCompDimension(height, 72, "-height value");
+
++ overflow2(width, 72);
+ cmdlineP->width = width * 72;
++ overflow2(height, 72);
+ cmdlineP->height = height * 72;
+
+ if (imagewidthSpec) {
+ validateCompDimension(imagewidth, 72, "-imagewidth value");
++ overflow2(imagewidth, 72);
+ cmdlineP->imagewidth = imagewidth * 72;
+ }
+ else
+ cmdlineP->imagewidth = 0;
+ if (imageheightSpec) {
+- validateCompDimension(imagewidth, 72, "-imageheight value");
++ validateCompDimension(imageheight, 72, "-imageheight value");
++ overflow2(imageheight, 72);
+ cmdlineP->imageheight = imageheight * 72;
+ }
+ else
+diff --git a/converter/other/rletopnm.c b/converter/other/rletopnm.c
+index 97f271d..72b63d3 100644
+--- a/converter/other/rletopnm.c
++++ b/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,
+ * and the reason for such modification.
++ *
++ * 2002-12-19: Fix maths wrapping bugs. Alan Cox
+ */
+ /*
+ * rletopnm - A conversion program to convert from Utah's "rle" image format
+diff --git a/converter/other/sirtopnm.c b/converter/other/sirtopnm.c
+index fafcc91..9fe49d0 100644
+--- a/converter/other/sirtopnm.c
++++ b/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 ) ) )
+diff --git a/converter/other/tifftopnm.c b/converter/other/tifftopnm.c
+index 05493e7..7ea59fd 100644
+--- a/converter/other/tifftopnm.c
++++ b/converter/other/tifftopnm.c
+@@ -1372,6 +1372,7 @@ convertRasterByRows(pnmOut * const pnmOutP,
+ if (scanbuf == NULL)
+ pm_error("can't allocate memory for scanline buffer");
+
++ overflow2(cols,spp);
+ MALLOCARRAY(samplebuf, cols * spp);
+ if (samplebuf == NULL)
+ pm_error("can't allocate memory for row buffer");
+diff --git a/converter/other/xwdtopnm.c b/converter/other/xwdtopnm.c
+index a74da34..4d26a31 100644
+--- a/converter/other/xwdtopnm.c
++++ b/converter/other/xwdtopnm.c
+@@ -210,6 +210,10 @@ processX10Header(X10WDFileHeader * const h10P,
+ *colorsP = pnm_allocrow(2);
+ PNM_ASSIGN1((*colorsP)[0], 0);
+ PNM_ASSIGN1((*colorsP)[1], *maxvalP);
++ overflow_add(h10P->pixmap_width, 15);
++ if(h10P->pixmap_width < 0)
++ pm_error("assert: negative width");
++ 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;
+@@ -635,6 +639,7 @@ processX11Header(X11WDFileHeader * const h11P,
+
+ *colsP = h11FixedP->pixmap_width;
+ *rowsP = h11FixedP->pixmap_height;
++ overflow2(h11FixedP->bytes_per_line, 8);
+ *padrightP =
+ h11FixedP->bytes_per_line * 8 -
+ h11FixedP->pixmap_width * h11FixedP->bits_per_pixel;
+diff --git a/converter/pbm/mdatopbm.c b/converter/pbm/mdatopbm.c
+index 461b3f8..c8bab6c 100644
+--- a/converter/pbm/mdatopbm.c
++++ b/converter/pbm/mdatopbm.c
+@@ -245,10 +245,13 @@ main(int argc, char **argv) {
+ pm_readlittleshort(infile, &yy); nInCols = yy;
+ }
+
++ overflow2(nOutCols, 8);
+ nOutCols = 8 * nInCols;
+ nOutRows = nInRows;
+- if (bScale)
++ if (bScale) {
++ overflow2(nOutRows, 2);
+ nOutRows *= 2;
++ }
+
+ data = pbm_allocarray(nOutCols, nOutRows);
+
+diff --git a/converter/pbm/mgrtopbm.c b/converter/pbm/mgrtopbm.c
+index 9f7004a..f2c1590 100644
+--- a/converter/pbm/mgrtopbm.c
++++ b/converter/pbm/mgrtopbm.c
+@@ -67,6 +67,7 @@ readMgrHeader(FILE * const ifP,
+
+ *colsP = (((int)head.h_wide - ' ') << 6) + ((int)head.l_wide - ' ');
+ *rowsP = (((int)head.h_high - ' ') << 6) + ((int) head.l_high - ' ');
++ overflow_add(*colsP, pad);
+ *padrightP = ( ( *colsP + pad - 1 ) / pad ) * pad - *colsP;
+ }
+
+diff --git a/converter/pbm/pbmto4425.c b/converter/pbm/pbmto4425.c
+index 1d97ac6..c4c8cbb 100644
+--- a/converter/pbm/pbmto4425.c
++++ b/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" );
+diff --git a/converter/pbm/pbmtogem.c b/converter/pbm/pbmtogem.c
+index 4fd30e9..c82757d 100644
+--- a/converter/pbm/pbmtogem.c
++++ b/converter/pbm/pbmtogem.c
+@@ -79,6 +79,7 @@ putinit (int const rows, int const cols)
+ bitsperitem = 0;
+ bitshift = 7;
+ outcol = 0;
++ overflow_add(cols, 7);
+ outmax = (cols + 7) / 8;
+ outrow = (unsigned char *) pm_allocrow (outmax, sizeof (unsigned char));
+ lastrow = (unsigned char *) pm_allocrow (outmax, sizeof (unsigned char));
+diff --git a/converter/pbm/pbmtogo.c b/converter/pbm/pbmtogo.c
+index 4f84f39..943dc84 100644
+--- a/converter/pbm/pbmtogo.c
++++ b/converter/pbm/pbmtogo.c
+@@ -158,6 +158,7 @@ main(int argc,
+ bitrow = pbm_allocrow(cols);
+
+ /* Round cols up to the nearest multiple of 8. */
++ overflow_add(cols, 7);
+ rucols = ( cols + 7 ) / 8;
+ bytesperrow = rucols; /* GraphOn uses bytes */
+ rucols = rucols * 8;
+diff --git a/converter/pbm/pbmtolj.c b/converter/pbm/pbmtolj.c
+index 3cd7670..0b51932 100644
+--- a/converter/pbm/pbmtolj.c
++++ b/converter/pbm/pbmtolj.c
+@@ -120,7 +120,11 @@ parseCommandLine(int argc, char ** argv,
+ static void
+ allocateBuffers(unsigned int const cols) {
+
++ overflow_add(cols, 8);
+ rowBufferSize = (cols + 7) / 8;
++ overflow_add(rowBufferSize, 128);
++ overflow_add(rowBufferSize, rowBufferSize+128);
++ overflow_add(rowBufferSize+10, rowBufferSize/8);
+ packBufferSize = rowBufferSize + (rowBufferSize + 127) / 128 + 1;
+ deltaBufferSize = rowBufferSize + rowBufferSize / 8 + 10;
+
+diff --git a/converter/pbm/pbmtomda.c b/converter/pbm/pbmtomda.c
+index 3ad5149..9efe5cf 100644
+--- a/converter/pbm/pbmtomda.c
++++ b/converter/pbm/pbmtomda.c
+@@ -179,6 +179,7 @@ int main(int argc, char **argv)
+
+ nOutRowsUnrounded = bScale ? nInRows/2 : nInRows;
+
++ overflow_add(nOutRowsUnrounded, 3);
+ nOutRows = ((nOutRowsUnrounded + 3) / 4) * 4;
+ /* MDA wants rows a multiple of 4 */
+ nOutCols = nInCols / 8;
+diff --git a/converter/pbm/pbmtoppa/pbm.c b/converter/pbm/pbmtoppa/pbm.c
+index ae36e0d..b8c89c9 100644
+--- a/converter/pbm/pbmtoppa/pbm.c
++++ b/converter/pbm/pbmtoppa/pbm.c
+@@ -154,6 +154,7 @@ pbm_readline(pbm_stat * const pbmStatP,
+ break;
+ case P4: {
+ int tmp, tmp2;
++ overflow_add(pbmStatP->width, 7);
+ 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,
+
+ if (!pbmStatP->unread) {
+ pbmStatP->unread = 1;
++ overflow_add(pbmStatP->width, 7);
+ pbmStatP->revdata = malloc ((pbmStatP->width+7)/8);
+ memcpy(pbmStatP->revdata, data, (pbmStatP->width+7)/8);
+ --pbmStatP->current_line;
+diff --git a/converter/pbm/pbmtoppa/pbmtoppa.c b/converter/pbm/pbmtoppa/pbmtoppa.c
+index ff4a599..aa510ec 100644
+--- a/converter/pbm/pbmtoppa/pbmtoppa.c
++++ b/converter/pbm/pbmtoppa/pbmtoppa.c
+@@ -453,6 +453,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;
+
+diff --git a/converter/pbm/pbmtoxbm.c b/converter/pbm/pbmtoxbm.c
+index ecb72b3..600461f 100644
+--- a/converter/pbm/pbmtoxbm.c
++++ b/converter/pbm/pbmtoxbm.c
+@@ -352,6 +352,7 @@ convertRaster(FILE * const ifP,
+
+ unsigned char * bitrow;
+ unsigned int row;
++ overflow_add(cols, padright);
+
+ putinit(xbmVersion);
+
+diff --git a/converter/pbm/pktopbm.c b/converter/pbm/pktopbm.c
+index 712f339..b6fcb02 100644
+--- a/converter/pbm/pktopbm.c
++++ b/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]) {
+diff --git a/converter/pbm/thinkjettopbm.l b/converter/pbm/thinkjettopbm.l
+index 5de4f2b..cc1810c 100644
+--- a/converter/pbm/thinkjettopbm.l
++++ b/converter/pbm/thinkjettopbm.l
+@@ -114,7 +114,9 @@ DIG [0-9]
+ \033\*b{DIG}+W {
+ int l;
+ if (rowCount >= rowCapacity) {
++ overflow_add(rowCapacity, 100);
+ rowCapacity += 100;
++ overflow2(rowCapacity, sizeof *rows);
+ rows = realloc (rows, rowCapacity * sizeof *rows);
+ if (rows == NULL)
+ pm_error ("Out of memory.");
+@@ -226,6 +228,7 @@ yywrap (void)
+ /*
+ * Quite simple since ThinkJet bit arrangement matches PBM
+ */
++ overflow2(maxRowLength, 8);
+ pbm_writepbminit(stdout, maxRowLength*8, rowCount, 0);
+
+ packed_bitrow = malloc(maxRowLength);
+diff --git a/converter/pbm/ybmtopbm.c b/converter/pbm/ybmtopbm.c
+index 2a42908..cf1ff03 100644
+--- a/converter/pbm/ybmtopbm.c
++++ b/converter/pbm/ybmtopbm.c
+@@ -43,6 +43,7 @@ getinit(FILE * const ifP,
+ pm_error("EOF / read error");
+
+ *depthP = 1;
++ overflow_add(*colsP, 15);
+ }
+
+
+diff --git a/converter/pgm/lispmtopgm.c b/converter/pgm/lispmtopgm.c
+index 40dd3fb..8dd9cae 100644
+--- a/converter/pgm/lispmtopgm.c
++++ b/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 )
+@@ -103,6 +104,7 @@ getinit( file, colsP, rowsP, depthP, padrightP )
+ if ( *depthP == 0 )
+ *depthP = 1; /* very old file */
+
++ overflow_add((int)colsP, 31);
+ *padrightP = ( ( *colsP + 31 ) / 32 ) * 32 - *colsP;
+
+ if ( *colsP != (cols_32 - *padrightP) ) {
+diff --git a/converter/pgm/psidtopgm.c b/converter/pgm/psidtopgm.c
+index 07417d1..25bb311 100644
+--- a/converter/pgm/psidtopgm.c
++++ b/converter/pgm/psidtopgm.c
+@@ -78,6 +78,7 @@ main(int argc,
+ pm_error("bits/sample (%d) is too large.", bitspersample);
+
+ 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;
+diff --git a/converter/ppm/Makefile b/converter/ppm/Makefile
+index 003ef8d..b97349d 100644
+--- a/converter/ppm/Makefile
++++ b/converter/ppm/Makefile
+@@ -11,7 +11,7 @@ SUBDIRS = hpcdtoppm ppmtompeg
+
+ PORTBINARIES = 411toppm eyuvtoppm gouldtoppm ilbmtoppm imgtoppm \
+ leaftoppm mtvtoppm neotoppm \
+- pcxtoppm pc1toppm pi1toppm picttoppm pjtoppm \
++ pcxtoppm pc1toppm pi1toppm pjtoppm \
+ ppmtoacad ppmtoapplevol ppmtoarbtxt ppmtoascii \
+ ppmtobmp ppmtoeyuv ppmtogif ppmtoicr ppmtoilbm \
+ ppmtoleaf ppmtolj ppmtomitsu ppmtoneo \
+diff --git a/converter/ppm/ilbmtoppm.c b/converter/ppm/ilbmtoppm.c
+index b9b8986..f4fe331 100644
+--- a/converter/ppm/ilbmtoppm.c
++++ b/converter/ppm/ilbmtoppm.c
+@@ -608,6 +608,7 @@ decode_row(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,
+ Multipalette handling
+ ****************************************************************************/
+
++static void *
++xmalloc2(x, y)
++ int x;
++ int y;
++{
++ void *mem;
++
++ overflow2(x,y);
++ if( x * y == 0 )
++ return NULL;
++
++ mem = malloc2(x,y);
++ if( mem == NULL )
++ pm_error("out of memory allocating %d bytes", x * y);
++ return mem;
++}
++
+
+ static void
+ multi_adjust(ColorMap * const cmapP,
+@@ -1363,6 +1381,9 @@ 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 +1823,9 @@ PCHG_ConvertSmall(PCHGHeader * const pchgP,
+ 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 +2090,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 +2169,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 */
+
+diff --git a/converter/ppm/imgtoppm.c b/converter/ppm/imgtoppm.c
+index 7078b88..eb8509e 100644
+--- a/converter/ppm/imgtoppm.c
++++ b/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" );
++ overflow2(cmaplen, 3);
+ if ( cmaplen * 3 != len )
+ {
+ pm_message(
+@@ -105,6 +106,7 @@ main(int argc, char ** argv) {
+ pm_error( "bad pixel data header" );
+ buf[8] = '\0';
+ len = atoi((char*) buf );
++ overflow2(cols, rows);
+ if ( len != cols * rows )
+ pm_message(
+ "pixel data length (%d) does not match image size (%d)",
+diff --git a/converter/ppm/pcxtoppm.c b/converter/ppm/pcxtoppm.c
+index e252ba2..270ae3b 100644
+--- a/converter/ppm/pcxtoppm.c
++++ b/converter/ppm/pcxtoppm.c
+@@ -409,6 +409,7 @@ pcx_planes_to_pixels(pixels, bitplanes, bytesperline, planes, bitsperpixel)
+ /*
+ * 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,
+ }
+
+ /* BytesPerLine should be >= BitsPerPixel * cols / 8 */
++ overflow2(BytesPerLine, 8);
+ rawcols = BytesPerLine * 8 / BitsPerPixel;
+ if (headerCols > rawcols) {
+ pm_message("warning - BytesPerLine = %d, "
+diff --git a/converter/ppm/picttoppm.c b/converter/ppm/picttoppm.c
+index 9cf570e..6020f67 100644
+--- a/converter/ppm/picttoppm.c
++++ b/converter/ppm/picttoppm.c
+@@ -1,3 +1,4 @@
++#error "Unfixable. Don't ship me"
+ /*
+ * picttoppm.c -- convert a MacIntosh PICT file to PPM format.
+ *
+diff --git a/converter/ppm/pjtoppm.c b/converter/ppm/pjtoppm.c
+index ffb01d0..eb11e8d 100644
+--- a/converter/ppm/pjtoppm.c
++++ b/converter/ppm/pjtoppm.c
+@@ -149,12 +149,17 @@ main(int argc, const char ** argv) {
+ case 'V': /* send plane */
+ case 'W': /* send last plane */
+ if (rows == -1 || row >= rows || image == NULL) {
+- if (rows == -1 || row >= rows)
++ if (rows == -1 || row >= rows) {
++ overflow_add(rows, 100);
+ rows += 100;
++ }
++
+ if (image == NULL) {
++ overflow2(rows,planes);
+ MALLOCARRAY(image, uintProduct(rows, planes));
+ MALLOCARRAY(imlen, uintProduct(rows, planes));
+ } else {
++ overflow2(rows,planes);
+ REALLOCARRAY(image, uintProduct(rows, planes));
+ REALLOCARRAY(imlen, uintProduct(rows, planes));
+ }
+@@ -235,8 +240,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]);
+ /*
+@@ -247,6 +254,7 @@ main(int argc, const char ** argv) {
+ image[plane + row * planes] = realloc(buf, i);
+ }
+ }
++ overflow2(cols, 8);
+ cols *= 8;
+ }
+
+diff --git a/converter/ppm/ppmtoeyuv.c b/converter/ppm/ppmtoeyuv.c
+index f5ce115..6f072be 100644
+--- a/converter/ppm/ppmtoeyuv.c
++++ b/converter/ppm/ppmtoeyuv.c
+@@ -114,6 +114,7 @@ create_multiplication_tables(const pixval maxval) {
+
+ int index;
+
++ overflow_add(maxval, 1);
+ MALLOCARRAY_NOFAIL(mult299 , maxval+1);
+ MALLOCARRAY_NOFAIL(mult587 , maxval+1);
+ MALLOCARRAY_NOFAIL(mult114 , maxval+1);
+diff --git a/converter/ppm/ppmtolj.c b/converter/ppm/ppmtolj.c
+index 7ed814e..b4e7db1 100644
+--- a/converter/ppm/ppmtolj.c
++++ b/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 );
+
++ 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)
+diff --git a/converter/ppm/ppmtomitsu.c b/converter/ppm/ppmtomitsu.c
+index 50b790d..63d3182 100644
+--- a/converter/ppm/ppmtomitsu.c
++++ b/converter/ppm/ppmtomitsu.c
+@@ -685,6 +685,8 @@ main(int argc, char * argv[]) {
+ medias = MSize_User;
+
+ if (dpi300) {
++ overflow2(medias.maxcols, 2);
++ overflow2(medias.maxrows, 2);
+ medias.maxcols *= 2;
+ medias.maxrows *= 2;
+ }
+diff --git a/converter/ppm/ppmtopcx.c b/converter/ppm/ppmtopcx.c
+index 76f0629..e7b06ff 100644
+--- a/converter/ppm/ppmtopcx.c
++++ b/converter/ppm/ppmtopcx.c
+@@ -422,6 +422,8 @@ ppmTo16ColorPcx(pixel ** const pixels,
+ else Planes = 1;
+ }
+ }
++ overflow2(BitsPerPixel, cols);
++ overflow_add(BitsPerPixel * cols, 7);
+ BytesPerLine = ((cols * BitsPerPixel) + 7) / 8;
+ MALLOCARRAY_NOFAIL(indexRow, cols);
+ MALLOCARRAY_NOFAIL(planesrow, BytesPerLine);
+diff --git a/converter/ppm/ppmtopict.c b/converter/ppm/ppmtopict.c
+index 36464b6..c91ccf2 100644
+--- a/converter/ppm/ppmtopict.c
++++ b/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;
+diff --git a/converter/ppm/ppmtopj.c b/converter/ppm/ppmtopj.c
+index d116773..49d08fc 100644
+--- a/converter/ppm/ppmtopj.c
++++ b/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));
+
+diff --git a/converter/ppm/ppmtopjxl.c b/converter/ppm/ppmtopjxl.c
+index 90bcef0..72d0027 100644
+--- a/converter/ppm/ppmtopjxl.c
++++ b/converter/ppm/ppmtopjxl.c
+@@ -267,6 +267,9 @@ main(int argc, const char * argv[]) {
+ 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...");
+ chv = ppm_computecolorhist(pixels, cols, rows, MAXCOLORS, &colors);
+@@ -286,6 +289,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 +300,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);
+diff --git a/converter/ppm/ppmtowinicon.c b/converter/ppm/ppmtowinicon.c
+index c673798..f026c08 100644
+--- a/converter/ppm/ppmtowinicon.c
++++ b/converter/ppm/ppmtowinicon.c
+@@ -12,6 +12,7 @@
+
+ #include
+ #include
++#include
+
+ #include "pm_c_util.h"
+ #include "winico.h"
+@@ -214,6 +215,7 @@ createAndBitmap (gray ** const ba, int const cols, int const rows,
+ 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;
+
+ for (y=0;yxBytes = xBytes;
+ icBitmap->data = rowData;
++ overflow2(xBytes, rows);
+ icBitmap->size = xBytes * 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)
+diff --git a/converter/ppm/ppmtoxpm.c b/converter/ppm/ppmtoxpm.c
+index 0e31692..1b3923f 100644
+--- a/converter/ppm/ppmtoxpm.c
++++ b/converter/ppm/ppmtoxpm.c
+@@ -198,6 +198,7 @@ genNumstr(unsigned int const input, int const digits) {
+ 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");
+
+@@ -315,6 +316,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.",
+diff --git a/converter/ppm/qrttoppm.c b/converter/ppm/qrttoppm.c
+index 935463e..653084c 100644
+--- a/converter/ppm/qrttoppm.c
++++ b/converter/ppm/qrttoppm.c
+@@ -46,7 +46,7 @@ main( argc, 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" );
+
+diff --git a/converter/ppm/sldtoppm.c b/converter/ppm/sldtoppm.c
+index 2fef023..ce73025 100644
+--- a/converter/ppm/sldtoppm.c
++++ b/converter/ppm/sldtoppm.c
+@@ -506,6 +506,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,
+diff --git a/converter/ppm/ximtoppm.c b/converter/ppm/ximtoppm.c
+index 9620942..e9083f3 100644
+--- a/converter/ppm/ximtoppm.c
++++ b/converter/ppm/ximtoppm.c
+@@ -118,6 +118,7 @@ ReadXimHeader(FILE * const in_fp,
+ header->bits_channel = atoi(a_head.bits_per_channel);
+ header->alpha_flag = atoi(a_head.alpha_channel);
+ if (strlen(a_head.author)) {
++ overflow_add(strlen(a_head.author),1);
+ if (!(header->author = calloc((unsigned int)strlen(a_head.author)+1,
+ 1))) {
+ pm_message("ReadXimHeader: can't calloc author string" );
+@@ -127,6 +128,7 @@ ReadXimHeader(FILE * const in_fp,
+ strncpy(header->author, a_head.author, strlen(a_head.author));
+ }
+ if (strlen(a_head.date)) {
++ overflow_add(strlen(a_head.date),1);
+ if (!(header->date =calloc((unsigned int)strlen(a_head.date)+1,1))){
+ pm_message("ReadXimHeader: can't calloc date string" );
+ return(0);
+@@ -135,6 +137,7 @@ ReadXimHeader(FILE * const in_fp,
+ strncpy(header->date, a_head.date, strlen(a_head.date));
+ }
+ if (strlen(a_head.program)) {
++ overflow_add(strlen(a_head.program),1);
+ if (!(header->program = calloc(
+ (unsigned int)strlen(a_head.program) + 1, 1))) {
+ pm_message("ReadXimHeader: can't calloc program string" );
+@@ -161,6 +164,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) {
+diff --git a/editor/pamcut.c b/editor/pamcut.c
+index 1fc9d9b..ad0e030 100644
+--- a/editor/pamcut.c
++++ b/editor/pamcut.c
+@@ -799,6 +799,8 @@ cutOneImage(FILE * const ifP,
+
+ outpam = inpam; /* Initial value -- most fields should be same */
+ outpam.file = ofP;
++ overflow_add(rightcol, 1);
++ overflow_add(bottomrow, 1);
+ outpam.width = rightcol - leftcol + 1;
+ outpam.height = bottomrow - toprow + 1;
+
+diff --git a/editor/pnmgamma.c b/editor/pnmgamma.c
+index 1fdf20e..98b7e90 100644
+--- a/editor/pnmgamma.c
++++ b/editor/pnmgamma.c
+@@ -596,6 +596,7 @@ createGammaTables(enum transferFunction const transferFunction,
+ xelval ** const btableP) {
+
+ /* Allocate space for the tables. */
++ overflow_add(maxval, 1);
+ MALLOCARRAY(*rtableP, maxval+1);
+ MALLOCARRAY(*gtableP, maxval+1);
+ MALLOCARRAY(*btableP, maxval+1);
+diff --git a/editor/pnmhisteq.c b/editor/pnmhisteq.c
+index a339f73..c2c85a3 100644
+--- a/editor/pnmhisteq.c
++++ b/editor/pnmhisteq.c
+@@ -107,6 +107,7 @@ computeLuminosityHistogram(xel * const * const xels,
+ unsigned int pixelCount;
+ unsigned int * lumahist;
+
++ overflow_add(maxval, 1);
+ MALLOCARRAY(lumahist, maxval + 1);
+ if (lumahist == NULL)
+ pm_error("Out of storage allocating array for %u histogram elements",
+diff --git a/editor/pnmindex.csh b/editor/pnmindex.csh
+index c6f1e84..c513a84 100755
+--- a/editor/pnmindex.csh
++++ b/editor/pnmindex.csh
+@@ -1,5 +1,7 @@
+ #!/bin/csh -f
+ #
++echo "Unsafe code, needs debugging, do not ship"
++exit 1
+ # pnmindex - build a visual index of a bunch of anymaps
+ #
+ # Copyright (C) 1991 by Jef Poskanzer.
+diff --git a/editor/pnmpad.c b/editor/pnmpad.c
+index 55cdcd6..10da3af 100644
+--- a/editor/pnmpad.c
++++ b/editor/pnmpad.c
+@@ -654,6 +654,8 @@ main(int argc, const char ** argv) {
+
+ computePadSizes(cmdline, cols, rows, &lpad, &rpad, &tpad, &bpad);
+
++ overflow_add(cols, lpad);
++ overflow_add(cols + lpad, rpad);
+ newcols = cols + lpad + rpad;
+
+ if (cmdline.reportonly)
+diff --git a/editor/pnmremap.c b/editor/pnmremap.c
+index 0c0096b..8b86cb7 100644
+--- a/editor/pnmremap.c
++++ b/editor/pnmremap.c
+@@ -468,6 +468,7 @@ fserr_init(struct pam * const pamP,
+
+ unsigned int const fserrSize = pamP->width + 2;
+
++ overflow_add(pamP->width, 2);
+ fserrP->width = pamP->width;
+
+ MALLOCARRAY(fserrP->thiserr, pamP->depth);
+@@ -506,6 +507,7 @@ floydInitRow(struct pam * const pamP,
+
+ unsigned int col;
+
++ overflow_add(pamP->width, 2);
+ for (col = 0; col < pamP->width + 2; ++col) {
+ unsigned int plane;
+ for (plane = 0; plane < pamP->depth; ++plane)
+diff --git a/editor/pnmscalefixed.c b/editor/pnmscalefixed.c
+index 884ca31..f4d7086 100644
+--- a/editor/pnmscalefixed.c
++++ b/editor/pnmscalefixed.c
+@@ -214,6 +214,7 @@ compute_output_dimensions(const struct cmdline_info cmdline,
+ 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 +266,7 @@ compute_output_dimensions(const struct cmdline_info cmdline,
+
+ if (*newcolsP < 1) *newcolsP = 1;
+ if (*newrowsP < 1) *newrowsP = 1;
++ overflow2(*newcolsP, *newrowsP);
+ }
+
+
+@@ -446,6 +448,8 @@ 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;
+
+diff --git a/editor/ppmdither.c b/editor/ppmdither.c
+index ec1b977..c46a974 100644
+--- a/editor/ppmdither.c
++++ b/editor/ppmdither.c
+@@ -352,6 +352,9 @@ dithMatrix(unsigned int const dithPower) {
+ assert(dithPower < sizeof(unsigned int) * 8);
+
+ {
++ overflow2(dithDim, sizeof(*dithMat));
++ overflow3(dithDim, dithDim, sizeof(**dithMat));
++ overflow_add(dithDim * sizeof(*dithMat), dithDim * dithDim * sizeof(**dithMat));
+ unsigned int const dithMatSize =
+ (dithDim * sizeof(*dithMat)) + /* pointers */
+ (dithDim * dithDim * sizeof(**dithMat)); /* data */
+diff --git a/editor/specialty/pamoil.c b/editor/specialty/pamoil.c
+index 6cb8d3a..6f4bde9 100644
+--- a/editor/specialty/pamoil.c
++++ b/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);
+
++ overflow_add(inpam.maxval, 1);
+ MALLOCARRAY(hist, inpam.maxval + 1);
+ if (hist == NULL)
+ pm_error("Unable to allocate memory for histogram.");
+diff --git a/lib/libpam.c b/lib/libpam.c
+index a8f140b..e6986f1 100644
+--- a/lib/libpam.c
++++ b/lib/libpam.c
+@@ -225,7 +225,8 @@ allocPamRow(const struct pam * const pamP) {
+ unsigned int const bytesPerTuple = allocationDepth(pamP) * sizeof(sample);
+ tuple * tuplerow;
+
+- tuplerow = malloc(pamP->width * (sizeof(tuple *) + bytesPerTuple));
++ overflow_add(sizeof(tuple *), bytesPerTuple);
++ tuplerow = malloc2(pamP->width, (sizeof(tuple *) + bytesPerTuple));
+
+ if (tuplerow != NULL) {
+ /* Now we initialize the pointers to the individual tuples
+diff --git a/lib/libpammap.c b/lib/libpammap.c
+index 569156f..bc24d22 100644
+--- a/lib/libpammap.c
++++ b/lib/libpammap.c
+@@ -108,6 +108,8 @@ allocTupleIntListItem(struct pam * const pamP) {
+ */
+ struct tupleint_list_item * retval;
+
++ 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);
+diff --git a/lib/libpm.c b/lib/libpm.c
+index 47a2f49..a263598 100644
+--- a/lib/libpm.c
++++ b/lib/libpm.c
+@@ -888,5 +888,53 @@ pm_parse_height(const char * const arg) {
+ return height;
+ }
+
++/*
++ * Maths wrapping
++ */
+
++void __overflow2(int a, int b)
++{
++ if(a < 0 || b < 0)
++ pm_error("object too large");
++ if(b == 0)
++ return;
++ if(a > INT_MAX / b)
++ pm_error("object too large");
++}
++
++void overflow3(int a, int b, int c)
++{
++ overflow2(a,b);
++ overflow2(a*b, c);
++}
++
++void overflow_add(int a, int b)
++{
++ if( a > INT_MAX - b)
++ pm_error("object too large");
++}
++
++void *malloc2(int a, int b)
++{
++ overflow2(a, b);
++ if(a*b == 0)
++ pm_error("Zero byte allocation");
++ return malloc(a*b);
++}
++
++void *malloc3(int a, int b, int c)
++{
++ overflow3(a, b, c);
++ if(a*b*c == 0)
++ pm_error("Zero byte allocation");
++ return malloc(a*b*c);
++}
++
++void *realloc2(void * a, int b, int c)
++{
++ overflow2(b, c);
++ if(b*c == 0)
++ pm_error("Zero byte allocation");
++ return realloc(a, b*c);
++}
+
+diff --git a/lib/pm.h b/lib/pm.h
+index 3fc92fb..17a25f1 100644
+--- a/lib/pm.h
++++ b/lib/pm.h
+@@ -441,5 +441,12 @@ pm_parse_height(const char * const arg);
+ }
+ #endif
+
++#define overflow2(a,b) __overflow2(a,b)
++void __overflow2(int, int);
++void overflow3(int, int, int);
++void overflow_add(int, int);
++void *malloc2(int, int);
++void *malloc3(int, int, int);
++void *realloc2(void *, int, int);
+
+ #endif
+diff --git a/other/pnmcolormap.c b/other/pnmcolormap.c
+index 7da3122..dafa390 100644
+--- a/other/pnmcolormap.c
++++ b/other/pnmcolormap.c
+@@ -1002,6 +1002,7 @@ colormapToSquare(struct pam * const pamP,
+ pamP->width = intsqrt;
+ else
+ pamP->width = intsqrt + 1;
++ overflow_add(intsqrt, 1);
+ }
+ {
+ unsigned int const intQuotient = colormap.size / pamP->width;
+diff --git a/urt/Runput.c b/urt/Runput.c
+index 3bc562a..cb6e7c5 100644
+--- a/urt/Runput.c
++++ b/urt/Runput.c
+@@ -202,9 +202,11 @@ RunSetup(rle_hdr * the_hdr)
+ if ( the_hdr->background != 0 )
+ {
+ register int i;
+- register rle_pixel *background =
+- (rle_pixel *)malloc( (unsigned)(the_hdr->ncolors + 1) );
++ register rle_pixel *background;
+ register 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 +226,7 @@ RunSetup(rle_hdr * the_hdr)
+ /* Big-endian machines are harder */
+ register int i, nmap = (1 << the_hdr->cmaplen) *
+ the_hdr->ncmap;
+- register char *h_cmap = (char *)malloc( nmap * 2 );
++ register char *h_cmap = (char *)malloc2( nmap, 2 );
+ if ( h_cmap == NULL )
+ {
+ fprintf( stderr,
+diff --git a/urt/rle.h b/urt/rle.h
+index 0071774..6a905ba 100644
+--- a/urt/rle.h
++++ b/urt/rle.h
+@@ -152,6 +152,17 @@ rle_hdr /* End of typedef. */
+ */
+ extern rle_hdr rle_dflt_hdr;
+
++/*
++ * Provided by pm library
++ */
++
++extern void overflow_add(int, int);
++#define overflow2(a,b) __overflow2(a,b)
++extern void __overflow2(int, int);
++extern void overflow3(int, int, int);
++extern void *malloc2(int, int);
++extern void *malloc3(int, int, int);
++extern void *realloc2(void *, int, int);
+
+ /* Declare RLE library routines. */
+
+diff --git a/urt/rle_addhist.c b/urt/rle_addhist.c
+index b165175..e09ed94 100644
+--- a/urt/rle_addhist.c
++++ b/urt/rle_addhist.c
+@@ -70,13 +70,18 @@ rle_addhist(char * argv[],
+ return;
+
+ 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. */
+-
++ 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,8 +89,10 @@ rle_addhist(char * argv[],
+ else
+ old = NULL;
+
+- if (old && *old)
++ if (old && *old) {
++ overflow_add(length, strlen(old));
+ length += strlen(old); /* add length if there. */
++ }
+
+ ++length; /*Cater for the null. */
+
+diff --git a/urt/rle_getrow.c b/urt/rle_getrow.c
+index ae220f5..39010ba 100644
+--- a/urt/rle_getrow.c
++++ b/urt/rle_getrow.c
+@@ -164,6 +164,7 @@ rle_get_setup(rle_hdr * const the_hdr) {
+ char * cp;
+
+ VAXSHORT(comlen, infile); /* get comment length */
++ overflow_add(comlen, 1);
+ evenlen = (comlen + 1) & ~1; /* make it even */
+ if (evenlen) {
+ MALLOCARRAY(comment_buf, evenlen);
+diff --git a/urt/rle_hdr.c b/urt/rle_hdr.c
+index 1edb7a3..c3dd60f 100644
+--- a/urt/rle_hdr.c
++++ b/urt/rle_hdr.c
+@@ -148,6 +148,7 @@ rle_hdr_cp(rle_hdr * const fromHdrP,
+ if (toHdrP->cmap) {
+ size_t const size =
+ toHdrP->ncmap * (1 << toHdrP->cmaplen) * sizeof(rle_map);
++ overflow3(toHdrP->ncmap, 1<cmaplen, sizeof(rle_map));
+ toHdrP->cmap = malloc(size);
+ if (!toHdrP->cmap)
+ pm_error("Failed to allocate memory for %u color maps "
+@@ -163,12 +164,16 @@ rle_hdr_cp(rle_hdr * const fromHdrP,
+ const char ** cp;
+
+ /* Count the comments. */
+- for (cp = toHdrP->comments, size = 0; *cp; ++cp)
++ for (cp = toHdrP->comments, size = 0; *cp; ++cp) {
++ overflow_add(size, 1);
+ ++size;
++ }
+
+ /* Check if there are really any comments. */
+ if (size > 0) {
++ overflow_add(size, 1);
+ ++size; /* Copy the NULL pointer, too. */
++ overflow2(size, sizeof(char *));
+ size *= sizeof(char *);
+ toHdrP->comments = malloc(size);
+ if (!toHdrP->comments)
+diff --git a/urt/rle_open_f.c b/urt/rle_open_f.c
+index 1aeb644..595b15c 100644
+--- a/urt/rle_open_f.c
++++ b/urt/rle_open_f.c
+@@ -163,65 +163,7 @@ dealWithSubprocess(const char * const file_name,
+ FILE ** const fpP,
+ bool * const noSubprocessP,
+ const char ** const errorP) {
+-
+-#ifdef NO_OPEN_PIPES
+ *noSubprocessP = TRUE;
+-#else
+- const char *cp;
+-
+- reapChildren(catchingChildrenP, pids);
+-
+- /* Real file, not stdin or stdout. If name ends in ".Z",
+- * pipe from/to un/compress (depending on r/w mode).
+- *
+- * If it starts with "|", popen that command.
+- */
+-
+- cp = file_name + strlen(file_name) - 2;
+- /* Pipe case. */
+- if (file_name[0] == '|') {
+- pid_t thepid; /* PID from my_popen */
+-
+- *noSubprocessP = FALSE;
+-
+- *fpP = my_popen(file_name + 1, mode, &thepid);
+- if (*fpP == NULL)
+- *errorP = "%s: can't invoke <<%s>> for %s: ";
+- else {
+- /* One more child to catch, eventually. */
+- if (*catchingChildrenP < MAX_CHILDREN)
+- pids[(*catchingChildrenP)++] = thepid;
+- }
+- } else if (cp > file_name && *cp == '.' && *(cp + 1) == 'Z' ) {
+- /* Compress case. */
+- pid_t thepid; /* PID from my_popen. */
+- const char * command;
+-
+- *noSubprocessP = FALSE;
+-
+- if (*mode == 'w')
+- pm_asprintf(&command, "compress > %s", file_name);
+- else if (*mode == 'a')
+- pm_asprintf(&command, "compress >> %s", file_name);
+- else
+- pm_asprintf(&command, "compress -d < %s", file_name);
+-
+- *fpP = my_popen(command, mode, &thepid);
+-
+- if (*fpP == NULL)
+- *errorP = "%s: can't invoke 'compress' program, "
+- "trying to open %s for %s";
+- else {
+- /* One more child to catch, eventually. */
+- if (*catchingChildrenP < MAX_CHILDREN)
+- pids[(*catchingChildrenP)++] = thepid;
+- }
+- pm_strfree(command);
+- } else {
+- *noSubprocessP = TRUE;
+- *errorP = NULL;
+- }
+-#endif
+ }
+
+
+diff --git a/urt/rle_putcom.c b/urt/rle_putcom.c
+index ab2eb20..ce83615 100644
+--- a/urt/rle_putcom.c
++++ b/urt/rle_putcom.c
+@@ -98,12 +98,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
+diff --git a/urt/scanargs.c b/urt/scanargs.c
+index f3af334..8dfa05b 100644
+--- a/urt/scanargs.c
++++ b/urt/scanargs.c
+@@ -62,8 +62,8 @@ typedef int *ptr;
+ /*
+ * Storage allocation macros
+ */
+-#define NEW( type, cnt ) (type *) malloc( (cnt) * sizeof( type ) )
+-#define RENEW( type, ptr, cnt ) (type *) realloc( ptr, (cnt) * sizeof( type ) )
++#define NEW( type, cnt ) (type *) malloc2( (cnt) , sizeof( type ) )
++#define RENEW( type, ptr, cnt ) (type *) realloc2( ptr, (cnt), sizeof( type ) )
+
+ static CONST_DECL char * prformat( CONST_DECL char *, int );
+ static int isnum( CONST_DECL char *, int, int );
+
diff --git a/netpbm-CAN-2005-2471.patch b/netpbm-CAN-2005-2471.patch
index ae17d6b..de6bc59 100644
--- a/netpbm-CAN-2005-2471.patch
+++ b/netpbm-CAN-2005-2471.patch
@@ -1,6 +1,6 @@
diff -urNp a/converter/other/pstopnm.c b/converter/other/pstopnm.c
---- a/converter/other/pstopnm.c 2018-07-23 15:14:51.200658026 +0200
-+++ b/converter/other/pstopnm.c 2018-07-23 15:18:12.579910612 +0200
+--- a/converter/other/pstopnm.c 2025-02-04 10:47:27.857451432 +0100
++++ b/converter/other/pstopnm.c 2025-02-04 10:55:56.430470597 +0100
@@ -896,11 +896,11 @@ execGhostscript(int const
ghostscriptProg, arg0,
deviceopt, outfileopt, gopt, ropt, textalphabitsopt,
@@ -9,9 +9,9 @@ diff -urNp a/converter/other/pstopnm.c b/converter/other/pstopnm.c
+ "-dPARANOIDSAFER", "-");
}
- execl(ghostscriptProg, arg0, deviceopt, outfileopt, gopt, ropt,
-- textalphabitsopt, "-q", "-dNOPAUSE", "-dSAFER", "-", NULL);
-+ "-q", "-dNOPAUSE", "-dPARANOIDSAFER", "-", NULL);
+ execl(ghostscriptProg, arg0, deviceopt, outfileopt, gopt, ropt,
+- textalphabitsopt, "-q", "-dNOPAUSE", "-dSAFER", "-", NULL);
++ "-q", "-dNOPAUSE", "-dPARANOIDSAFER", "-", NULL);
pm_error("execl() of Ghostscript ('%s') failed, errno=%d (%s)",
ghostscriptProg, errno, strerror(errno));
diff --git a/netpbm-c99.patch b/netpbm-c99.patch
index ed0a887..bcb8a99 100644
--- a/netpbm-c99.patch
+++ b/netpbm-c99.patch
@@ -1,46 +1,41 @@
-Include "pm.h" for the declaration of the overflow_add function. This
-avoids an implicit function declaration. Future C compilers will
-require that all functions are declared explicitly. Implicit function
-declarations are a language feature that was removed in 1999.
+Remove the contents of libjasper_compat.c. The assignment
-Likewise, include "pm.h" for the newly added declarations of realloc2.
-This fixes a pointer truncation bug in pjtoppm.
+ *errorP = errorP;
-Both issues are specific to downstream patches.
+is bogus because it creates a non-null value in *errorP even on
+success, and the caller expects a null pointer int his case.
-diff --git a/converter/pbm/pbmtoppa/pbm.c b/converter/pbm/pbmtoppa/pbm.c
-index 1c8d236219b297e1..d63cab63b13f2051 100644
---- a/converter/pbm/pbmtoppa/pbm.c
-+++ b/converter/pbm/pbmtoppa/pbm.c
-@@ -12,6 +12,7 @@
- #include
- #include
-
-+#include "pm.h"
- #include "ppapbm.h"
-
- int make_pbm_stat(pbm_stat* pbm,FILE* fptr)
-diff --git a/converter/ppm/pjtoppm.c b/converter/ppm/pjtoppm.c
-index c458c06457c2b9bd..5e93a6acb8d6f198 100644
---- a/converter/ppm/pjtoppm.c
-+++ b/converter/ppm/pjtoppm.c
-@@ -10,6 +10,7 @@
- ** implied warranty.
- */
-
-+#include "pm.h"
- #include "ppm.h"
- #include "mallocvar.h"
-
-diff --git a/lib/pm.h b/lib/pm.h
-index 5037c2519c565fbc..435445d5e7f52fbf 100644
---- a/lib/pm.h
-+++ b/lib/pm.h
-@@ -457,6 +457,7 @@ pm_parse_height(const char * const arg);
-
- void *malloc2(int, int);
- void *malloc3(int, int, int);
-+void *realloc2(void * a, int b, int c);
- #define overflow2(a,b) __overflow2(a,b)
- void __overflow2(int, int);
- void overflow3(int, int, int);
+The source file is compiled, but not actually linked in, so this is
+only a problem because of the type error that fails the build.
+
+diff --git a/converter/other/jpeg2000/libjasper_compat.c b/converter/other/jpeg2000/libjasper_compat.c
+index 101820a321212dc6..e69de29bb2d1d643 100644
+--- a/converter/other/jpeg2000/libjasper_compat.c
++++ b/converter/other/jpeg2000/libjasper_compat.c
+@@ -1,26 +0,0 @@
+-#include "netpbm/nstring.h"
+-
+-#include "jasper/jasper.h"
+-#include "jasper/jas_image.h"
+-
+-#ifndef JAS_HAVE_PMJAS_IMAGE_DECODE
+-
+-void
+-pmjas_image_decode(jas_stream_t * const in,
+- int const fmtArg,
+- const char * const optstr,
+- jas_image_t ** const imagePP,
+- const char ** const errorP) {
+-
+- jas_image_t * const jasperP = jas_image_decode(in, fmtArg, optstr);
+-
+- if (jasperP) {
+- *imagePP = jasperP;
+- *errorP = errorP;
+- } else {
+- pm_asprintf(errorP, "Failed. Details may have been written to "
+- "Standard Error");
+- }
+-}
+-
+-#endif
diff --git a/netpbm-cmuwtopbm.patch b/netpbm-cmuwtopbm.patch
deleted file mode 100644
index f5b328b..0000000
--- a/netpbm-cmuwtopbm.patch
+++ /dev/null
@@ -1,21 +0,0 @@
-diff -up netpbm-10.61.01/converter/pbm/cmuwmtopbm.c.cmuwtopbmfix netpbm-10.61.01/converter/pbm/cmuwmtopbm.c
---- netpbm-10.61.01/converter/pbm/cmuwmtopbm.c.cmuwtopbmfix 2013-01-02 18:39:57.000000000 +0100
-+++ netpbm-10.61.01/converter/pbm/cmuwmtopbm.c 2013-01-03 05:41:36.024984241 +0100
-@@ -18,7 +18,7 @@
- This program does not check the pad bits at the end of each row.
- */
-
--
-+#include
- #include "pbm.h"
-
- /*--------------------------
-@@ -42,7 +42,7 @@ readCmuwmHeader(FILE * const ifP
- "CMU window manager header EOF / read error";
- uint32_t const cmuwmMagic = 0xf10040bb;
-
-- long l;
-+ uint32_t l;
- short s;
- int rc;
-
diff --git a/netpbm-glibc.patch b/netpbm-glibc.patch
index 4ae71e8..c500386 100644
--- a/netpbm-glibc.patch
+++ b/netpbm-glibc.patch
@@ -1,9 +1,10 @@
---- netpbm-10.35/converter/other/pnmtotiffcmyk.c.glibc 2006-09-18 12:20:06.000000000 +0200
-+++ netpbm-10.35/converter/other/pnmtotiffcmyk.c 2007-08-23 09:18:30.000000000 +0200
-@@ -974,8 +974,8 @@ int main( int argc, char **argv ) {
+diff -urNp a/converter/other/pnmtotiffcmyk.c b/converter/other/pnmtotiffcmyk.c
+--- a/converter/other/pnmtotiffcmyk.c 2025-02-04 10:47:27.858451429 +0100
++++ b/converter/other/pnmtotiffcmyk.c 2025-02-04 11:04:46.118394226 +0100
+@@ -989,8 +989,8 @@ int main( int argc, char **argv ) {
if ( (err = parseOpts( argc, argv, rt )) ) goto exit ;
-
+
- if ( (err = rt->in->open( rt->in, rt )) ) goto exit ;
- if ( (err = rt->out->open( rt->out, rt )) ) goto exit ;
+ if ( (err = (rt->in->open)( rt->in, rt )) ) goto exit ;
diff --git a/netpbm-manfix.patch b/netpbm-manfix.patch
index 10f635d..6d759c1 100644
--- a/netpbm-manfix.patch
+++ b/netpbm-manfix.patch
@@ -1,25 +1,20 @@
diff -urNp a/userguide/avstopam.html b/userguide/avstopam.html
---- a/userguide/avstopam.html 2022-01-03 16:56:37.731614243 +0100
-+++ b/userguide/avstopam.html 2022-01-03 16:58:29.889416006 +0100
-@@ -2,12 +2,13 @@
+--- a/userguide/avstopam.html 2025-02-04 10:47:27.823451565 +0100
++++ b/userguide/avstopam.html 2025-02-04 17:49:34.981978989 +0100
+@@ -2,9 +2,9 @@
Avstopam User Manual
avstopam
-Updated: 07 February 2010
-
-Table Of Contents
-+
+Updated: 07 February 2010
+
+Table Of Contents
NAME
--avstopam - convert an AVS X image to a Netpbm image
-+
avstopam - convert an AVS X image to a Netpbm image
-
- SYNOPSIS
-
-@@ -16,40 +17,40 @@ Updated: 07 February 2010
+ avstopam - convert an AVS X image to a Netpbm image
+@@ -16,40 +16,40 @@ Updated: 07 February 2010
DESCRIPTION
@@ -72,8 +67,8 @@ diff -urNp a/userguide/avstopam.html b/userguide/avstopam.html
diff -urNp a/userguide/faxformat.html b/userguide/faxformat.html
---- a/userguide/faxformat.html 2022-01-03 16:56:37.731614243 +0100
-+++ b/userguide/faxformat.html 2022-01-03 16:58:29.890416013 +0100
+--- a/userguide/faxformat.html 2025-02-04 10:47:27.824451560 +0100
++++ b/userguide/faxformat.html 2025-02-04 17:50:41.300631089 +0100
@@ -5,10 +5,11 @@
Updated: 03 December 2008
@@ -88,8 +83,8 @@ diff -urNp a/userguide/faxformat.html b/userguide/faxformat.html
(the idea is to provide a way to be sure that a fax machine is able to receive
a fax sent by another). These standards incidentally specify graphics file
diff -urNp a/userguide/libnetpbm_ug.html b/userguide/libnetpbm_ug.html
---- a/userguide/libnetpbm_ug.html 2022-01-03 16:56:37.732614250 +0100
-+++ b/userguide/libnetpbm_ug.html 2022-01-03 16:58:29.891416020 +0100
+--- a/userguide/libnetpbm_ug.html 2025-02-04 10:47:27.824451560 +0100
++++ b/userguide/libnetpbm_ug.html 2025-02-04 17:52:02.045207328 +0100
@@ -374,7 +374,7 @@ plain format.
Reference
@@ -100,8 +95,8 @@ diff -urNp a/userguide/libnetpbm_ug.html b/userguide/libnetpbm_ug.html
The Libnetpbm Utility Manual
diff -urNp a/userguide/pamfunc.html b/userguide/pamfunc.html
---- a/userguide/pamfunc.html 2022-01-03 16:56:37.730614236 +0100
-+++ b/userguide/pamfunc.html 2022-01-03 16:58:29.892416027 +0100
+--- a/userguide/pamfunc.html 2025-02-04 10:47:27.823451565 +0100
++++ b/userguide/pamfunc.html 2025-02-04 17:52:19.661114878 +0100
@@ -60,7 +60,7 @@ output image.
and bit string (such as and with 01001000). For the arithmetic functions, the
function arguments and results are the fraction that a sample is of the
@@ -112,9 +107,9 @@ diff -urNp a/userguide/pamfunc.html b/userguide/pamfunc.html
Arithmetic functions
diff -urNp a/userguide/pammixmulti.html b/userguide/pammixmulti.html
---- a/userguide/pammixmulti.html 2022-01-03 16:56:37.731614243 +0100
-+++ b/userguide/pammixmulti.html 2022-01-03 16:58:29.893416034 +0100
-@@ -7,8 +7,8 @@ Updated: 18 November 2018
+--- a/userguide/pammixmulti.html 2025-02-04 10:47:27.820451577 +0100
++++ b/userguide/pammixmulti.html 2025-02-04 17:56:58.538651212 +0100
+@@ -7,8 +7,8 @@ Updated: 18 December 2024
Table Of Contents
@@ -125,9 +120,15 @@ diff -urNp a/userguide/pammixmulti.html b/userguide/pammixmulti.html
SYNOPSIS
-@@ -22,14 +22,14 @@ Updated: 18 November 2018
- Minimum unique abbreviation of an option is acceptable. You can use a
- single hyphen instead of double hyphens to denote options. You can use white
+@@ -17,19 +17,19 @@ Updated: 18 December 2024
+ [-maskfile=filename]
+ [-stdev=number]
+ [-randomseed integer]
+- filename ...
++ filename ...
+
+ Minimum unique abbreviation of an option is acceptable. You can use double
+ hyphen instead of a single hyphen to denote options. You can use white
space in place of the equals sign to separate an option name from its
-value.
+value.
@@ -151,17 +152,19 @@ diff -urNp a/userguide/pammixmulti.html b/userguide/pammixmulti.html
+command line options:
- - --blend=average|random|mask
-@@ -50,7 +50,7 @@ output is produced by selecting the corr
- images, chosen at random on a per-pixel basis. With
- --blend=mask, each pixel in the output is produced by a
- weighted average of the corresponding pixels from all the input images based
--on the grayscale level of an additional mask image.
-+on the grayscale level of an additional mask image.
+ - -blend=average|alpha-weighted|random|mask
+@@ -55,8 +55,8 @@ of the input images, chosen at random on
+ With -blend=mask, each pixel in the output is
+ produced by a weighted average of the corresponding pixels from all
+ the input images based on the grayscale level of an additional mask
+-image.
+--alpha-weighted was new in Netpbm 11.09 (December 2024).
++image.
++-alpha-weighted was new in Netpbm 11.09 (December 2024).
- - --maskfile=filename
-@@ -60,7 +60,7 @@ grayscale mask file to control the blend
+ - -maskfile=filename
+@@ -66,7 +66,7 @@ grayscale mask file to control the blend
not grayscale, the first channel is treated as gray). Where the mask file is
black, the first image is selected. Where the mask file is white, the last
image is selected. Intermediate levels of gray select intermediate
@@ -169,19 +172,19 @@ diff -urNp a/userguide/pammixmulti.html b/userguide/pammixmulti.html
+images.
- - --stdev=number
-@@ -77,7 +77,7 @@ that includes roughly equal amounts of t
+ - -stdev=number
+@@ -83,7 +83,7 @@ that includes roughly equal amounts of t
and 2 but less of the corresponding pixel from image 3. As number
tends towards the number of input images (going beyond that has diminishing
impact), the output tends to look more
--like --blend=average. number defaults to 0.25.
-+like --blend=average. number defaults to 0.25.
+-like -blend=average. number defaults to 0.25.
++like -blend=average. number defaults to 0.25.
- - --randomseed integer
-@@ -85,45 +85,45 @@ like --blend=average. number
+
- -randomseed integer
+@@ -91,45 +91,45 @@ like -blend=average. numberThis is the seed for the random number generator used with
- --blend=random
+ -blend=random
-
Use this to ensure you get the same image on separate invocations.
+
Use this to ensure you get the same image on separate invocations.
@@ -207,7 +210,7 @@ diff -urNp a/userguide/pammixmulti.html b/userguide/pammixmulti.html
+image:
- pammixmulti --blend=random input*.ppm >output.ppm
+ pammixmulti -blend=random input*.ppm >output.ppm
Use a mask image to control the fading among input images on a
@@ -215,7 +218,7 @@ diff -urNp a/userguide/pammixmulti.html b/userguide/pammixmulti.html
+pixel-by-pixel basis:
- pammixmulti --blend=mask --maskfile=mask.pgm >output.pam \
+ pammixmulti -blend=mask -maskfile=mask.pgm >output.pam \
one.pam two.pam three.pam four.pam
@@ -223,7 +226,7 @@ diff -urNp a/userguide/pammixmulti.html b/userguide/pammixmulti.html
+Do the same but with more abrupt transitions:
- pammixmulti --blend=mask --maskfile=mask.pgm --stdev=0.0 >output.pam \
+ pammixmulti -blend=mask -maskfile=mask.pgm -stdev=0.0 >output.pam \
one.pam two.pam three.pam four.pam
@@ -231,8 +234,8 @@ diff -urNp a/userguide/pammixmulti.html b/userguide/pammixmulti.html
+and now with more gradual transitions:
- pammixmulti --blend=mask --maskfile=mask.pgm --stdev=1.0 >output.pam \
-@@ -133,12 +133,12 @@ pixel-by-pixel basis:
+ pammixmulti -blend=mask -maskfile=mask.pgm -stdev=1.0 >output.pam \
+@@ -139,12 +139,12 @@ pixel-by-pixel basis:
HISTORY
@@ -242,12 +245,12 @@ diff -urNp a/userguide/pammixmulti.html b/userguide/pammixmulti.html
AUTHOR
--Copyright 2018 Scott Pakin, scott+pbm@pakin.org.
-+
Copyright 2018 Scott Pakin, scott+pbm@pakin.org.
+-Copyright 2018–2024 Scott Pakin, scott+pbm@pakin.org.
++
Copyright 2018–2024 Scott Pakin, scott+pbm@pakin.org.
SEE ALSO
-@@ -146,20 +146,20 @@ pixel-by-pixel basis:
+@@ -152,20 +152,20 @@ pixel-by-pixel basis:
ppmmix,
pamarith,
pnm,
@@ -278,8 +281,8 @@ diff -urNp a/userguide/pammixmulti.html b/userguide/pammixmulti.html