diff --git a/.gitignore b/.gitignore
index f4510f8..41e3700 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,20 +13,3 @@
/netpbm-10.84.03.tar.xz
/netpbm-10.86.00.tar.xz
/netpbm-10.87.00.tar.xz
-/netpbm-10.88.00.tar.xz
-/netpbm-10.89.00.tar.xz
-/netpbm-10.90.00.tar.xz
-/netpbm-10.92.00.tar.xz
-/netpbm-10.93.00.tar.xz
-/netpbm-10.94.05.tar.xz
-/netpbm-10.95.00.tar.xz
-/netpbm-10.96.00.tar.xz
-/netpbm-10.97.00.tar.xz
-/netpbm-10.99.00.tar.xz
-/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
deleted file mode 100644
index b3c3cb9..0000000
--- a/fix.patch
+++ /dev/null
@@ -1,1336 +0,0 @@
-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 The frame options are additive. All the parts of the image
@@ -105,20 +89,31 @@ index 018f18a..13073d2 100644
--include (or their defaults) are in the visible part. The
visible part is the smallest possible rectangle that contains the
parts specified those three ways.
-diff --git a/userguide/pbmtoepson.html b/userguide/pbmtoepson.html
-index baacf7b..e74a7fe 100644
---- a/userguide/pbmtoepson.html
-+++ b/userguide/pbmtoepson.html
-@@ -16,7 +16,7 @@ pbmtoepson - convert a PBM image into Epson printer graphics
+diff -urNp old/converter/pbm/pbmtoepson.c new/converter/pbm/pbmtoepson.c
+--- old/converter/pbm/pbmtoepson.c 2018-01-04 14:26:14.740024843 +0100
++++ new/converter/pbm/pbmtoepson.c 2018-01-04 14:28:47.970518766 +0100
+@@ -75,7 +75,7 @@ parseCommandLine(int ar
+ &dpiSpec, 0);
+ OPTENT3(0, "adjacent", OPT_FLAG, NULL,
+ &adjacentSpec, 0);
+- OPTENT3(0, "nonadjacent", OPT_FLAG, NULL,
++ OPTENT3(0, "noadjacent", OPT_FLAG, NULL,
+ &nonadjacentSpec, 0);
+
+ opt.opt_table = option_def;
+diff -urNp old/userguide/pbmtoepson.html new/userguide/pbmtoepson.html
+--- old/userguide/pbmtoepson.html 2018-01-04 14:26:14.586024719 +0100
++++ new/userguide/pbmtoepson.html 2018-01-04 14:27:56.466847698 +0100
+@@ -18,7 +18,7 @@ pbmtoepson - convert a PBM image into Ep
[-dpi=n]
- [-protocol={escp9|escp}]
+ [-protocol={escp9|escp}]
[-adjacent]
-[-nonadjacent]
+[-noadjacent]
- [pbmfile]
+ [pbmfile]
-@@ -75,7 +75,7 @@ print density for you consistent with your other options.
+@@ -74,7 +74,7 @@ print density for you consistent with yo
This option was new in Netpbm 10.23 (July 2004).
Updated: 07 February 2010 avstopam - convert an AVS X image to a Netpbm image
-@@ -16,40 +16,40 @@ Updated: 07 February 2010
++ This program is part of Netpbm.
-+ This program is part of Netpbm. avstopam reads a Stardent AVS X image as input and produces a Netpbm
--image as output.
-+image as output. avsfile is the input file, which defaults to Standard Input.
--Output is always on Standard Output.
-+Output is always on Standard Output. There are no command line options defined specifically
- for avstopam, but it recognizes the options common to all
- programs based on libnetpbm (See
--Common Options.)
-+Common Options.) Copyright © 2010 Scott Pakin,
--scott+pbm@pakin.org
-+scott+pbm@pakin.org This page, part of the Netpbm user's guide,
describes FAX formats in relation to Netpbm facilities.
-
-+ The ITU (formerly CCITT) publishes standards for operation of fax machines
(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 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.
- The Libnetpbm Netpbm Image
--Processing Manual describes the the libnetpbm functions for
-+Processing Manual describes the libnetpbm functions for
- processing image data.
-
- The Libnetpbm Utility Manual
-diff -urNp a/userguide/pamfunc.html b/userguide/pamfunc.html
---- 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
- maxval, i.e. normal interpretation of PAM tuples. But for the bit string
--functions, the value is the the bit string whose value as a binary cipher is
-+functions, the value is the bit string whose value as a binary cipher is
- the sample value, and the maxval indicates the width of the bit string.
-
- pammixmulti - blend together multiple PAM images
-+ pammixmulti - blend together multiple PAM imagesavstopam
--Updated: 07 February 2010
--
--Table Of Contents
-+NAME
+diff -urNp old/userguide/escp2topbm.html new/userguide/escp2topbm.html
+--- old/userguide/escp2topbm.html 2017-09-05 13:58:08.335559561 +0200
++++ new/userguide/escp2topbm.html 2017-09-05 14:01:20.226842694 +0200
+@@ -6,6 +6,7 @@ Updated: 14 July 2015
+
+ Table Of Contents
- NAME
+ escp2topbm - convert an ESC/P2 printer file to a PBM image
- DESCRIPTION
-
--OPTIONS
-
- AUTHOR
-
- SEE ALSO
-
--
-
-
-
- Table Of Contents
-
--
-
-
-diff -urNp a/userguide/faxformat.html b/userguide/faxformat.html
---- a/userguide/faxformat.html 2025-02-04 10:47:27.824451560 +0100
-+++ b/userguide/faxformat.html 2025-02-04 17:50:41.300631089 +0100
+ SYNOPSIS
+diff -urNp old/userguide/faxformat.html new/userguide/faxformat.html
+--- old/userguide/faxformat.html 2017-09-05 13:58:08.337559553 +0200
++++ new/userguide/faxformat.html 2017-09-05 14:02:33.322571279 +0200
@@ -5,10 +5,11 @@
Updated: 03 December 2008
-
+
-+SYNOPSIS
++SYNOPSIS
DESCRIPTION
++DESCRIPTION
Reference
+diff -urNp old/userguide/pampaintspill.html new/userguide/pampaintspill.html
+--- old/userguide/pampaintspill.html 2017-09-05 13:58:08.338559550 +0200
++++ new/userguide/pampaintspill.html 2017-09-05 14:03:32.625351620 +0200
+@@ -1,8 +1,7 @@
+
+-
++
+
+ Arithmetic functions
-diff -urNp a/userguide/pammixmulti.html b/userguide/pammixmulti.html
---- 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
-
-
--NAME
--NAME
-+SYNOPSIS
-@@ -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.
- - -This file is part of Netpbm. -+
This file is part of Netpbm.
- -pammixmulti mixes two or more images to produce a new image. The --program provides multiple ways to interpret "mix." -+program provides multiple ways to interpret "mix."
- - -In addition to the options common to all programs based on libnetpbm - (most notably -quiet, see - Common Options), pammixmulti recognizes the following --command line options: -+command line options:
- -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).
- - -Use this to ensure you get the same image on separate invocations. -+
Use this to ensure you get the same image on separate invocations.
- -You supply the names of the files to mix as non-option arguments. -+
You supply the names of the files to mix as non-option arguments.
- - -Average a bunch of PPM images to produce a new PAM image: -+
Average a bunch of PPM images to produce a new PAM image:
-
- pammixmulti input*.ppm >output.ppm
-
-
- Mix these same images by taking each pixel from a randomly selected input --image: -+image:
- -
- pammixmulti -blend=random input*.ppm >output.ppm
-
-
- Use a mask image to control the fading among input images on a --pixel-by-pixel basis: -+pixel-by-pixel basis:
- -
- pammixmulti -blend=mask -maskfile=mask.pgm >output.pam \
- one.pam two.pam three.pam four.pam
-
-
--Do the same but with more abrupt transitions: -+
Do the same but with more abrupt transitions:
- -
- pammixmulti -blend=mask -maskfile=mask.pgm -stdev=0.0 >output.pam \
- one.pam two.pam three.pam four.pam
-
-
--and now with more gradual transitions: -+
and now with more gradual transitions:
- -
- pammixmulti -blend=mask -maskfile=mask.pgm -stdev=1.0 >output.pam \
-@@ -139,12 +139,12 @@ pixel-by-pixel basis:
-
- HISTORY
-
--pammixmulti was new in Netpbm 10.85 (December 2018).
-+
pammixmulti was new in Netpbm 10.85 (December 2018).
-
-
- AUTHOR
-
--Copyright 2018–2024 Scott Pakin, scott+pbm@pakin.org.
-+
Copyright 2018–2024 Scott Pakin, scott+pbm@pakin.org.
-
- SEE ALSO
-
-@@ -152,20 +152,20 @@ pixel-by-pixel basis:
- ppmmix,
- pamarith,
- pnm,
--pam
-+pam
-
-
- Table Of Contents
-
-
--- SYNOPSIS
--
- DESCRIPTION
--
- OPTIONS
--
- ARGUMENTS
--
- EXAMPLES
--
- HISTORY
--
- AUTHOR
--
- SEE ALSO
-+
- SYNOPSIS
-+- DESCRIPTION
-+- OPTIONS
-+- ARGUMENTS
-+- EXAMPLES
-+- HISTORY
-+- AUTHOR
-+- SEE ALSO
-
-
-
-diff -urNp a/userguide/pampaintspill.html b/userguide/pampaintspill.html
---- a/userguide/pampaintspill.html 2025-02-04 10:47:27.823451565 +0100
-+++ b/userguide/pampaintspill.html 2025-02-04 18:01:50.746117598 +0100
-@@ -7,7 +7,7 @@ Updated: 02 November 2021
- Table Of Contents
-
- NAME
--pampaintspill - smoothly spill colors into the background
-+pampaintspill - smoothly spill colors into the background
-
- SYNOPSIS
-
-@@ -19,48 +19,48 @@ pampaintspill - smoothly spill colors in
- [--downsample=number]
- [--near=number]
- [--power=number] [filename]
--[-randomseed=integer]
-+[-randomseed=integer]
-
-
- Minimum unique abbreviations of option are acceptable. You may use
- double hyphens instead of single hyphen to denote options. You may use
- white space in place of the equals sign to separate an option name
--from its value.
-+from its value.
-
- DESCRIPTION
-
--This program is part of Netpbm.
-+
This program is part of Netpbm.
-
- pampaintspill produces a smooth color gradient from all of the
- non-background-colored pixels in an input image, effectively "spilling
- paint" onto the background. pampaintspill is similar to
--pamgradient but differs in the following characteristics:
-+pamgradient but differs in the following characteristics:
-
-
- - pampaintspill accepts any number of paint
- sources (non-background-colored pixels), which can lie anywhere
- on the canvas. pamgradient accepts exactly
-- four paint sources, one in each corner of the image.
-+ four paint sources, one in each corner of the image.
-
- - pampaintspill requires an input image while
- pamgradient generates a new image from
-- scratch.
-+ scratch.
-
- - pampaintspill can produce tileable output and
- can control how tightly the gradient colors bind to their source
-- pixels.
-+ pixels.
-
-
- Results are generally best when the input image contains just a few, crisp
- spots of color. Use your drawing program's pencil tool — as opposed to a
--paintbrush or airbrush tool — with a small nib.
-+paintbrush or airbrush tool — with a small nib.
-
- OPTIONS
-
- In addition to the options common to all programs based on libnetpbm
- (most notably -quiet, see
- Common Options), pampaintspill recognizes the following
--command line options:
-+command line options:
-
-
- - --bgcolor=color
-@@ -117,45 +117,45 @@ command line options:
- gradients away from them.
-
- - -randomseed=integer
--
- This is the seed for the random number generator that generates the
-- pixels.
-+
- This is the seed fodr the random number generator that generates the
-+ pixels.
-
-- Use this to ensure you get the same image on separate invocations.
-+
Use this to ensure you get the same image on separate invocations.
-
-- This option was new in Netpbm 10.94 (March 2021).
-+ This option was new in Netpbm 10.94 (March 2021).
-
-
-
- SEE ALSO
-
-
--- pamgradient
--
- ppmmake,
--
- ppmrainbow,
--
- pgmramp,
--
- ppmpat,
--
- pam
-+
- pamgradient
-+- ppmmake,
-+- ppmrainbow,
-+- pgmramp,
-+- ppmpat,
-+- pam
-
-
- HISTORY
-
--pampaintspill was new in Netpbm 10.50 (March 2010).
-+
pampaintspill was new in Netpbm 10.50 (March 2010).
-
-
- COPYRIGHT
-
- Copyright © 2010–2021 Scott Pakin,
--scott+pbm@pakin.org.
-+scott+pbm@pakin.org.
-
- Table Of Contents
-
-
--- SYNOPSIS
--
- DESCRIPTION
--
- OPTIONS
--
- SEE ALSO
--
- HISTORY
--
- COPYRIGHT
-+
- SYNOPSIS
-+- DESCRIPTION
-+- OPTIONS
-+- SEE ALSO
-+- HISTORY
-+- COPYRIGHT
-
-
-
-diff -urNp a/userguide/pamrecolor.html b/userguide/pamrecolor.html
---- a/userguide/pamrecolor.html 2025-02-04 10:47:27.823451565 +0100
-+++ b/userguide/pamrecolor.html 2025-02-04 18:10:00.968545076 +0100
-@@ -2,9 +2,9 @@
- Pamrecolor User Manual
- pamrecolor
--Updated: 31 July 2010
-+Updated: 31 July 2010
-
--Table Of Contents
-+Table Of Contents
+@@ -11,6 +10,7 @@
- NAME
- pamrecolor - alter colors without affecting luminance
-@@ -22,15 +22,15 @@ pamrecolor - alter colors without affect
- [-randomseed=integer]
+
- [infile]
--
-+
++NAME
+ pampaintspill - smoothly spill colors into the background
- Minimum unique abbreviation of option is acceptable. You may use double
- hyphens instead of single hyphen to denote options. You may use white
--space in place of the equals sign to separate an option name from its value.
-+space in place of the equals sign to separate an option name from its value.
+ SYNOPSIS
+diff -urNp old/userguide/pamrecolor.html new/userguide/pamrecolor.html
+--- old/userguide/pamrecolor.html 2017-09-05 13:58:08.336559557 +0200
++++ new/userguide/pamrecolor.html 2017-09-05 14:04:34.714122098 +0200
+@@ -1,8 +1,7 @@
+-
++
+
+
+ Pamrecolor User Manual
+-
+
- DESCRIPTION
+
+@@ -11,7 +10,7 @@
--This program is part of Netpbm.
-+
This program is part of Netpbm.
+ Updated: 31 July 2010
- pamrecolor changes an image's colors to be as close as
- possible to given target colors but with the constraint that the
-@@ -39,17 +39,17 @@ image will look identical if both are co
- (e.g. with
- ppmtopgm). You can have pamrecolor select
- target colors randomly, specify a single hue for the entire image, or take the
--target colors from a target image.
-+target colors from a target image.
-
- In addition to real Netpbm images, pamrecolor works on pseudo-Netpbm
- images based on arbitrary color spaces. You can define the color space
--explicitly or choose one of many that pamrecolor knows by name.
-+explicitly or choose one of many that pamrecolor knows by name.
-
- The output is a PAM image on standard output. Options control the
- exact format of the PAM. If you want a PNM (PBM, PGM, or PPM) image,
- use pamtopnm on the output. There is no
- need to convert if you will use the image as input to a current Netpbm
--program, but many other programs don't know what a PAM is.
-+program, but many other programs don't know what a PAM is.
+-
++
- OPTIONS
-@@ -57,7 +57,7 @@ program, but many other programs don't k
- In addition to the options common to all programs based on libnetpbm
- (most notably -quiet, see
- Common Options), pamrecolor recognizes the following
--command line options:
-+command line options:
+ NAME
+diff -urNp old/userguide/pamsistoaglyph.html new/userguide/pamsistoaglyph.html
+--- old/userguide/pamsistoaglyph.html 2017-09-05 13:58:08.334559565 +0200
++++ new/userguide/pamsistoaglyph.html 2017-09-05 14:05:25.865944327 +0200
+@@ -1,8 +1,7 @@
+
+-
++
+
+ Pamsistoaglyph User Manual
+-
+
-
+
+diff -urNp old/userguide/pamstereogram.html new/userguide/pamstereogram.html
+--- old/userguide/pamstereogram.html 2017-09-05 13:58:08.337559553 +0200
++++ new/userguide/pamstereogram.html 2017-09-05 14:13:28.523959069 +0200
+@@ -1,5 +1,5 @@
+-
+-
++
++
+
+ Pamstereogram User Manual
+
+@@ -10,7 +10,7 @@
-@@ -67,7 +67,7 @@ to luminance of each of the red, green,
- example, in the SMPTE-C color space an RGB color is converted to
- grayscale by multiplying the red channel by 0.2124132, the green
- channel by 0.7010437, and the blue channel by 0.0865432 and summing
--the resulting three products.
-+the resulting three products.
+ Updated: 19 June 2015
- When you use this option, the input and output images are not true Netpbm
- images, because the Netpbm image format specifies a particular color space.
-@@ -76,9 +76,9 @@ the raster have different meaning. Many
- images actually use a variation with a different color space. For example,
- GIMP uses sRGB internally and if you
- have GIMP generate a Netpbm image file, it really generates a variation of
--the format that uses sRGB.
-+the format that uses sRGB.
-
--pamrecolor knows the following color spaces (name values):
-+
pamrecolor knows the following color spaces (name values):
-
-
- - adobe
-@@ -109,12 +109,12 @@ the format that uses sRGB.
- The default is "ntsc" because this is the color space that the Netpbm
- formats and many graphics utilities use. As a counterexample,
- GIMP uses sRGB as its native color
--space.
-+space.
-
- The luminance values pamrecolor uses for each of the above come from
- Bruce Lindbloom's
-
--Computing RGB-to-XYZ and XYZ-to-RGB matrices page.
-+Computing RGB-to-XYZ and XYZ-to-RGB matrices page.
-
- - --rmult=fraction
- - --gmult=fraction
-@@ -133,15 +133,13 @@ image. pamrecolor will make each
- to color subject to the constraint that the luminance must stay the
- same as in the original image. Specify color as in
- the argument of the pnm_parsecolor()
--library routine (e.g., "hotpink" or "#ff69b4").
-+library routine (e.g., "hotpink" or "#ff69b4").
-
- If you specify neither --targetcolor nor
- --colorfile, pamrecolor will randomly select a target color for
--each pixel of the input image.
--
--
You may not specify both -targetcolor and -colorfile.
-+each pixel of the input image.
-
--
-+You may not specify both -targetcolor and -colorfile.
-
- - --colorfile=file
- - Take per-pixel target colors from Netpbm file file instead
-@@ -150,40 +148,38 @@ of using a single target color for the e
- If the image in the file wider or taller than the input image,
- pamrecolor uses only the left and top part of it.
- If the image is narrower or shorter, pamrecolor considers the
--image to be repeated in a tile pattern.
-+image to be repeated in a tile pattern.
-
- If you specify neither --targetcolor nor
- --colorfile, pamrecolor will randomly select a target color for
--each pixel of the input image.
-+each pixel of the input image.
-
--You may not specify both -targetcolor and -colorfile.
-+
You may not specify both -targetcolor and -colorfile.
-
--- -randomseed=integer
-+
- -randomseed=integer
-
- - This is the seed for the random number generator that generates the
--pixels.
-+pixels.
-
--Use this to ensure you get the same image on separate invocations.
-+
Use this to ensure you get the same image on separate invocations.
-
- By default, pamrecolor uses a seed derived from the time of day
- and process ID, which gives you fairly uncorrelated results in multiple
--invocations.
--
--
This option was new in Netpbm 10.61 (December 2012).
-+invocations.
-
--
-+This option was new in Netpbm 10.61 (December 2012).
+-
++
- EXAMPLES
+ NAME
+diff -urNp old/userguide/pamtoavs.html new/userguide/pamtoavs.html
+--- old/userguide/pamtoavs.html 2017-09-05 13:58:08.329559583 +0200
++++ new/userguide/pamtoavs.html 2017-09-05 14:05:49.299863901 +0200
+@@ -1,5 +1,5 @@
+
+-
++
+
+ Pamtoavs User Manual
+
+diff -urNp old/userguide/pamtooctaveimg.html new/userguide/pamtooctaveimg.html
+--- old/userguide/pamtooctaveimg.html 2017-09-05 13:58:08.335559561 +0200
++++ new/userguide/pamtooctaveimg.html 2017-09-05 14:06:21.825752356 +0200
+@@ -1,8 +1,7 @@
+
+-
++
+
+ Pamtooctaveimg User Manual
+-
+
--This command tints an image yellow:
-+
This command tints an image yellow:
+
+diff -urNp old/userguide/pnmflip.html new/userguide/pnmflip.html
+--- old/userguide/pnmflip.html 2017-09-05 13:58:08.336559557 +0200
++++ new/userguide/pnmflip.html 2017-09-05 14:07:15.065963977 +0200
+@@ -4,9 +4,11 @@
+
+ pnmflip
+
++NAME
+ pnmflip was replaced in Netpbm 10.13 (December 2002) by
+ pamflip.
-
- pamrecolor --targetcolor=yellow colorpic.pam > yellowpic.pam
-
++DESCRIPTION
+ pamflip is mostly backward compatible with pnmflip,
+ but works on PAM images too.
-
This command takes the colors from colorpicture.ppm and applies
--them to graypicture.pgm:
-+them to graypicture.pgm:
-
-
- pamrecolor --colorfile=colorpic.ppm graypic.pgm > colorizedpic.pam
-@@ -192,52 +188,52 @@ them to graypicture.pgm:
- The grayscale version of colorizedpic.pam will look just like
- graypic.pgm. Note that if you use a non-Netpbm tool to do the conversion to
- grayscale, you may additionally need to specify an
--appropriate --colorspace value for your conversion tool.
-+appropriate --colorspace value for your conversion tool.
-
-
- NOTES
-
- Here are a couple of fun special effects you can produce with
--pamrecolor:
-+pamrecolor:
-
-
- - Specify a color file that is identical to the input image but with
- some large, colored text added to it. The text will "magically"
--vanish when the image is converted to grayscale.
-+vanish when the image is converted to grayscale.
-
- - Provide a low-contrast grayscale image — perhaps a secret
- message written in similar shades of gray — as the input file and
- a colorful but completely different image as the color file. If done
- carefully, the grayscale image can be hidden by the colorful image.
- Only people who know to convert the result to grayscale can recover
--the original grayscale image.
-+the original grayscale image.
-
- - Use --targetcolor=tan to make an image look like an
- old-timey photograph (or, more precisely, a
- sepia-toned
--photograph of the late 1800s).
-+photograph of the late 1800s).
-
-
-
- HISTORY
-
--Scott Pakin wrote pamrecolor in July 2010.
-+
Scott Pakin wrote pamrecolor in July 2010.
-
--pamrecolor was new in Netpbm 10.52 (September 2010).
-+
pamrecolor was new in Netpbm 10.52 (September 2010).
-
-
- AUTHOR
-
- Copyright (C) 2010 Scott
--Pakin, scott+pbm@pakin.org
-+Pakin, scott+pbm@pakin.org
-
-
- SEE ALSO
-
-
-
-
-@@ -246,14 +242,14 @@ Pakin, Table Of Contents
-
-
--- SYNOPSIS
--
- DESCRIPTION
--
- OPTIONS
--
- EXAMPLES
--
- NOTES
--
- HISTORY
--
- AUTHOR
--
- SEE ALSO
-+
- SYNOPSIS
-+- DESCRIPTION
-+- OPTIONS
-+- EXAMPLES
-+- NOTES
-+- HISTORY
-+- AUTHOR
-+- SEE ALSO
-
-
-
-diff -urNp a/userguide/pbmtog3.html b/userguide/pbmtog3.html
---- a/userguide/pbmtog3.html 2025-02-04 10:47:27.827451549 +0100
-+++ b/userguide/pbmtog3.html 2025-02-04 18:10:55.328259786 +0100
-@@ -80,7 +80,7 @@ You cannot specify both.
- HISTORY
-
- Before Netpbm 10.79 (June 2017), there was a different program by the same
--name in Netpbm, which was written by by Paul Haeberli
-+name in Netpbm, which was written by Paul Haeberli
- <paul@manray.sgi.com> in 1989
- and then modified extensively by others.
-
-diff -urNp a/userguide/ppmtogif.html b/userguide/ppmtogif.html
---- a/userguide/ppmtogif.html 2025-02-04 10:47:27.828451545 +0100
-+++ b/userguide/ppmtogif.html 2025-02-04 18:12:39.950710820 +0100
-@@ -5,17 +5,17 @@
-
-
NAME
-
--ppmtogif - replaced by pamtogif
--
--DESCRIPTION
-+ppmtogif - replaced by pamtogif
-
- This program is part of Netpbm.
-
-+
SYNOPSIS
+diff -urNp old/userguide/pnmmercator.html new/userguide/pnmmercator.html
+--- old/userguide/pnmmercator.html 2017-09-05 13:58:08.334559565 +0200
++++ new/userguide/pnmmercator.html 2017-09-05 14:08:08.305214742 +0200
+@@ -1,7 +1,6 @@
+-
++
+
+
+-
+ PnmMercator User Manual
+
+
+diff -urNp old/userguide/ppmtogif.html new/userguide/ppmtogif.html
+--- old/userguide/ppmtogif.html 2017-09-05 13:58:08.337559553 +0200
++++ new/userguide/ppmtogif.html 2017-09-05 14:09:51.450583126 +0200
+@@ -4,11 +4,14 @@
+
+ ppmtogif
+
++NAME
ppmtogif was replaced in Netpbm 10.37 (December 2006) by
pamtogif.
-
pamtogif is mostly backward compatible with ppmtogif.
++
SYNOPSIS
+ pamtogif is mostly backward compatible with ppmtogif.
-+
DESCRIPTION
- One way pamtogif is not backward compatible with ppmtogif
++
DESCRIPTION
+ One way pamtogif is not backward compatible with ppmtogif
is that to specify a transparency (alpha) mask with ppmtogif, you
supply the transparency as a separate pseudo-PGM image and use the
diff --git a/netpbm-manual-pages.patch b/netpbm-manual-pages.patch
new file mode 100644
index 0000000..d52c8eb
--- /dev/null
+++ b/netpbm-manual-pages.patch
@@ -0,0 +1,1336 @@
+diff --git a/userguide/libnetpbm_ug.html b/userguide/libnetpbm_ug.html
+index 94d4fd4..bb1c77e 100644
+--- a/userguide/libnetpbm_ug.html
++++ b/userguide/libnetpbm_ug.html
+@@ -374,7 +374,7 @@ plain format.
+
Reference
+
+ The Libnetpbm Netpbm Image
+-Processing Manual describes the the libnetpbm functions for
++Processing Manual
describes the libnetpbm functions for
+ processing image data.
+
+ The Libnetpbm Utility Manual
+diff --git a/userguide/pamfunc.html b/userguide/pamfunc.html
+index d158393..e0fe96a 100644
+--- a/userguide/pamfunc.html
++++ b/userguide/pamfunc.html
+@@ -57,7 +57,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
+ maxval, i.e. normal interpretation of PAM tuples. But for the bit string
+-functions, the value is the the bit string whose value as a binary cipher is
++functions, the value is the bit string whose value as a binary cipher is
+ the sample value, and the maxval indicates the width of the bit string.
+
+
Arithmetic functions
+diff --git a/userguide/pbmtog3.html b/userguide/pbmtog3.html
+index ee2bd6b..3b23517 100644
+--- a/userguide/pbmtog3.html
++++ b/userguide/pbmtog3.html
+@@ -77,7 +77,7 @@ You cannot specify both.
+ HISTORY
+
+ Before Netpbm 10.79 (June 2017), there was a different program by the same
+-name in Netpbm, which was written by by Paul Haeberli
++name in Netpbm, which was written by Paul Haeberli
+ <paul@manray.sgi.com> in 1989
+ and then modified extensively by others.
+
+diff --git a/userguide/ppmtompeg.html b/userguide/ppmtompeg.html
+deleted file mode 100644
+index a1ce767..0000000
+--- a/userguide/ppmtompeg.html
++++ /dev/null
+@@ -1,1291 +0,0 @@
+-
+-
+-
+-Ppmtompeg User Manual
+-
+-
+-Ppmtompeg
+-Updated: 23 July 2006
+-
+-Table Of Contents
+-
+-NAME
+-ppmtompeg - encode an MPEG-1 bitstream
+-
+-SYNOPSIS
+-
+-ppmtompeg
+-[options]
+-parameter-file
+-
+-DESCRIPTION
+-
+-This program is part of Netpbm.
+-
+-
ppmtompeg produces an MPEG-1 video stream. MPEG-1 is the
+-first great video compression method, and is what is used in Video CDs
+-(VCD). ppmtompeg originated in the year 1995. DVD uses a more
+-advanced method, MPEG-2. There is an even newer method called MPEG-4
+-which is also called Divx. I don't know where one finds that used.
+-
+-
There's technically a difference between a compression method for
+-video and an actual file (stream) format for a movie, and I don't know
+-if it can be validly said that the format of the stream
+-ppmtompeg produces is MPEG-1.
+-
+-
Mencoder from the Mplayer
+-package is probably superior for most video format generation
+-needs, if for no other reason than that it is more popular.
+-
+-
The programming library PM2V
+-generates MPEG-2 streams.
+-
+-
Use Mplayer (not part of Netpbm)
+-to do the reverse conversion: to create a series of PNM files from an MPEG
+-stream.
+-
+-
param_file is a parameter file which includes a list of
+-input files and other parameters. The file is described in detail
+-below.
+-
+-
To understand this program, you need to understand something about
+-the complex MPEG-1 format. One source of information about this
+-standard format is the section Introduction to MPEG in the Compression FAQ.
+-
+-
OPTIONS
+-
+-The -gop, -combine_gops, -frames, and
+--combine_frames options are all mutually exclusive.
+-
+-
+-- -stat stat_file
+-
+-
- This option causes ppmtompeg to append the statistics that
+-it write to Standard Output to the file stat_file as well. The
+-statistics use the following abbreviations: bits per block (bpb), bits
+-per frame (bpf), seconds per frame (spf), and bits per second (bps).
+-
+-
These statistics include how many I, P, and B frames there were,
+-and information about compression and quality.
+-
+-
+-
- -quiet num_seconds
+-
+-
- causes ppmtompeg not to report remaining time more often
+-than every num_seconds seconds (unless the time estimate rises,
+-which will happen near the beginning of the run). A negative value
+-tells ppmtompeg not to report at all. 0 is the default
+-(reports once after each frame). Note that the time remaining is an
+-estimate and does not take into account time to read in frames.
+-
+-
- -realquiet
- causes ppmtompeg to run silently,
+-with the only screen output being errors. Particularly useful when
+-reading input from stdin.
+-
+-
-
+--no_frame_summary
+-
+-
- This option prevents ppmtompeg from printing a summary
+-line for each frame
+-
+-
- -float_dct
+-
+-
- forces ppmtompeg to use a more accurate, yet more
+-computationally expensive version of the DCT.
+-
+-
- -gop gop_num
+-
-
+-causes ppmtompeg to encode only the numbered GOP (first GOP is 0). The
+-parameter file is the same as for normal usage. The output file will be
+-the normal output file with the suffix .gop.gop_num.
+-ppmtompeg does not output any sequence information.
+-
+-
- -combine_gops
+-
+-
- causes ppmtompeg simply to combine some GOP files into a
+-single MPEG output stream. ppmtompeg inserts a sequence header
+-and trailer. In this case, the parameter file needs only to contain
+-the SIZE value, an output file, and perhaps a list of input GOP
+-files (see below).
+-
+-If you don't supply a list of input GOP files is used, then
+-ppmtompeg assumes you're using the same parameter file you used
+-when you created the input (with the -gop option) and
+-calculates the corresponding gop filenames itself. If this is not the
+-case, you can specify input GOP files in the same manner as normal
+-input files -- except instead of using INPUT_DIR, INPUT, and
+-END_INPUT, use GOP_INPUT_DIR, GOP_INPUT, and GOP_END_INPUT. If no
+-input GOP files are specified, then the default is to use the output
+-file name with suffix .gop.gop_num, with gop_num
+-starting from 0, as the input files.
+-
+-
Thus, unless you're mixing and matching GOP files from different
+-sources, you can simply use the same parameter file for creating the
+-GOP files (-gop) and for later turning them into an MPEG stream
+-(-combine_gops).
+-
+-
+-
- -frames first_frame last_frame
+-
+-
- This option causes ppmtompeg to encode only the frames numbered
+-first_frame to last_frame, inclusive. The parameter
+-file is the same as for normal usage. The output will be placed in
+-separate files, one per frame, with the file names being the normal
+-output file name with the suffix .frame.frame_num. No
+-GOP header information is output. (Thus, the parameter file need not
+-include the GOP_SIZE value)
+-
+-
Use ppmtompeg -combine_frames to combine these frames later into
+-an MPEG stream.
+-
+-
+-
- -combine_frames
+-
+-
- This option causes ppmtompeg simply to combine some
+-individual MPEG frames (such as you might have created with an earlier
+-run of ppmtompeg -frames) into a single MPEG stream. Sequence
+-and GOP headers are inserted appropriately. In this case, the
+-parameter file needs to contain only the SIZE value, the GOP_SIZE
+-value, an output file, and perhaps a list of frame files (see below).
+-
+-
The parameter file may specify input frame files in the same manner
+-as normal input files -- except instead of using INPUT_DIR, INPUT, and
+-END_INPUT, use FRAME_INPUT_DIR, FRAME_INPUT, and FRAME_END_INPUT. If
+-no input frame files are specified, then the default is to use the
+-output file name with suffix .frame.frame_num, with
+-frame_num starting from 0, as the input files.
+-
+-
+-
+-
- -nice
+-
+-
- This option causes ppmtompeg to run any remote processes
+-"nicely," i.e. at low priority. (This is relevant only if you are
+-running ppmtompeg in parallel mode. Otherwise, there are no
+-remote processes). See 'man nice.'
+-
+-
- -max_machines num_machines
+-
+-
- This option causes ppmtompeg to use no more than
+-num_machines machines as slaves for use in parallel encoding.
+-
+-
- -snr
+-
+-
- This option causes ppmtompeg to include the signal-to-noise
+-ratio in the reported statistics. Prints SNR (Y U V) and peak SNR (Y
+-U V) for each frame. In summary, prints averages of luminance only
+-(Y). SNR is defined as 10*log(variance of original/variance of
+-error). Peak SNR is defined as 20*log(255/RMSE). Note that
+-ppmtompeg runs a little slower when you use this option.
+-
+-
- -mse
+-
+-
- This option causes ppmtompeg to report the mean squared
+-error per block. It also automatically reports the quality of the
+-images, so there is no need to specify -snr then.
+-
+-
- -bit_rate_info rate_file
+-
+-
- This option makes ppmtompeg write bit rate information
+-into the file rate_file. Bit rate information is bits per frame, and
+-also bits per I-frame-to-I-frame.
+-
+-
- -mv_histogram
+-
+-
- This option causes ppmtompeg to print a histogram of the
+-motion vectors as part of statistics. There are three histograms --
+-one for P frame, one for forward B frame, and one for backward B frame
+-motion vectors.
+-
+-
The output is in the form of a matrix, each entry corresponding to one
+-motion vector in the search window. The center of the matrix
+-represents (0,0) motion vectors.
+-
+-
- -debug_sockets
+-
+-
- This option causes ppmtompeg to print to Standard Output
+-messages that narrate the communication between the machines when you run
+-ppmtompeg in parallel mode.
+-
+-
- -debug_machines
+-
+-
- This option causes ppmtompeg to print to Standard Output
+-messages that narrate the progress of the conversion on the various
+-machines when you run ppmtompeg in parallel
+-mode.
+-
+-
+-
+-PARAMETER FILE
+-
+-The parameter file must contain the following
+-lines (except when using the -combine_gops or -combine_frames
+-options):
+-
+-
+-
+-- PATTERN pattern
+-
+-
- This statement specifies the pattern (sequence) of I frames, P frames,
+-and B frames. pattern is just a sequence of the letters I, P, and
+-B with nothing between. Example:
+-
+-
+- PATTERN IBBPBBPBBPBBPBB
+-
+-
+-See I Frames, P Frames, B Frames.
+-
+-
- OUTPUT output file
+-
- This names the file where the output MPEG stream goes.
+-
+-
- INPUT_DIR directory
+-
+-
- This statement tells where the input images (frames) come from.
+-If each frame is in a separate file, directory is the directory
+-where they all are. You may use . to refer to the current
+-directory. A null directory refers to the root directory of the
+-system file tree.
+-
+-
To have ppmtompeg read all the frames serially from Standard
+-Input, specify
+-
+- INPUT_DIR stdin
+-
+-
+- - INPUT
+-
-
+-This line must be followed by a list of the input files (in display order)
+-and then the line END_INPUT.
+-
+-
There are three types of lines between INPUT and END_INPUT. First,
+-a line may simply be the name of an input file. Second, the line
+-may be of the form single_star_expr
+-[x-y].
+-single_star_expr can have a single * in it. It is
+-replaced by all the numbers between x and y inclusive. So, for
+-example, the line tennis*.ppm [12-15] refers to the files
+-tennis12.ppm, tennis13.ppm, tennis14.ppm, tennis15.ppm.
+-
+-
Uniform zero-padding occurs, as well. For example, the line
+-football.*.ppm [001-130] refers to the files football.001.ppm,
+-football.002.ppm, ..., football.009.ppm, football.010.ppm, ...,
+-football.130.ppm.
+-
+-
The third type of line is: single_star_expr
+-[x-y+s], where the
+-line is treated exactly as above, except that we skip by s. Thus, the
+-line football.*.ppm [001-130+4] refers to the files
+-football.001.ppm, football.005.ppm, football.009.ppm,
+-football.013.ppm, etc.
+-
+-
Furthermore, a line may specify a shell command to execute to
+-generate lines to be interpreted as described above, as if those lines
+-were in the parameter file instead. Use back ticks, like in the
+-Bourne Shell, like this:
+-
+-
+- `cat myfilelist`
+-
+-
+-
+-If input is from Standard Input (per the INPUT_DIR statement),
+-ppmtompeg ignores the INPUT/END_INPUT block, but
+-it still must be present.
+-
+-
- BASE_FILE_FORMAT {PPM | PNM | YUV |
+- JPEG | JMOVIE}
+-
+-
- ppmtompeg must convert all input files to one of the
+-following formats as a first step of processing: PNM, YUV, JPEG(v4),
+-or JMOVIE. (The conversion may be trivial if your input files are
+-already in one of these formats). This line specifies which of the
+-four formats. PPM is actually a subset of PNM. The separate
+-specification is allowed for backward compatibility. Use PNM instead
+-of PPM in new applications.
+-
+-
- INPUT_CONVERT conversion_command
+-
+-
- You must specify how to convert a file to the base file format.
+-If no conversion is necessary, then you would just say:
+-
+-
+- INPUT_CONVERT *
+-
+-
+-Otherwise, conversion_command is a shell command that causes
+-an image in the format your specified with BASE_FILE_FORMAT to
+-be written to Standard Output. ppmtompeg executes the command
+-once for each line between INPUT and END_INPUT (which is
+-normally, but not necessarily, a file name). In the conversion
+-command, ppmtompeg replaces each '*' with the contents of that
+-line.
+-
+- If you had a bunch of gif files, you might say:
+-
+- INPUT_CONVERT giftopnm *
+-
+-
+- If you have a bunch of separate a.Y, a.U, and a.V files (where
+- the U and V have already been subsampled), then you might say:
+-
+-
+- INPUT_CONVERT cat *.Y *.U *.V
+-
+-
+-Input conversion is not allowed with input from stdin, so use
+-
+-
+- INPUT_CONVERT *
+-
+-
+-as described above.
+-
+- - SIZE widthxheight
+-
+-
-
+-
+-
width and height are the width and height of each
+-frame in pixels.
+-
+-
When ppmtompeg can get this information from the input image
+-files, it ignores the SIZE parameter and you may omit it.
+-
+-
When the image files are in YUV format, the files don't contain
+-dimension information, so SIZE is required.
+-
+-
When ppmtompeg is running in parallel mode, not all of the
+-processes in the network have access to the image files, so
+-SIZE is required and must give the same dimensions as the
+-input image files.
+-
+-
- YUV_SIZE widthxheight
+-
+-
- This is an obsolete synonym of SIZE.
+-
+-
- YUV_FORMAT {ABEKAS | PHILLIPS | UCB |
+- EYUV | pattern}
+-
+-
- This is meaningful only when BASE_FILE_FORMAT specifies
+-YUV format, and then it is required. It specifies the sub-format of
+-the YUV class.
+-
+-
+-
- GOP_SIZE n
+-
+-
- n is the number of frames in a Group of Pictures. Except that
+-because a GOP must start with an I frame, ppmtompeg makes a GOP as
+-much longer than n as it has to to make the next GOP start with an
+-I frame.
+-
+-
Normally, it makes sense to make your GOP size a multiple of your
+-pattern length (the latter is determined by the PATTERN parameter file
+-statement).
+-
+-
See Group Of Pictures.
+-
+-
- SLICES_PER_FRAME n
+-
- n is roughly the number of slices per frame. Note, at
+-least one MPEG player may complain if slices do not start at the left
+-side of an image. To ensure this does not happen, make sure the
+-number of rows is divisible by SLICES_PER_FRAME.
+-
+-
- PIXEL {FULL | HALF}
+-
+-
- use half-pixel motion vectors, or just full-pixel ones It is
+-usually important that you use half-pixel motion vectors, because it
+-results in both better quality and better compression.
+-
+-
+-
- RANGE n
+-
- Use a search range of n pixels in each of the four directions
+-from a subject pixel. (So the search window is a square n*2 pixels
+-on a side).
+-
+-
- PSEARCH_ALG {EXHAUSTIVE | TWOLEVEL |
+- SUBSAMPLE | LOGARITHMIC}
+-
+-
- This statement tells ppmtompeg what kind of search
+- technique (algorithm) to use for P frames. You select the desired
+- combination of speed and compression. EXHAUSTIVE gives the
+- best compression, but LOGARITHMIC is the fastest.
+- TWOLEVEL is an exhaustive full-pixel search, followed by a
+- local half- pixel search around the best full-pixel vector (the
+- PIXEL option is ignored for this search technique).
+-
+-
- BSEARCH_ALG {SIMPLE | CROSS2 | EXHAUSTIVE}
+-
+-
- This statement tells ppmtompeg what kind of search
+- technique (algorithm) to use for B frames. SIMPLE means
+- find best forward and backward vectors, then interpolate.
+- CROSS2 means find those two vectors, then see what backward
+- vector best matches the best forward vector, and vice versa.
+- EXHAUSTIVE does an n-squared search and is
+- extremely slow in relation to the others (CROSS2
+- is about half as fast as SIMPLE).
+-
+-
- IQSCALE n
+-
- Use n as the qscale for I frames.
+- See Qscale.
+-
+-
- PQSCALE n
+-
- Use n as the qscale for P frames.
+- See Qscale.
+-
+-
- BQSCALE n
+-
- Use n as the qscale for B frames.
+- See Qscale.
+-
+-
- REFERENCE_FRAME {ORIGINAL | DECODED}
- This
+-statement determines whether ppmtompeg uses the original images
+-or the decoded images when computing motion vectors. Using decoded
+-images is more accurate and should increase the playback quality of
+-the output, but it makes the encoding take longer and seems to give
+-worse compression. It also causes some complications with parallel
+-encoding. (see the section on parallel encoding). One thing you can
+-do as a trade-off is select ORIGINAL here, and lower the
+-qscale (see QSCALE if the quality is not good enough.
+-
+-
+- Original or Decoded? (Normalized)
+-
+-
+-
+- Reference
+- Compression
+- Speed
+- Quality I
+- Quality P
+- Quality B
+-
+-
+- Decoded
+- 1000
+- 1000
+- 1000
+- 969
+- 919
+-
+-
+- Original
+- 885
+- 1373
+- 1000
+- 912
+- 884
+-
+-
+-
+-
+-
+-
+-
+-The following lines are optional:
+-
+-
+-
+-- FORCE_ENCODE_LAST_FRAME
+-
+-
- This statement is obsolete. It does nothing.
+-
+-
Before Netpbm 10.26 (January 2005), ppmtompeg would drop
+-trailing B frames from your movie, since a movie can't end with a B
+-frame. (See I Frames, P Frames, B Frames.
+-You would have to specify FORCE_ENCODE_LAST_FRAME to stop
+-that from happening and get the same function that ppmtompeg
+-has today.
+-
+-
+-
- NIQTABLE
+-
+-
- This statement specifies a custom non-intra quantization table.
+-If you don't specify this statement, ppmtompeg uses a default
+-non-intra quantization table.
+-
+-
+-The 8 lines immediately following NIQTABLE specify the quantization
+-table. Each line defines a table row and consists of 8 integers,
+-whitespace-delimited, which define the table columns.
+-
+-
- IQTABLE
+-
+-
- This is analogous to NIQTABLE, but for the intra quantization table.
+-
+-
- ASPECT_RATIO ratio
+-
+-
- This statement specifies the aspect ratio for ppmtompeg to
+-specify in the MPEG output. I'm not sure what this is used for.
+-
+-
ratio must be 1.0, 0.6735, 0.7031, 0.7615, 0.8055, 0.8437,
+-0.8935, 0.9157, 0.9815, 1.0255, 1.0695, 1.0950, 1.1575, or 1.2015.
+-
+-
- FRAME_RATE rate
+-
- This specifies the frame rate for ppmtompeg to specify in the
+-MPEG output. Some players use this value to determine the playback rate.
+-
+-
rate must be 23.976, 24, 25, 29.97, 30, 50, 59.94, or 60.
+-
+-
- BIT_RATE rate
+-
- This specifies the bit rate for Constant Bit Rate (CBR) encoding.
+-
+-
rate must be an integer.
+-
+-
- BUFFER_SIZE size
+-
+-
- This specifies the value
+-ppmtompeg is to specify in the MPEG output for the Video
+-Buffering Verifier (VBV) buffer size needed to decode the sequence.
+-
+-
A Video Verifying Buffer is a buffer in which a decoder keeps the
+-decoded bits in order to match the uneven speed of the decoding with
+-the required constant playback speed.
+-
+-
As ppmtompeg encodes the image, it simulates the decoding
+-process in terms of how many bits would be in the VBV as each frame gets
+-decoded, assuming a VBV of the size you indicate.
+-
+-
If you specify the WARN_VBV_UNDERFLOW statement,
+-ppmtompeg issues a warning each time the simulation underflows
+-the buffer, which suggests that an underflow would occur on playback,
+-which suggests the buffer is too small.
+-
+-
If you specify the WARN_VBV_OVERFLOW statement,
+-ppmtompeg issues a warning each time the simulation overflows
+-the buffer, which suggests that an overflow would occur on playback,
+-which suggests the buffer is too small.
+-
+-
- WARN_VBV_UNDERFLOW
+-
- WARN_VBV_OVERFLOW
+-
+-
- See BUFFER_SIZE.
+-
+-
These options were new in Netpbm 10.26 (January 2005). Before that,
+-ppmtompeg issued the warnings always.
+-
+-
+-
+-
+-The following statements apply only to parallel operation:
+-
+-
+-
+-- PARALLEL
+-
+-
- This statement, paired with END PARALLEL, is what causes
+-ppmtompeg to operate in parallel mode. See Parallel Operation.
+-
+-
- END PARALLEL
+-
+-
- This goes with PARALLEL.
+-
+-
- PARALLEL_TEST_FRAMES n
+-
+-
- The master starts off by measuring each slave's speed. It does
+-this by giving each slave n frames to encode and noting how
+-long the slave takes to finish. These are not just test frames,
+-though -- they're real frames and the results become part of the
+-output.
+-ppmtompeg is old and measures time in undivided seconds, so
+-to get useful timings, specify enough frames that it will take at
+-least 5 seconds to process them. The default is 10.
+-
+-
If you specify FORCE_I_ALIGN, ppmtompeg will increase
+-the test frames value enough to maintain the alignment.
+-
+-
If there aren't enough frames for every slave to have the indicated
+-number of test frames, ppmtompeg will give some slaves fewer.
+-
+-
+-
- PARALLEL_TIME_CHUNKS t
+-
+-
- When you specify this statement, the master attempts to feed work
+-to the slaves in chunks that take t seconds to process. It uses
+-the speed measurement it made when it started up (see PARALLEL_TEST_FRAMES)
+-to decide how many frames to put in the chunk. This statement obviously
+-doesn't affect the first batch of work sent to each slave, which is the
+-one used to measure the slave's speed.
+-
+-
Smaller values of t increase communication, but improve load
+-balancing. The default is 30 seconds.
+-
+-
You may specify only one of PARALLEL_TIME_CHUNKS, PARALLEL_CHUNK_TAPER,
+-and PARALLEL_PERFECT. PARALLEL_CHUNK_TAPER is usually best.
+-
+-
- PARALLEL_CHUNK_TAPER
+-
+-
- When you specify this statement, the master distributes work like
+-with PARALLEL_TIME_CHUNKS, except that the master chooses the number
+-of seconds for the chunks. It starts with a large number and, as it
+-gets closer to finishing the job, reduces it. That way, it reduces
+-scheduling overhead when precise scheduling isn't helpful, but still
+-prevents a slave from finishing early after all the work has already
+-been handed out to the other slaves, and then sitting idle while
+-there's still work to do.
+-
+-
You may specify only one of PARALLEL_TIME_CHUNKS, PARALLEL_CHUNK_TAPER,
+-and PARALLEL_PERFECT. PARALLEL_CHUNK_TAPER is usually best.
+-
+-
+-
- PARALLEL_PERFECT
+-
+-
- If this statement is present, ppmtompeg schedules on the
+-assumption that each machine is about the same speed. The master will
+-simply divide up the frames evenly between the slaves -- each
+-slave gets the same number of frames. If some slaves are faster than
+-others, they will finish first and remain idle while the slower slaves
+-continue.
+-
+-
This has the advantage of minimal scheduling overhead. Where slaves
+-have different speeds, though, it makes inefficient use of the fast
+-ones. Where slaves are the same speed, it also has the disadvantage
+-that they all finish at the same time and feed their output to the
+-single Combine Server in a burst, which makes less efficient use of
+-the Combine Server and thus can increase the total elapsed time.
+-
+-
You may specify only one of PARALLEL_TIME_CHUNKS, PARALLEL_CHUNK_TAPER,
+-and PARALLEL_PERFECT. PARALLEL_CHUNK_TAPER is usually best.
+-
+-
- RSH remote_shell_command
+-
+-
- ppmtompeg executes the shell command
+-remote_shell_command to start a process on another machine.
+-The default command is rsh, and whatever command you specify
+-must have compatible semantics. ssh is usually compatible.
+-The command ppmtompeg uses is one like this:
+-ssh remote.host.com -l username shellcommand.
+-
+-
Be sure to set up .rhosts files or SSH key authorizations
+-where needed. Otherwise, you'll have to type in passwords.
+-
+-
On some HP machines, rsh is the restricted shell, and you want
+-to specify remsh.
+-
+-
- FORCE_I_ALIGN
+-
+-
- This statement forces each slave to encode a chunk of frames which
+-is a multiple of the pattern length (see PATTERN). Since the
+-first frame in any pattern is an I frame, this forces each chunk
+-encoded by a slave to begin with an I frame.
+-
+-
This document used to say there was an argument to
+-FORCE_I_ALIGN which was the number of frames ppmtompeg
+-would use (and was required to be a multiple of the pattern length).
+-But ppmtompeg has apparently always ignored that argument, and
+-it does now.
+-
+-
- KEEP_TEMP_FILES
+-
+-
- This statement causes ppmtompeg not to delete the temporary
+-files it uses to transmit encoded frames to the combine server. This
+-means you will be left with a file for each frame, the same as you
+-would get with the -frames option.
+-
+-
This is mostly useful for debugging.
+-
+-
This works only if you're using a shared filesystem to communicate
+-between the servers.
+-
+-
This option was new in Netpbm 10.26 (January 2005).
+-
+-
+-
+-
+-Parameter File Notes
+-
+- If you use the -combine_gops option, then you need to specify
+-only the SIZE and OUTPUT values in the parameter file. In
+-addition, the parameter file may specify input GOP files in the same
+-manner as normal input files -- except instead of using INPUT_DIR,
+-INPUT, and END_INPUT, use GOP_INPUT_DIR, GOP_INPUT, and GOP_END_INPUT.
+-If you specify no input GOP files, then ppmtompeg uses by default the
+-output file name with suffix .gop.gop_num, with gop_num
+-starting from 0, as the input files.
+-
+-
If you use the -combine_frames option, then you need to
+-specify only the SIZE, GOP_SIZE, and OUTPUT values in the
+-parameter file. In addition, the parameter file may specify input
+-frame files in the same manner as normal input files -- except instead
+-of using INPUT_DIR, INPUT, and END_INPUT, use FRAME_INPUT_DIR,
+-FRAME_INPUT, and FRAME_END_INPUT. If no input frame files are
+-specified, then the default is to use the output file name with suffix
+-.frame.frame_num, with frame_num starting from 0,
+-as the input files.
+-
+-
Any number of spaces and tabs may come between each option and value. Lines
+-beginning with # are ignored. Any other lines are ignored except for
+-those between INPUT and END_INPUT. This allows you to use the same
+-parameter file for normal usage and for -combine_gops and
+--combine_frames.
+-
+-
The file format is case-sensitive so all keywords should be in
+-upper case.
+-
+-
The statements may appear in any order, except that the order within
+-a block statement (such as INPUT ... END INPUT) is significant.
+-
+-
ppmtompeg is prepared to handle up to 16 B frames between
+-reference frames when encoding with input from stdin. (To build a
+-modified ppmtompeg with a higher limit, change the constant
+-B_FRAME_RUN in frame.c and recompile).
+-
+-
GENERAL USAGE INFORMATION
+-
+-Qscale
+-
+-The quantization scale values (qscale) give a trade-off between
+-quality and compression. Using different Qscale values has very little
+-effect on speed. The qscale values can be set separately for I, P, and
+-B frames.
+-
+-
You select the qscale values with the IQSCALE,
+-PQSCALE, and BSCALE parameter file statements.
+-
+-
A qscale value is an integer from 1 to 31. Larger numbers give
+-better compression, but worse quality. In the following, the quality
+-numbers are peak signal-to-noise ratio, defined as:
+-
+-where MSE is the mean squared error.
+-
+-
+-
Flower garden tests:
+-
+-
+- Qscale vs Quality
+-
+-
+-
+- Qscale
+- I Frames
+- P Frames
+- B Frames
+-
+-
+- 1
+- 43.2
+- 46.3
+- 46.5
+-
+-
+- 6
+- 32.6
+- 34.6
+- 34.3
+-
+-
+- 11
+- 28.6
+- 29.5
+- 30.0
+-
+-
+- 16
+- 26.3
+- 26.8
+- 28.6
+-
+-
+- 21
+- 24.7
+- 25.0
+- 27.9
+-
+-
+- 26
+- 23.5
+- 23.9
+- 27.5
+-
+-
+- 31
+- 22.6
+- 23.0
+- 27.3
+-
+-
+-
+-
+- Qscale vs Compression
+-
+-
+-
+- Qscale
+- I Frames
+- P Frames
+- B Frames
+-
+-
+- 1
+- 2
+- 2
+- 2
+-
+-
+- 6
+- 7
+- 10
+- 15
+-
+-
+- 11
+- 11
+- 18
+- 43
+-
+-
+- 16
+- 15
+- 29
+- 97
+-
+-
+- 21
+- 19
+- 41
+- 173
+-
+-
+- 26
+- 24
+- 56
+- 256
+-
+-
+- 31
+- 28
+- 73
+- 330
+-
+-
+-
+-
+-Search Techniques
+-
+-There are several different motion vector search techniques
+-available. There are different techniques available for P frame
+-search and B frame search. Using different search techniques present
+-little difference in quality, but a large difference in compression
+-and speed.
+-
+-
There are 4 types of P frame search: Exhaustive, TwoLevel,
+-SubSample, and Logarithmic.
+-
+-
There are 3 types of B frame search: Exhaustive, Cross2, and
+-Simple.
+-
+-The recommended search techniques are TwoLevel and Logarithmic for
+-P frame search, and Cross2 and Simple for B frame search. Here are
+-some numbers comparing the different search methods:
+-
+-
+- P frame Motion Vector Search (Normalized)
+-
+-
+-
+- Technique
+- Compression1
+- Speed 2
+- Quality 3
+-
+-
+- Exhaustive
+- 1000
+- 1000
+- 1000
+-
+-
+- SubSample
+- 1008
+- 2456
+- 1000
+-
+-
+- TwoLevel
+- 1009
+- 3237
+- 1000
+-
+-
+- Logarithmic
+- 1085
+- 8229
+- 998
+-
+-
+-
+-
+- B frame Motion Vector Search (Normalized)
+-
+-
+-
+- Technique
+- Compression1
+- Speed2
+- Quality3
+-
+-
+- Exhaustive
+- 1000
+- 1000
+- 1000
+-
+-
+- Cross2
+- 975
+- 1000
+- 996
+-
+-
+- Simple
+- 938
+- 1765
+- 991
+-
+-
+-
+- 1Smaller numbers are better
+-compression.
+-
+- 2Larger numbers mean faster
+-execution.
+-
+- 3Larger numbers mean better quality.
+-
+-For some reason, Simple seems to give better compression, but it
+-depends on the image sequence.
+-
+-
Select the search techniques with the PSEARCH_ALG and
+-BSEARCH_ALG parameter file statements.
+-
+-
+-
+-
Group Of Pictures (GOP)
+-
+-A Group of Pictures (GOP) is a roughly independently decodable
+-sequence of frames. An MPEG video stream is made of one or more
+-GOP's. You may specify how many frames should be in each GOP with the
+-GOP_SIZE parameter file statement. A GOP always starts with an
+-I frame.
+-
+-
Instead of encoding an entire sequence, you can encode a single
+-GOP. To do this, use the -gop command option. You can later
+-join the resulting GOP files at any time by running ppmtompeg
+-with the -combine_gops command option.
+-
+-
+-
Slices
+-
+-A slice is an independently decodable unit in a frame. It can be
+-as small as one macroblock, or it can be as big as the entire frame.
+-Barring transmission error, adding slices does not change quality or
+-speed; the only effect is slightly worse compression. More slices are
+-used for noisy transmission so that errors are more recoverable. Since
+-usually errors are not such a problem, we usually just use one slice
+-per frame.
+-
+-
Control the slice size with the SLICES_PER_FRAME parameter
+-file statement.
+-
+-
Some MPEG playback systems require that each slice consist of whole
+-rows of macroblocks. If you are encoding for this kind of player, if
+-the height of the image is H pixels, then you should set the
+-SLICES_PER_FRAME to some number which divides H/16. For example, if
+-the image is 240 pixels (15 macroblocks) high, then you should use
+-only 15, 5, 3, or 1 slices per frame.
+-
+-
Note: these MPEG playback systems are really wrong, since the MPEG
+-standard says this doesn't have to be so.
+-
+-
+-
+-
Search Window
+-
+-The search window is the window in which ppmtompeg searches
+-for motion vectors. The window is a square. You can specify the size
+-of the square, and whether to allow half-pixel motion vectors or not,
+-with the RANGE and PIXEL parameter file statements.
+-
+-
I Frames, P Frames, B Frames
+-
+-In MPEG-1, a movie is represented as a sequence of MPEG frames,
+-each of which is an I Frame, a P Frame, or a B Frame. Each represents
+-an actual frame of the movie (don't get confused by the dual use of
+-the word "frame." A movie frame is a graphical image. An MPEG frame
+-is a set of data that describes a movie frame).
+-
+-
An I frame ("intra" frame) describes a movie frame in isolation --
+-without respect to any other frame in the movie. A P frame
+-("predictive" frame) describes a movie frame by describing how it
+-differs from the movie frame described by the latest preceding I or
+-P frame. A B frame ("bidirectional" frame) describes a movie frame by
+-describing how it differs from the movie frames described by the
+-nearest I or P frame before and after it.
+-
+-
Note that the first frame of a movie must be described by an I
+-frame (because there is no previous movie frame) and the last movie
+-frame must be described by an I or P frame (because there is no
+-subsequent movie frame).
+-
+-
Beyond that, you can choose which frames are represented by which
+-types. You specify a pattern, such as IBPBP and ppmtompeg
+-simply repeats it over and over throughout the movie. The pattern
+-affects speed, quality, and stream size. Here is a chart which shows
+-some of the trade-offs:
+-
+-
+- Comparison of I/P/B Frames (Normalized)
+-
+-
+-
+- Frame Type
+- Size
+- Speed
+- Quality
+-
+-
+- I frames
+- 1000
+- 1000
+- 1000
+-
+-
+- P frames
+- 409
+- 609
+- 969
+-
+-
+- B frames
+- 72
+- 260
+- 919
+-
+-
+-
+-(this is with constant qscale)
+-
+-A standard sequence is IBBPBBPBBPBBPBB.
+-
+-
Select the sequence with the PATTERN parameter file statement.
+-
+-
Since the last MPEG frame cannot be a B frame (see above), if the
+-pattern you specify indicates a B frame for the last movie frame of
+-the movie, ppmtompeg makes it an I frame instead.
+-
+-
Before Netpbm 10.26 (January 2005), ppmtompeg instead drops
+-the trailing B frames by default, and you need the
+-FORCE_ENCODE_LAST_FRAME parameter file statement to make it do
+-this.
+-
+-
The MPEG frames don't appear in the MPEG-1 stream in the same order that
+-the corresponding movie frames appear in the movie -- the B frames come after
+-the I and P frames on which they are based. For example, if the movie is
+-4 frames that you will represent with the pattern IBBP, the MPEG-1 stream
+-will start with an I frame describing movie frame 0. The next frame in
+-the MPEG-1 stream is a P frame describing movie frame 3. The last two
+-frames in the MPEG-1 stream are B frames describing movie frames 1 and 2,
+-respectively.
+-
+-
+-
Specifying Input and Output Files
+-
+-Specify the input frame images with the INPUT_DIR,
+-INPUT, END_INPUT, BASE_FILE_FORMAT,
+-SIZE, YUV_FORMAT and INPUT_CONVERT parameter
+-file statements.
+-
+-
Specify the output file with the OUTPUT parameter file statement.
+-
+-
+-
Statistics
+-
+-ppmtompeg can generate a variety of statistics about the
+-encoding. See the -stat, -snr, -mv_histogram,
+--quiet, -no_frame_summary, and -bit_rate_info
+-options.
+-
+-
+-
PARALLEL OPERATION
+-
+-You can run ppmtompeg on multiple machines at once, encoding
+-the same MPEG stream. When you do, the machines are used as shown in
+-the following diagram. We call this "parallel mode."
+-
+-
+-
+-
To do parallel processing, put the statement
+-
+-
+- PARALLEL
+-
+-
+-in the parameter file, followed by a listing of the machines, one
+-machine per line, then
+-
+-
+- END_PARALLEL
+-
+-
+-Each of the machine lines must be in one of two forms. If the machine
+-has filesystem access to the input files, then the line is:
+-
+-
+-machine user executable
+-
+-
The executable is normally ppmtompeg (you may need to give
+-the complete path if you've built for different architectures). If
+-the machine does not have filesystem access to the input files, the line
+-is:
+-
+-
REMOTE machine user executable
+-parameter file
+-
+-
The -max_machines command option limits the number of
+-machines ppmtompeg will use. If you specify more machines in
+-the parameter file than -max_machines allows, ppmtompeg
+-uses only the machines listed first. This is handy if you want to
+-experiment with different amounts of parallelism.
+-
+-
In general, you should use full path file names when describing
+-executables and parameter files. This includes the parameter
+-file argument on the original invocation of ppmtompeg.
+-
+-
All file names must be the same on all systems (so if e.g. you're
+-using an NFS filesystem, you must make sure it is mounted at the same
+-mountpoint on all systems).
+-
+-
Because not all of the processes involved in parallel operation
+-have easy access to the input files, you must specify the SIZE
+-parameter file statement when you do parallel operation.
+-
+-
The machine on which you originally invoke ppmtompeg is the
+-master machine. It hosts a "combine server,", a
+-"decode server," and a number of "i/o servers,"
+-all as separate processes. The other machines in the network (listed
+-in the parameter file) are slave machines. Each hosts a single
+-process that continuously requests work from the master and does it.
+-The slave process does the computation to encode MPEG frames. It
+-processes frames in batches identified by the master.
+-
+-
The master uses a remote shell command to start a process on a
+-slave machine. By default, it uses an rsh shell command to do
+-this. But use the RSH parameter file statement to control
+-this. The shell command the master executes remotely is
+-ppmtompeg, but with options to indicate that it is to perform
+-slave functions.
+-
+-
The various machines talk to each other over TCP connections. Each
+-machine finds and binds to a free TCP port number and tells its
+-partners the port number. These port numbers are at least 2048.
+-
+-
Use the PARALLEL_TEST_FRAMES, PARALLEL_TIME_CHUNKS, and
+-PARALLEL_PERFECT parameter file statements to control the way the
+-master divides up work among the slaves.
+-
+-
Use the -nice command option to cause all slave processes to run
+-"nicely," i.e. as low priority processes. That way, this substantial and
+-long-running CPU load will have minimal impact on other, possibly
+-interactive, users of the systems.
+-
+-
+-
SPEED
+-
+-Here is a look at ppmtompeg speed, in single-node (not parallel)
+-operation:
+-
+-
+- Compression Speed
+-
+-
+-
+- Machine Type
+- Macroblocks per second1
+-
+-
+- HP 9000/755
+- 280
+-
+-
+- DEC 3000/400
+- 247
+-
+-
+- HP 9000/750
+- 191
+-
+-
+- Sparc 10
+- 104
+-
+-
+- DEC 5000
+- 68
+-
+-
+-1A macroblock is a 16x16 pixel square
+-
+-The measurements in the table are with inputs and outputs via a
+-conventional locally attached filesystem. If you are using a network
+-filesystem over a single 10 MB/s Ethernet, that constrains your speed more
+-than your CPU speed. In that case, don't expect to get better than 4
+-or 5 frames per second no matter how fast your CPUs are.
+-
+-
Network speed is even more of a bottleneck when the slaves do not
+-have filesystem access to the input files -- i.e. you declare them
+-REMOTE.
+-
+-
Where I/O is the bottleneck, size of the input frames can make a big
+-difference. So YUV input is better than PPM, and JPEG is better than
+-both.
+-
+-
When you're first trying to get parallel mode working, be sure to
+-use the -debug_machines option so you can see what's going on.
+-Also, -debug_sockets can help you diagnose communication
+-problems.
+-
+-
+-
AUTHORS
+-
+-
+-
+-- Kevin Gong - University of California, Berkeley, keving@cs.berkeley.edu
+-
+-
- Ketan Patel - University of California, Berkeley, kpatel@cs.berkeley.edu
+-
+-
- Dan Wallach - University of California, Berkeley, dwallach@cs.berkeley.edu
+-
+-
- Darryl Brown - University of California, Berkeley, darryl@cs.berkeley.edu
+-
+-
- Eugene Hung - University of California, Berkeley, eyhung@cs.berkeley.edu
+-
+-
- Steve Smoot - University of California, Berkeley, smoot@cs.berkeley.edu
+-
+-
+-
+-
+-
+-Table Of Contents
+-
+-- SYNOPSIS
+-- DESCRIPTION
+-- OPTIONS
+-- PARAMETER FILE
+-- GENERAL USAGE INFORMATION
+-- PARALLEL OPERATION
+-- SPEED
+-- AUTHORS
+-
+-
+-
diff --git a/netpbm-pamtojpeg2k.patch b/netpbm-pamtojpeg2k.patch
index 8fbd899..7eeed54 100644
--- a/netpbm-pamtojpeg2k.patch
+++ b/netpbm-pamtojpeg2k.patch
@@ -1,7 +1,234 @@
-diff -up netpbm-10.47.12/converter/other/jpeg2000/pamtojpeg2k.c.pamtojpeg2kfix netpbm-10.47.12/converter/other/jpeg2000/pamtojpeg2k.c
---- netpbm-10.47.12/converter/other/jpeg2000/pamtojpeg2k.c.pamtojpeg2kfix 2010-04-27 15:47:10.000000000 +0200
-+++ netpbm-10.47.12/converter/other/jpeg2000/pamtojpeg2k.c 2010-05-03 15:37:49.934269588 +0200
-@@ -532,7 +532,5 @@ main(int argc, char **argv)
+diff --git a/converter/other/jpeg2000/pamtojpeg2k.c b/converter/other/jpeg2000/pamtojpeg2k.c
+index 4d73316..a53573f 100644
+--- a/converter/other/jpeg2000/pamtojpeg2k.c
++++ b/converter/other/jpeg2000/pamtojpeg2k.c
+@@ -98,7 +98,7 @@ parseCommandLine(int argc, char ** argv,
+ char * modeOpt;
+
+ unsigned int option_def_index;
+-
++
+ MALLOCARRAY_NOFAIL(option_def, 100);
+
+ option_def_index = 0; /* incremented by OPTENTRY */
+@@ -134,25 +134,25 @@ parseCommandLine(int argc, char ** argv,
+ &numrlvlsSpec, 0);
+ OPTENT3(0, "numgbits", OPT_UINT, &cmdlineP->numgbits,
+ &numgbitsSpec, 0);
+- OPTENT3(0, "nomct", OPT_FLAG, NULL,
++ OPTENT3(0, "nomct", OPT_FLAG, NULL,
+ &cmdlineP->nomct, 0);
+- OPTENT3(0, "sop", OPT_FLAG, NULL,
++ OPTENT3(0, "sop", OPT_FLAG, NULL,
+ &cmdlineP->sop, 0);
+- OPTENT3(0, "eph", OPT_FLAG, NULL,
++ OPTENT3(0, "eph", OPT_FLAG, NULL,
+ &cmdlineP->eph, 0);
+- OPTENT3(0, "lazy", OPT_FLAG, NULL,
++ OPTENT3(0, "lazy", OPT_FLAG, NULL,
+ &cmdlineP->lazy, 0);
+- OPTENT3(0, "termall", OPT_FLAG, NULL,
++ OPTENT3(0, "termall", OPT_FLAG, NULL,
+ &cmdlineP->termall, 0);
+- OPTENT3(0, "segsym", OPT_FLAG, NULL,
++ OPTENT3(0, "segsym", OPT_FLAG, NULL,
+ &cmdlineP->segsym, 0);
+- OPTENT3(0, "vcausal", OPT_FLAG, NULL,
++ OPTENT3(0, "vcausal", OPT_FLAG, NULL,
+ &cmdlineP->vcausal, 0);
+- OPTENT3(0, "pterm", OPT_FLAG, NULL,
++ OPTENT3(0, "pterm", OPT_FLAG, NULL,
+ &cmdlineP->pterm, 0);
+- OPTENT3(0, "resetprob", OPT_FLAG, NULL,
++ OPTENT3(0, "resetprob", OPT_FLAG, NULL,
+ &cmdlineP->resetprob, 0);
+- OPTENT3(0, "verbose", OPT_FLAG, NULL,
++ OPTENT3(0, "verbose", OPT_FLAG, NULL,
+ &cmdlineP->verbose, 0);
+ OPTENT3(0, "debuglevel", OPT_UINT, &cmdlineP->debuglevel,
+ &debuglevelSpec, 0);
+@@ -223,7 +223,7 @@ parseCommandLine(int argc, char ** argv,
+ cmdlineP->inputFilename = strdup("-"); /* he wants stdin */
+ else if (argc - 1 == 1)
+ cmdlineP->inputFilename = strdup(argv[1]);
+- else
++ else
+ pm_error("Too many arguments. The only argument accepted\n"
+ "is the input file specification");
+
+@@ -232,7 +232,7 @@ parseCommandLine(int argc, char ** argv,
+
+
+ static void
+-createJasperRaster(struct pam * const inpamP,
++createJasperRaster(struct pam * const inpamP,
+ jas_image_t * const jasperP) {
+ /*----------------------------------------------------------------------------
+ Create the raster in the *jasperP object, reading the raster from the
+@@ -254,7 +254,7 @@ createJasperRaster(struct pam * const inpamP,
+ if (matrix[plane] == NULL)
+ pm_error("Unable to create matrix for plane %u. "
+ "jas_matrix_create() failed.", plane);
+- }
++ }
+ tuplerow = pnm_allocpamrow(inpamP);
+
+ jasperMaxval = pm_bitstomaxval(pm_maxvaltobits(inpamP->maxval));
+@@ -271,7 +271,7 @@ createJasperRaster(struct pam * const inpamP,
+ unsigned int jasperSample;
+
+ if (oddMaxval)
+- jasperSample = tuplerow[col][plane] *
++ jasperSample = tuplerow[col][plane] *
+ jasperMaxval / inpamP->maxval;
+ else
+ jasperSample = tuplerow[col][plane];
+@@ -279,16 +279,16 @@ createJasperRaster(struct pam * const inpamP,
+ jas_matrix_set(matrix[plane], 0, col, jasperSample);
+ }
+ }
+- {
++ {
+ unsigned int plane;
+
+ for (plane = 0; plane < inpamP->depth; ++plane) {
+ int rc;
+- rc = jas_image_writecmpt(jasperP, plane, 0, row,
++ rc = jas_image_writecmpt(jasperP, plane, 0, row,
+ inpamP->width, 1,
+ matrix[plane]);
+ if (rc != 0)
+- pm_error("jas_image_writecmpt() of plane %u failed.",
++ pm_error("jas_image_writecmpt() of plane %u failed.",
+ plane);
+ }
+ }
+@@ -297,14 +297,14 @@ createJasperRaster(struct pam * const inpamP,
+ pnm_freepamrow(tuplerow);
+ for (plane = 0; plane < inpamP->depth; ++plane)
+ jas_matrix_destroy(matrix[plane]);
+-
++
+ free(matrix);
+ }
+
+
+
+ static void
+-createJasperImage(struct pam * const inpamP,
++createJasperImage(struct pam * const inpamP,
+ jas_image_t ** const jasperPP) {
+
+ jas_image_cmptparm_t * cmptparms;
+@@ -322,7 +322,7 @@ createJasperImage(struct pam * const inpamP,
+ cmptparms[plane].prec = pm_maxvaltobits(inpamP->maxval);
+ cmptparms[plane].sgnd = 0;
+ }
+- *jasperPP =
++ *jasperPP =
+ jas_image_create(inpamP->depth, cmptparms, JAS_CLRSPC_UNKNOWN);
+ if (*jasperPP == NULL)
+ pm_error("Unable to create jasper image structure. "
+@@ -371,7 +371,7 @@ convertToJasperImage(struct pam * const inpamP,
+
+
+ static void
+-writeJpc(jas_image_t * const jasperP,
++writeJpc(jas_image_t * const jasperP,
+ struct cmdlineInfo const cmdline,
+ FILE * const ofP) {
+
+@@ -383,8 +383,8 @@ writeJpc(jas_image_t * const jasperP,
+
+ /* Note: ilyrrates is a hack because we're too lazy to properly parse
+ command line options to get the information and then compose
+- a proper input to Jasper. So the user can screw things up by
+- specifying garbage for the -ilyrrates option
++ a proper input to Jasper. So the user can screw things up by
++ specifying garbage for the -ilyrrates option
+ */
+ if (strlen(cmdline.ilyrrates) > 0)
+ pm_asprintf(&ilyrratesOpt, "ilyrrates=%s", cmdline.ilyrrates);
+@@ -410,7 +410,7 @@ writeJpc(jas_image_t * const jasperP,
+ */
+ rateOpt[0] = '\0';
+ }
+- pm_asprintf(&options,
++ pm_asprintf(&options,
+ "imgareatlx=%u "
+ "imgareatly=%u "
+ "tilegrdtlx=%u "
+@@ -428,7 +428,7 @@ writeJpc(jas_image_t * const jasperP,
+ "numrlvls=%u "
+ "numgbits=%u "
+ "%s %s %s %s %s %s %s %s %s",
+-
++
+ cmdline.imgareatlx,
+ cmdline.imgareatly,
+ cmdline.tilegrdtlx,
+@@ -471,8 +471,8 @@ writeJpc(jas_image_t * const jasperP,
+ pm_message("Using Jasper to encode to 'jpc' format with options "
+ "'%s'", options);
+
+- rc = jas_image_encode(jasperP, outStreamP,
+- jas_image_strtofmt((char*)"jpc"),
++ rc = jas_image_encode(jasperP, outStreamP,
++ jas_image_strtofmt((char*)"jpc"),
+ (char *)options);
+ if (rc != 0)
+ pm_error("jas_image_encode() failed to encode the JPEG 2000 "
+@@ -484,11 +484,11 @@ writeJpc(jas_image_t * const jasperP,
+ int rc;
+
+ rc = jas_stream_close(outStreamP);
+-
++
+ if (rc != 0)
+ pm_error("Failed to close output stream, "
+ "jas_stream_close() rc = %d", rc);
+- }
++ }
+
+ jas_image_clearfmts();
+
+@@ -506,33 +506,31 @@ main(int argc, char **argv)
+ jas_image_t * jasperP;
+
+ pnm_init(&argc, argv);
+-
++
+ parseCommandLine(argc, argv, &cmdline);
+-
+- {
++
++ {
+ int rc;
+-
++
+ rc = jas_init();
+ if ( rc != 0 )
+ pm_error("Failed to initialize Jasper library. "
+ "jas_init() returns rc %d", rc );
+ }
+-
++
+ jas_setdbglevel(cmdline.debuglevel);
+-
++
+ ifP = pm_openr(cmdline.inputFilename);
+-
++
+ pnm_readpaminit(ifP, &inpam, PAM_STRUCT_SIZE(tuple_type));
+-
++
+ convertToJasperImage(&inpam, &jasperP);
+-
++
+ writeJpc(jasperP, cmdline, stdout);
+-
++
+ jas_image_destroy(jasperP);
pm_close(ifP);
diff --git a/netpbm-ppmfadeusage.patch b/netpbm-ppmfadeusage.patch
index 2943ddb..d48f5f5 100644
--- a/netpbm-ppmfadeusage.patch
+++ b/netpbm-ppmfadeusage.patch
@@ -1,62 +1,57 @@
-diff -urNp a/editor/ppmfade b/editor/ppmfade
---- a/editor/ppmfade 2025-02-04 10:47:27.812451607 +0100
-+++ b/editor/ppmfade 2025-02-04 10:52:14.233336029 +0100
-@@ -99,6 +99,9 @@ sub commandLineArgs() {
- $mode = 'BLOCK';
- } elsif ($arg eq "-mix") {
- $mode = 'MIX';
-+ } elsif ($arg eq "-help" || $arg eq "--help" || $arg eq "-h") {
-+ print STDERR ("ppmfade: Use 'man ppmfade' for help.\n");
-+ exit 1;
+diff -urNp old/editor/ppmfade new/editor/ppmfade
+--- old/editor/ppmfade 2017-11-01 11:47:49.869611402 +0100
++++ new/editor/ppmfade 2017-11-01 11:53:25.524973342 +0100
+@@ -84,7 +84,7 @@ for ($n = 0; $n < @ARGV; $n++) {
+ if (-e $first_file) {
} else {
- if (substr($arg, 0, 1) eq '-') {
- print STDERR ("Unknown option '$arg'. " .
-@@ -109,13 +112,13 @@ sub commandLineArgs() {
- print STDERR ("There are no non-option arguments possible. " .
- "You specified '$arg'\n");
- }
-- exit 100;
+ print "I can't find first file '$first_file'\n";
+- exit 20;
+ exit 1;
}
- }
-
- if (!defined($firstFileNm) && !defined($lastFileNm)) {
- print STDERR ("You must specify -f or -l (or both)\n");
-- exit 90;
-+ exit 1
- }
-
- if (!defined($mode)) {
-@@ -142,7 +145,7 @@ sub imageDimensions($$) {
+ } elsif ($ARGV[$n] eq "-l") {
+ $n++;
+@@ -92,7 +92,7 @@ for ($n = 0; $n < @ARGV; $n++) {
+ if (-e $last_file) {
} else {
- print STDERR
- ("Unrecognized results from pnmfile on $firstFileNm.\n");
-- exit(50);
-+ exit(1);
+ print "I can't find last file '$last_file'\n";
+- exit 20;
++ exit 1;
}
+ } elsif ($ARGV[$n] eq "-base") {
+ $n++;
+@@ -113,9 +113,12 @@ for ($n = 0; $n < @ARGV; $n++) {
+ $mode = $BLOCK;
+ } elsif ("$ARGV[$n]" eq "-mix") {
+ $mode = $MIX;
++ } elsif ($ARGV[$n] eq "-help" || $ARGV[$n] eq "--help" || $ARGV[$n] eq "-h") {
++ print "ppmfade: Use 'man ppmfade' for help.\n";
++ exit 1;
} else {
- # $lastFileNm is defined
-@@ -151,7 +154,7 @@ sub imageDimensions($$) {
- } else {
- print STDERR
- ("Unrecognized results from pnmfile on $firstFileNm.\n");
-- exit(50);
-+ exit(1);
- }
+ print "Unknown argument: $ARGV[$n]\n";
+- exit 100;
++ exit 1;
+ }
+ }
+ #
+@@ -134,18 +137,18 @@ if ($first_file ne "undefined") {
+ $width = $1; $height = $2;
+ } else {
+ print("Unrecognized results from pnmfile on $first_file.\n");
+- exit(50);
++ exit 1;
}
- return $width, $height;
-@@ -436,12 +439,12 @@ my ($mode, $firstFileNm, $lastFileNm, $b
-
- if (defined($firstFileNm) && !-e($firstFileNm)) {
- print STDERR ("First file '$firstFileNm' does not exist\n");
-- exit 20;
+ } elsif ($last_file ne "undefined") {
+ if ((`pnmfile $last_file` =~ m{\b(\d+)\sby\s(\d+)} )) {
+ $width = $1; $height = $2;
+ } else {
+ print("Unrecognized results from pnmfile on $first_file.\n");
+- exit(50);
++ exit 1;
+ }
+ } else {
+ print("ppmfade: You must specify -f or -l (or both)\n");
+- exit(90);
+ exit 1;
}
- if (defined($lastFileNm) && !-e($lastFileNm)) {
- print STDERR ("Last file '$lastFileNm' does not exist\n");
-- exit 20;
-+ exit 1;
- }
-
- my ($width, $height) = imageDimensions($firstFileNm, $lastFileNm);
+ print("Frames are " . $width . "W x " . $height . "H\n");
diff --git a/netpbm-python3.patch b/netpbm-python3.patch
index 2557933..f611b81 100644
--- a/netpbm-python3.patch
+++ b/netpbm-python3.patch
@@ -1,28 +1,9 @@
-diff --git a/buildtools/makeman b/buildtools/makeman
-index 196dbd0..d73ab76 100755
---- a/buildtools/makeman
-+++ b/buildtools/makeman
+diff -urNp old/buildtools/makeman new/buildtools/makeman
+--- old/buildtools/makeman 2018-01-03 12:15:55.000000000 +0100
++++ new/buildtools/makeman 2018-02-26 14:18:39.993760106 +0100
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
#
# makeman -- compile netpbm's stereotyped HTML to troff markup
#
-diff --git a/buildtools/manpage.mk b/buildtools/manpage.mk
-index ef1a103..c1badb8 100644
---- a/buildtools/manpage.mk
-+++ b/buildtools/manpage.mk
-@@ -126,11 +126,11 @@ reportman:
- # to standard error.
- %.1 %.3 %.5: $(USERGUIDE)/%.html
- @echo Converting $< to $@
-- @python $(MAKEMAN) -d $(USERGUIDE) $(= nl); assert(nh <= UINT_MAX-1);
+ assert(nh >= nl);
+ overflow_add(nh - nl, 1);
-+
++
MALLOCARRAY(v, (unsigned) (nh - nl + 1));
if (v == NULL)
-@@ -133,6 +135,8 @@ matrix (unsigned int const nrl,
+@@ -129,6 +131,7 @@ matrix (unsigned int const nrl,
+ assert(nrh >= nrl);
- assert(nrh >= nrl); assert(nrh <= UINT_MAX-1);
-
-+ overflow_add(nrh - nrl, 1);
-+
/* allocate pointers to rows */
- MALLOCARRAY(matrix, (unsigned) (nrh - nrl + 1));
- if (matrix == NULL)
-@@ -142,6 +146,8 @@ matrix (unsigned int const nrl,
++ overflow_add(nrh - nrl, 1);
+ MALLOCARRAY(m, (unsigned) (nrh - nrl + 1));
+ if (m == NULL)
+ pm_error("Unable to allocate memory for a matrix.");
+@@ -137,6 +140,7 @@ matrix (unsigned int const nrl,
- assert (nch >= ncl); assert(nch <= UINT_MAX-1);
+ assert (nch >= ncl);
+ overflow_add(nch - ncl, 1);
-+
/* allocate rows and set pointers to them */
for (i = nrl; i <= nrh; ++i) {
- MALLOCARRAY(matrix[i], (unsigned) (nch - ncl + 1));
-diff -urNp a/converter/other/gemtopnm.c b/converter/other/gemtopnm.c
---- a/converter/other/gemtopnm.c 2025-02-03 09:24:28.345500482 +0100
-+++ b/converter/other/gemtopnm.c 2025-02-03 09:28:49.455092222 +0100
-@@ -153,6 +153,8 @@ main(int argc, const char ** argv) {
+ MALLOCARRAY(m[i], (unsigned) (nch - ncl + 1));
+diff --git a/converter/other/gemtopnm.c b/converter/other/gemtopnm.c
+index d862213..5f1a51a 100644
+--- a/converter/other/gemtopnm.c
++++ b/converter/other/gemtopnm.c
+@@ -36,7 +36,7 @@
+ * read 4-plane color IMG files. Therefore changed from PBM to PPM.
+ * Bryan changed it further to use the PNM facilities so it outputs
+ * both PBM and PPM in the Netpbm tradition. Name changed from
+- * gemtopbm to gemtopnm.
++ * gemtopbm to gemtopnm.
+ */
- pnm_writepnminit(stdout, cols, rows, MAXVAL, type, 0);
+ #include
+@@ -50,106 +50,107 @@
+ char pattern[8];
+ static void getinit ARGS ((FILE *file, int *colsP, int *rowsP, int *padrightP,
+- int *patlenP, int *planesP));
++ int *patlenP, int *planesP));
+
+ int
+ main(argc, argv)
+- int argc;
+- char *argv[];
++ int argc;
++ char *argv[];
+ {
+- int debug = 0;
+- FILE *f;
++ int debug = 0;
++ FILE *f;
+ int row;
+- int rows, cols, padright, patlen, planes;
++ int rows, cols, padright, patlen, planes;
+ /* attributes of input image */
+ int type; /* The format type (PBM/PPM) of the output image */
+- bit *bitrow[4];
++ bit *bitrow[4];
+ /* One row of input, one or four planes. (If one, only [0] is defined)*/
+ xel * xelrow; /* One row of output */
+- const char * const usage = "[-debug] [gem IMG file]";
+- int argn;
++ const char * const usage = "[-debug] [gem IMG file]";
++ int argn;
+
+ /* Process multiple planes by maintaining a separate row of bits for each
+- * plane. In a single-plane image, all we have to do is write out the
++ * plane. In a single-plane image, all we have to do is write out the
+ * first plane; in a multiple-plane image, we combine them just before writing
+ * out the row.
+ */
+- pnm_init( &argc, argv );
+-
++ pnm_init( &argc, argv );
++
+ argn = 1;
+
+- while (argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0')
+- {
+- if (pm_keymatch(argv[1], "-debug", 2))
+- debug = 1;
+- else
+- pm_usage (usage);
+- ++argn;
+- }
++ while (argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0')
++ {
++ if (pm_keymatch(argv[1], "-debug", 2))
++ debug = 1;
++ else
++ pm_usage (usage);
++ ++argn;
++ }
+
+- if (argc == argn)
+- f = stdin;
+- else {
+- f = pm_openr (argv[argn]);
+- ++argn;
+- }
++ if (argc == argn)
++ f = stdin;
++ else {
++ f = pm_openr (argv[argn]);
++ ++argn;
++ }
+
+- if (argn != argc)
+- pm_usage (usage);
++ if (argn != argc)
++ pm_usage (usage);
+
+- getinit (f, &cols, &rows, &padright, &patlen, &planes);
++ getinit (f, &cols, &rows, &padright, &patlen, &planes);
+
+- if (planes == 1)
++ if (planes == 1)
+ type = PBM_TYPE;
+- else
++ else
+ 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 */
- unsigned int plane;
-diff -urNp a/converter/other/jpegtopnm.c b/converter/other/jpegtopnm.c
---- a/converter/other/jpegtopnm.c 2025-02-03 09:24:28.346500477 +0100
-+++ b/converter/other/jpegtopnm.c 2025-02-03 09:29:57.845723398 +0100
-@@ -894,6 +894,8 @@ convertImage(FILE *
+ int plane;
+- for (plane = 0; plane < planes; plane++)
++ for (plane = 0; plane < planes; plane++)
+ bitrow[plane] = malloc (cols + padright);
+ }
+ xelrow = pnm_allocrow(cols+padright); /* Output row */
+
+- for (row = 0; row < rows; ) {
++ for (row = 0; row < rows; ) {
+ int linerep;
+ int plane;
+
+- linerep = 1;
+- for (plane = 0; plane < planes; plane++) {
++ linerep = 1;
++ for (plane = 0; plane < planes; plane++) {
+ int col;
+- col = 0;
+- while (col < cols) {
++ col = 0;
++ while (col < cols) {
+ int c;
+- switch (c = getc(f)) {
+- case 0x80: /* Bit String */
++ switch (c = getc(f)) {
++ case 0x80: /* Bit String */
+ {
+ int j;
+- c = getc(f); /* Byte count */
+- if (debug)
++ c = getc(f); /* Byte count */
++ if (debug)
+ pm_message("bit string of %d bytes", c);
+-
+- if (col + c * 8 > cols + padright)
+- pm_error ("bad byte count");
+- for (j = 0; j < c; ++j) {
++
++ if (col + c * 8 > cols + padright)
++ pm_error ("bad byte count");
++ for (j = 0; j < c; ++j) {
+ int cc, k;
+- cc = getc(f);
+- for (k = 0x80; k; k >>= 1) {
+- bitrow[plane][col] = (k & cc) ? 0 : 1;
+- ++col;
+- }
+- }
++ cc = getc(f);
++ for (k = 0x80; k; k >>= 1) {
++ bitrow[plane][col] = (k & cc) ? 0 : 1;
++ ++col;
++ }
++ }
+ }
+ break;
+- case 0: /* Pattern run */
++ case 0: /* Pattern run */
+ {
+ int j, l;
+- c = getc(f); /* Repeat count */
+- if (debug)
+- pm_message("pattern run of %d repetitions", c);
++ c = getc(f); /* Repeat count */
++ if (debug)
++ pm_message("pattern run of %d repetitions", c);
+ /* line repeat */
+ if (c == 0) {
+ c = getc(f);
+@@ -158,25 +159,25 @@ main(argc, argv)
+ linerep = getc(f);
+ break;
+ }
+- fread (pattern, 1, patlen, f);
+- if (col + c * patlen * 8 > cols + padright)
+- pm_error ("bad pattern repeat count");
+- for (j = 0; j < c; ++j)
+- for (l = 0; l < patlen; ++l) {
++ fread (pattern, 1, patlen, f);
++ if (col + c * patlen * 8 > cols + padright)
++ pm_error ("bad pattern repeat count");
++ for (j = 0; j < c; ++j)
++ for (l = 0; l < patlen; ++l) {
+ int k;
+- for (k = 0x80; k; k >>= 1) {
+- bitrow[plane][col] = (k & pattern[l]) ? 0 : 1;
+- ++col;
+- }
++ for (k = 0x80; k; k >>= 1) {
++ bitrow[plane][col] = (k & pattern[l]) ? 0 : 1;
++ ++col;
++ }
+ }
+ }
+ break;
+
+- default: /* Solid run */
++ default: /* Solid run */
+ {
+ int l, j;
+- if (debug)
+- pm_message("solid run of %d bytes %s", c & 0x7f,
++ if (debug)
++ pm_message("solid run of %d bytes %s", c & 0x7f,
+ c & 0x80 ? "on" : "off" );
+ /* each byte had eight bits DSB */
+ l = (c & 0x80) ? 0: 1;
+@@ -185,23 +186,23 @@ main(argc, argv)
+ pm_error ("bad solid run repeat count");
+ for (j = 0; j < c; ++j) {
+ bitrow[plane][col] = l;
+- ++col;
++ ++col;
+ }
+ }
+- break;
++ break;
+
+- case EOF: /* End of file */
+- pm_error( "end of file reached" );
++ case EOF: /* End of file */
++ pm_error( "end of file reached" );
+
+- }
+- }
++ }
++ }
+ if ( debug )
+ pm_message( "EOL plane %d row %d", plane, row );
+ if (col != cols + padright)
+ pm_error( "EOL beyond edge" );
+- }
++ }
+
+- if (planes == 4) {
++ if (planes == 4) {
+ /* Construct a pixel from the 4 planes of bits for this row */
+ int col;
+ for (col = 0; col < cols; col++) {
+@@ -212,21 +213,21 @@ main(argc, argv)
+ const int b_bit = !bitrow[2][col];
+ i = bitrow[3][col];
+
+- /* Deal with weird GEM palette - white/black/gray are
+- encoded oddly
++ /* Deal with weird GEM palette - white/black/gray are
++ encoded oddly
+ */
+- if (r_bit == g_bit && g_bit == b_bit) {
++ if (r_bit == g_bit && g_bit == b_bit) {
+ /* It's black, white, or gray */
+- if (r_bit && i) r = LIGHT;
+- else if (r_bit) r = BLACK;
+- else if (i) r = MAXVAL;
+- else r = DARK;
+- g = b = r;
+- } else {
++ if (r_bit && i) r = LIGHT;
++ else if (r_bit) r = BLACK;
++ else if (i) r = MAXVAL;
++ else r = DARK;
++ g = b = r;
++ } else {
+ /* It's one of the twelve colored colors */
+ if (!i) {
+ /* Low intensity */
+- r = r_bit * LIGHT;
++ r = r_bit * LIGHT;
+ g = g_bit * LIGHT;
+ b = b_bit * LIGHT;
+ } else {
+@@ -237,21 +238,21 @@ main(argc, argv)
+ }
+ }
+ PPM_ASSIGN(xelrow[col], r, g, b);
+- }
+- } else {
++ }
++ } else {
+ int col;
+- for (col = 0; col < cols; col++)
++ for (col = 0; col < cols; col++)
+ PNM_ASSIGN1(xelrow[col], bitrow[0][col]);
+ }
+- while (linerep--) {
+- pnm_writepnmrow( stdout, xelrow, cols, MAXVAL, type, 0 );
+- ++row;
+- }
+- }
++ while (linerep--) {
++ pnm_writepnmrow( stdout, xelrow, cols, MAXVAL, type, 0 );
++ ++row;
++ }
++ }
+ pnm_freerow(xelrow);
+- pm_close( f );
+- pm_close( stdout );
+- exit(0);
++ pm_close( f );
++ pm_close( stdout );
++ exit(0);
+ }
+
+
+@@ -303,5 +304,3 @@ getinit (file, colsP, rowsP, padrightP, patlenP, planesP)
+ }
+ }
+
+-
+-
+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);
@@ -52,21 +359,23 @@ diff -urNp a/converter/other/jpegtopnm.c b/converter/other/jpegtopnm.c
/* Start decompressor */
jpeg_start_decompress(cinfoP);
-diff -urNp a/converter/other/pbmtopgm.c b/converter/other/pbmtopgm.c
---- a/converter/other/pbmtopgm.c 2025-02-03 09:24:28.346500477 +0100
-+++ b/converter/other/pbmtopgm.c 2025-02-03 09:32:07.478024266 +0100
-@@ -88,6 +88,7 @@ main(int argc, const char ** argv) {
- up = cmdline.convRows / 2; down = cmdline.convRows - up;
+diff --git a/converter/other/pbmtopgm.c b/converter/other/pbmtopgm.c
+index 69b20fb..382a487 100644
+--- a/converter/other/pbmtopgm.c
++++ b/converter/other/pbmtopgm.c
+@@ -47,6 +47,7 @@ main(int argc, char *argv[]) {
+ "than the image height (%u rows)", height, rows);
outrow = pgm_allocrow(cols) ;
-+ overflow2(cmdline.convCols, cmdline.convRows);
- maxval = MIN(PGM_OVERALLMAXVAL, cmdline.convCols * cmdline.convRows);
++ overflow2(width, height);
+ maxval = MIN(PGM_OVERALLMAXVAL, width*height);
pgm_writepgminit(stdout, cols, rows, maxval, 0) ;
-diff -urNp a/converter/other/pnmtoddif.c b/converter/other/pnmtoddif.c
---- a/converter/other/pnmtoddif.c 2025-02-03 09:24:28.346500477 +0100
-+++ b/converter/other/pnmtoddif.c 2025-02-03 09:33:21.228626549 +0100
-@@ -627,6 +627,7 @@ main(int argc, char *argv[]) {
+diff --git a/converter/other/pnmtoddif.c b/converter/other/pnmtoddif.c
+index ac02e42..a2f045b 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;
@@ -74,7 +383,7 @@ diff -urNp a/converter/other/pnmtoddif.c b/converter/other/pnmtoddif.c
ip.bytes_per_line = (cols + 7) / 8;
ip.spectral = 2;
ip.components = 1;
-@@ -642,6 +643,7 @@ main(int argc, char *argv[]) {
+@@ -644,6 +645,7 @@ main(int argc, char *argv[]) {
ip.polarity = 2;
break;
case PPM_TYPE:
@@ -82,112 +391,187 @@ diff -urNp a/converter/other/pnmtoddif.c b/converter/other/pnmtoddif.c
ip.bytes_per_line = 3 * cols;
ip.bits_per_pixel = 24;
ip.spectral = 5;
-diff -urNp a/converter/other/pnmtops.c b/converter/other/pnmtops.c
---- a/converter/other/pnmtops.c 2025-02-03 09:24:28.345500482 +0100
-+++ b/converter/other/pnmtops.c 2025-02-03 09:42:01.586878661 +0100
-@@ -298,17 +298,21 @@ parseCommandLine(int argc, const char **
- validateCompDimension(width, psScaleFactor, "-width value");
- validateCompDimension(height, psScaleFactor, "-height value");
+diff --git a/converter/other/pnmtojpeg.c b/converter/other/pnmtojpeg.c
+index 4482624..757d08d 100644
+--- a/converter/other/pnmtojpeg.c
++++ b/converter/other/pnmtojpeg.c
+@@ -606,7 +606,11 @@ read_scan_script(j_compress_ptr const cinfo,
+ 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 rescale_p, const pixval maxval,
+ const long half_maxval = maxval / 2;
+ long val;
-+ overflow2(width, psScaleFactor);
- cmdlineP->width = width * psScaleFactor;
-+ overflow2(height, psScaleFactor);
- cmdlineP->height = height * psScaleFactor;
++ 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_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 de0dfd8..09c28d5 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, psScaleFactor, "-imagewidth value");
-+ overflow2(imagewidth, psScaleFactor);
- cmdlineP->imagewidth = imagewidth * psScaleFactor;
+ validateCompDimension(imagewidth, 72, "-imagewidth value");
++ overflow2(imagewidth, 72);
+ cmdlineP->imagewidth = imagewidth * 72;
}
else
cmdlineP->imagewidth = 0;
if (imageheightSpec) {
-- validateCompDimension(imagewidth, psScaleFactor, "-imageheight value");
-+ validateCompDimension(imageheight, psScaleFactor, "-imageheight value");
-+ overflow2(imageheight, psScaleFactor);
- cmdlineP->imageheight = imageheight * psScaleFactor;
+- validateCompDimension(imagewidth, 72, "-imageheight value");
++ validateCompDimension(imageheight, 72, "-imageheight value");
++ overflow2(imageheight, 72);
+ cmdlineP->imageheight = imageheight * 72;
}
else
-diff -urNp a/converter/other/sirtopnm.c b/converter/other/sirtopnm.c
---- a/converter/other/sirtopnm.c 2025-02-03 09:24:28.347500471 +0100
-+++ b/converter/other/sirtopnm.c 2025-02-03 09:44:25.547151413 +0100
-@@ -84,6 +84,7 @@ convertPpm(FILE * const ifP,
- unsigned int const cols,
- xel * const xelrow) {
+diff --git a/converter/other/rletopnm.c b/converter/other/rletopnm.c
+index 018456c..35ea7f7 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 c1e7af8..ef9253b 100644
+--- a/converter/other/tifftopnm.c
++++ b/converter/other/tifftopnm.c
+@@ -1372,7 +1372,9 @@ convertRasterByRows(pnmOut * const pnmOutP,
+ if (scanbuf == NULL)
+ pm_error("can't allocate memory for scanline buffer");
-+ overflow3(cols, rows, 3);
- unsigned int const picsize = cols * rows * 3;
- unsigned int const planesize = cols * rows;
-
-diff -urNp a/converter/other/tifftopnm.c b/converter/other/tifftopnm.c
---- a/converter/other/tifftopnm.c 2025-02-03 09:24:28.345500482 +0100
-+++ b/converter/other/tifftopnm.c 2025-02-03 09:46:55.210395347 +0100
-@@ -1358,7 +1358,8 @@ 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);
++ samplebuf = (unsigned int *) malloc3(cols , sizeof(unsigned int) , spp);
++
if (samplebuf == NULL)
pm_error("can't allocate memory for row buffer");
-diff -urNp a/converter/other/xwdtopnm.c b/converter/other/xwdtopnm.c
---- a/converter/other/xwdtopnm.c 2025-02-03 09:24:28.345500482 +0100
-+++ b/converter/other/xwdtopnm.c 2025-02-03 09:55:18.695851996 +0100
-@@ -243,6 +243,10 @@ processX10Header(X10WDFileHeader * cons
- *colorsP = pnm_allocrow(*maxvalP + 1);
- for (i = 0; i <= *maxvalP; ++i)
- PNM_ASSIGN1((*colorsP)[i], i);
+diff --git a/converter/other/xwdtopnm.c b/converter/other/xwdtopnm.c
+index df3c737..6c19ade 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;
- *bitsPerItemP = 16;
-@@ -671,6 +675,7 @@ processX11Header(const X11WDFileHeader *
- "%u bits per pixel, which is too many for this program "
- "to compute",
- h11FixedP->pixmap_width, h11FixedP->bits_per_pixel);
+ *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 -urNp a/converter/pbm/mdatopbm.c b/converter/pbm/mdatopbm.c
---- a/converter/pbm/mdatopbm.c 2025-02-03 09:24:28.358500411 +0100
-+++ b/converter/pbm/mdatopbm.c 2025-02-03 09:57:03.495422912 +0100
-@@ -283,11 +283,13 @@ main(int argc, const char **argv) {
- pm_readlittleshort(ifP, &yy); nInCols = yy;
+diff --git a/converter/pbm/mdatopbm.c b/converter/pbm/mdatopbm.c
+index d8e0657..12c7468 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)
+ if (bScale) {
+ overflow2(nOutRows, 2);
nOutRows *= 2;
--
+ }
+
data = pbm_allocarray(nOutCols, nOutRows);
-
- MALLOCARRAY_NOFAIL(mdrow, nInCols);
-diff -urNp a/converter/pbm/mgrtopbm.c b/converter/pbm/mgrtopbm.c
---- a/converter/pbm/mgrtopbm.c 2025-02-03 09:24:28.358500411 +0100
-+++ b/converter/pbm/mgrtopbm.c 2025-02-03 09:58:19.232265999 +0100
-@@ -105,6 +105,8 @@ readMgrHeader(FILE * const ifP,
- interpHdrWidth (head, colsP);
- interpHdrHeight(head, rowsP);
-
+
+diff --git a/converter/pbm/mgrtopbm.c b/converter/pbm/mgrtopbm.c
+index 9f7004a..60e8477 100644
+--- a/converter/pbm/mgrtopbm.c
++++ b/converter/pbm/mgrtopbm.c
+@@ -65,6 +65,8 @@ readMgrHeader(FILE * const ifP,
+ if (head.h_high < ' ' || head.l_high < ' ')
+ pm_error("Invalid width field in MGR header");
+
+ overflow_add(*colsP, pad);
+
- *padrightP = ((*colsP + pad - 1) / pad) * pad - *colsP;
- }
+ *colsP = (((int)head.h_wide - ' ') << 6) + ((int)head.l_wide - ' ');
+ *rowsP = (((int)head.h_high - ' ') << 6) + ((int) head.l_high - ' ');
+ *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 @@
-diff -urNp a/converter/pbm/pbmtogem.c b/converter/pbm/pbmtogem.c
---- a/converter/pbm/pbmtogem.c 2025-02-03 09:24:28.358500411 +0100
-+++ b/converter/pbm/pbmtogem.c 2025-02-03 10:25:34.259707343 +0100
+ #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 9eab041..13b0257 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;
@@ -196,9 +580,10 @@ diff -urNp a/converter/pbm/pbmtogem.c b/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));
-diff -urNp a/converter/pbm/pbmtogo.c b/converter/pbm/pbmtogo.c
---- a/converter/pbm/pbmtogo.c 2025-02-03 09:24:28.359500407 +0100
-+++ b/converter/pbm/pbmtogo.c 2025-02-03 10:26:22.723447123 +0100
+diff --git a/converter/pbm/pbmtogo.c b/converter/pbm/pbmtogo.c
+index 23b2ee9..d2ee91f 100644
+--- a/converter/pbm/pbmtogo.c
++++ b/converter/pbm/pbmtogo.c
@@ -158,6 +158,7 @@ main(int argc,
bitrow = pbm_allocrow(cols);
@@ -207,14 +592,15 @@ diff -urNp a/converter/pbm/pbmtogo.c b/converter/pbm/pbmtogo.c
rucols = ( cols + 7 ) / 8;
bytesperrow = rucols; /* GraphOn uses bytes */
rucols = rucols * 8;
-diff -urNp a/converter/pbm/pbmtolj.c b/converter/pbm/pbmtolj.c
---- a/converter/pbm/pbmtolj.c 2025-02-03 09:24:28.357500417 +0100
-+++ b/converter/pbm/pbmtolj.c 2025-02-03 10:29:37.442401385 +0100
-@@ -120,7 +120,11 @@ parseCommandLine(int argc, const char **
+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, 7);
++ overflow_add(cols, 8);
rowBufferSize = (cols + 7) / 8;
+ overflow_add(rowBufferSize, 128);
+ overflow_add(rowBufferSize, rowBufferSize+128);
@@ -222,162 +608,427 @@ diff -urNp a/converter/pbm/pbmtolj.c b/converter/pbm/pbmtolj.c
packBufferSize = rowBufferSize + (rowBufferSize + 127) / 128 + 1;
deltaBufferSize = rowBufferSize + rowBufferSize / 8 + 10;
-diff -urNp a/converter/pbm/pbmtomda.c b/converter/pbm/pbmtomda.c
---- a/converter/pbm/pbmtomda.c 2025-02-03 09:24:28.357500417 +0100
-+++ b/converter/pbm/pbmtomda.c 2025-02-03 10:31:40.714199457 +0100
-@@ -204,6 +204,7 @@ main(int argc, const char ** argv) {
-
- nOutRowsUnrounded = cmdline.dscale ? nInRows/2 : nInRows;
+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 */
+ /* MDA wants rows a multiple of 4 */
nOutCols = nInCols / 8;
-diff -urNp a/converter/pbm/pbmtoppa/pbm.c b/converter/pbm/pbmtoppa/pbm.c
---- a/converter/pbm/pbmtoppa/pbm.c 2025-02-03 09:24:28.356500423 +0100
-+++ b/converter/pbm/pbmtoppa/pbm.c 2025-02-03 10:48:49.928347495 +0100
-@@ -157,6 +157,7 @@ pbm_readline(pbm_stat * const pbmSt
- 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) {
-@@ -189,6 +190,7 @@ pbm_unreadline(pbm_stat * const pbmStatP
+diff --git a/converter/pbm/pbmtoppa/pbm.c b/converter/pbm/pbmtoppa/pbm.c
+index ae36e0d..1c8d236 100644
+--- a/converter/pbm/pbmtoppa/pbm.c
++++ b/converter/pbm/pbmtoppa/pbm.c
+@@ -11,185 +11,128 @@
+ #include
+ #include
+ #include
+-#include
- 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 -urNp a/converter/pbm/pbmtoppa/pbmtoppa.c b/converter/pbm/pbmtoppa/pbmtoppa.c
---- a/converter/pbm/pbmtoppa/pbmtoppa.c 2025-02-03 09:24:28.356500423 +0100
-+++ b/converter/pbm/pbmtoppa/pbmtoppa.c 2025-02-03 10:49:30.440158354 +0100
-@@ -456,6 +456,7 @@ main(int argc, char *argv[]) {
+-#include "pm.h"
+-#include "nstring.h"
+ #include "ppapbm.h"
+
+-int
+-make_pbm_stat(pbm_stat * const pbmStatP,
+- FILE * const ifP) {
+-
+- char line[1024];
+- char * rc;
+- int retval;
+-
+- pbmStatP->fptr = ifP;
+- pbmStatP->version = none;
+- pbmStatP->current_line = 0;
+- pbmStatP->unread = 0;
+-
+- rc = fgets(line, 1024, ifP);
+- if (rc == NULL)
+- retval = 0;
+- else {
+- line[strlen(line)-1] = 0;
+-
+- if (streq(line,"P1"))
+- pbmStatP->version=P1;
+- if (streq(line,"P4"))
+- pbmStatP->version=P4;
+-
+- if (pbmStatP->version == none) {
+- pm_message("unknown PBM magic '%s'", line);
+- retval = 0;
+- } else {
+- do {
+- char * rc;
+- rc = fgets(line, 1024, ifP);
+- if (rc == NULL)
+- return 0;
+- } while (line[0] == '#');
+- {
+- int rc;
+- rc = sscanf(line, "%d %d",
+- &pbmStatP->width, &pbmStatP->height);
+- if (rc != 2)
+- retval = 0;
+- else {
+- if (pbmStatP->width < 0) {
+- pm_message("Image has negative width");
+- retval = 0;
+- } else if (pbmStatP->width > INT_MAX/2) {
+- pm_message("Uncomputeably large width: %d",
+- pbmStatP->width);
+- retval = 0;
+- } else if (pbmStatP->height < 0) {
+- pm_message("Image has negative height");
+- retval = 0;
+- } else if (pbmStatP->height > INT_MAX/2) {
+- pm_message("Uncomputeably large height: %d",
+- pbmStatP->height);
+- retval = 0;
+- } else
+- retval = 1;
+- }
+- }
+- }
+- }
+- return retval;
+-}
++int make_pbm_stat(pbm_stat* pbm,FILE* fptr)
++{
++ char line[1024];
+
++ pbm->fptr=fptr;
++ pbm->version=none;
++ pbm->current_line=0;
++ pbm->unread = 0;
+
++ if (fgets (line, 1024, fptr) == NULL)
++ return 0;
++ line[strlen(line)-1] = 0;
+
+-static int
+-getbytes(FILE * const ifP,
+- unsigned int const width,
+- unsigned char * const data) {
+-
+- unsigned char mask;
+- unsigned char acc;
+- unsigned char * place;
+- unsigned int num;
+- int retval;
+-
+- if (width == 0)
+- retval = 0;
+- else {
+- for (mask = 0x80, acc = 0, num = 0, place = data; num < width; ) {
+- switch (getc(ifP)) {
+- case EOF:
+- return 0;
+- case '1':
+- acc |= mask;
+- /* fall through */
+- case '0':
+- mask >>= 1;
+- ++num;
+- if (mask == 0x00) { /* if (num % 8 == 0) */
+- *place++ = acc;
+- acc = 0;
+- mask = 0x80;
+- }
+- }
+- }
+- if (width % 8 != 0)
+- *place = acc;
+-
+- retval = 1;
+- }
+- return retval;
+-}
++ if(!strcmp(line,"P1")) pbm->version=P1;
++ if(!strcmp(line,"P4")) pbm->version=P4;
++ if(pbm->version == none)
++ {
++ fprintf(stderr,"pbm_readheader(): unknown PBM magic '%s'\n",line);
++ return 0;
++ }
+
++ do
++ if (fgets (line, 1024, fptr) == NULL)
++ return 0;
++ while (line[0] == '#');
+
++ if (2 != sscanf (line, "%d %d", &pbm->width, &pbm->height))
++ return 0;
+
+-int
+-pbm_readline(pbm_stat * const pbmStatP,
+- unsigned char * const data) {
+-/*----------------------------------------------------------------------------
+- Read a single line into data which must be at least (pbmStatP->width+7)/8
+- bytes of storage.
+------------------------------------------------------------------------------*/
+- int retval;
+-
+- if (pbmStatP->current_line >= pbmStatP->height)
+- retval = 0;
+- else {
+- if (pbmStatP->unread) {
+- memcpy(data, pbmStatP->revdata, (pbmStatP->width+7)/8);
+- ++pbmStatP->current_line;
+- pbmStatP->unread = 0;
+- free(pbmStatP->revdata);
+- pbmStatP->revdata = NULL;
+- retval = 1;
+- } else {
+- switch (pbmStatP->version) {
+- case P1:
+- if (getbytes(pbmStatP->fptr, pbmStatP->width, data)) {
+- pbmStatP->current_line++;
+- retval = 1;
+- } else
+- retval = 0;
+- break;
+- case P4: {
+- int tmp, tmp2;
+- tmp = (pbmStatP->width+7)/8;
+- tmp2 = fread(data,1,tmp,pbmStatP->fptr);
+- if (tmp2 == tmp) {
+- ++pbmStatP->current_line;
+- retval = 1;
+- } else {
+- pm_message("error reading line data (%d)", tmp2);
+- retval = 0;
+- }
+- } break;
+-
+- default:
+- pm_message("unknown PBM version");
+- retval = 0;
+- }
+- }
+- }
+- return retval;
++ return 1;
+ }
+
++static int getbytes(FILE *fptr,int width,unsigned char* data)
++{
++ unsigned char mask,acc,*place;
++ int num;
++
++ if(!width) return 0;
++ for(mask=0x80, acc=0, num=0, place=data; num>=1;
++ num++;
++ if(!mask) /* if(num%8 == 0) */
++ {
++ *place++ = acc;
++ acc=0;
++ mask=0x80;
++ }
++ }
++ }
++ if(width%8)
++ *place=acc;
++ return 1;
++}
+
++/* Reads a single line into data which must be at least (pbm->width+7)/8
++ bytes of storage */
++int pbm_readline(pbm_stat* pbm,unsigned char* data)
++{
++ int tmp,tmp2;
++
++ if(pbm->current_line >= pbm->height) return 0;
++
++ if (pbm->unread)
++ {
++ memcpy (data, pbm->revdata, (pbm->width+7)/8);
++ pbm->current_line++;
++ pbm->unread = 0;
++ free (pbm->revdata);
++ pbm->revdata = NULL;
++ return 1;
++ }
+
+-void
+-pbm_unreadline(pbm_stat * const pbmStatP,
+- void * const data) {
+-/*----------------------------------------------------------------------------
+- Push a line back into the buffer; we read too much!
+------------------------------------------------------------------------------*/
+- /* can store only one line in the unread buffer */
+-
+- if (!pbmStatP->unread) {
+- pbmStatP->unread = 1;
+- pbmStatP->revdata = malloc ((pbmStatP->width+7)/8);
+- memcpy(pbmStatP->revdata, data, (pbmStatP->width+7)/8);
+- --pbmStatP->current_line;
++ switch(pbm->version)
++ {
++ case P1:
++ if(getbytes(pbm->fptr,pbm->width,data))
++ {
++ pbm->current_line++;
++ return 1;
+ }
+-}
++ return 0;
++
++ case P4:
++ overflow_add(pbm->width, 7);
++ tmp=(pbm->width+7)/8;
++ tmp2=fread(data,1,tmp,pbm->fptr);
++ if(tmp2 == tmp)
++ {
++ pbm->current_line++;
++ return 1;
++ }
++ fprintf(stderr,"pbm_readline(): error reading line data (%d)\n",tmp2);
++ return 0;
+
++ default:
++ fprintf(stderr,"pbm_readline(): unknown PBM version\n");
++ return 0;
++ }
++}
+
++/* push a line back into the buffer; we read too much! */
++void pbm_unreadline (pbm_stat *pbm, void *data)
++{
++ /* can only store one line in the unread buffer */
++ if (pbm->unread)
++ return;
++
++ pbm->unread = 1;
++ overflow_add(pbm->width, 7);
++ pbm->revdata = malloc ((pbm->width+7)/8);
++ memcpy (pbm->revdata, data, (pbm->width+7)/8);
++ pbm->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 = ofP;
+ Pwidth=(Width+7)/8;
+ printer.fptr=out;
-diff -urNp a/converter/pbm/pbmtoxbm.c b/converter/pbm/pbmtoxbm.c
---- a/converter/pbm/pbmtoxbm.c 2025-02-03 09:24:28.357500417 +0100
-+++ b/converter/pbm/pbmtoxbm.c 2025-02-03 10:50:31.351873866 +0100
-@@ -370,6 +370,7 @@ convertRaster(FILE * const ifP,
+diff --git a/converter/pbm/pbmtoxbm.c b/converter/pbm/pbmtoxbm.c
+index ecb72b3..fc0eb9c 100644
+--- a/converter/pbm/pbmtoxbm.c
++++ b/converter/pbm/pbmtoxbm.c
+@@ -352,6 +352,8 @@ convertRaster(FILE * const ifP,
+
+ unsigned char * bitrow;
+ unsigned int row;
++
++ overflow_add(cols, padright);
putinit(xbmVersion);
-+ overflow_add(cols, padright);
- bitrow = pbm_allocrow_packed(cols + padright);
-
- for (row = 0; row < rows; ++row) {
-diff -urNp a/converter/pbm/pktopbm.c b/converter/pbm/pktopbm.c
---- a/converter/pbm/pktopbm.c 2025-02-03 09:24:28.357500417 +0100
-+++ b/converter/pbm/pktopbm.c 2025-02-03 17:09:21.430572232 +0100
-@@ -454,6 +454,7 @@ readCharacterHeader(int * const
- if (packetLength > UINT_MAX - pkLoc)
- pm_error("Invalid character header - excessive packet length");
-
-+ overflow_add(packetLength, pkLoc);
- *endOfPacketP = packetLength + pkLoc;
-
- *cheightP = cheight;
-diff -urNp a/converter/pbm/thinkjettopbm.l b/converter/pbm/thinkjettopbm.l
---- a/converter/pbm/thinkjettopbm.l 2025-02-03 09:24:28.359500407 +0100
-+++ b/converter/pbm/thinkjettopbm.l 2025-02-03 17:11:07.302725005 +0100
-@@ -117,6 +117,7 @@ DIG [0-9]
+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..7f31de5 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) {
- if (rowCapacity > INT_MAX-100)
- pm_error("Too many rows to count");
-+ overflow_add(rowCapacity, 100);
- rowCapacity += 100;
- REALLOCARRAY(rows, rowCapacity);
+- rowCapacity += 100;
++ overflow_add(rowCapacity, 100);
++ rowCapacity += 100;
++ overflow2(rowCapacity, sizeof *rows);
+ rows = realloc (rows, rowCapacity * sizeof *rows);
if (rows == NULL)
-@@ -232,6 +233,7 @@ yywrap (void)
+ pm_error ("Out of memory.");
+@@ -226,6 +228,8 @@ 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 -urNp a/converter/pbm/ybmtopbm.c b/converter/pbm/ybmtopbm.c
---- a/converter/pbm/ybmtopbm.c 2025-02-03 09:24:28.359500407 +0100
-+++ b/converter/pbm/ybmtopbm.c 2025-02-03 17:17:57.638369880 +0100
-@@ -88,8 +88,12 @@ main(int argc, const char * argv[]) {
+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");
- pbm_writepbminit(stdout, cols, rows, 0);
+ *depthP = 1;
++ overflow_add(*colsP, 15);
+ }
-+ overflow_add(cols, 8);
+
+diff --git a/converter/pgm/lispmtopgm.c b/converter/pgm/lispmtopgm.c
+index 40dd3fb..b5469f7 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 )
+@@ -102,6 +103,8 @@ getinit( file, colsP, rowsP, depthP, padrightP )
+
+ if ( *depthP == 0 )
+ *depthP = 1; /* very old file */
+
- bitrow = pbm_allocrow_packed(cols + 8);
++ overflow_add((int)colsP, 31);
+
+ *padrightP = ( ( *colsP + 31 ) / 32 ) * 32 - *colsP;
+
+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);
-+ overflow_add(cols, 15);
-+
+ pgm_writepgminit(stdout, cols, rows, maxval, 0);
++ overflow_add(cols, 7);
+ grayrow = pgm_allocrow((cols + 7) / 8 * 8);
for (row = 0; row < rows; ++row) {
- uint16_t * const itemrow = (uint16_t *) bitrow;
- unsigned int const itemCt = (cols + 15) / 16;
-diff -urNp a/converter/ppm/ilbmtoppm.c b/converter/ppm/ilbmtoppm.c
---- a/converter/ppm/ilbmtoppm.c 2025-02-03 09:24:28.330500563 +0100
-+++ b/converter/ppm/ilbmtoppm.c 2025-02-03 18:06:05.606638402 +0100
-@@ -1385,6 +1385,9 @@ dcol_to_ppm(FILE * const ifP,
- if (redmaxval != maxval || greenmaxval != maxval || bluemaxval != maxval)
- pm_message("scaling colors to %u 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);
-@@ -1875,12 +1878,14 @@ PCHG_ConvertSmall(PCHGHeader * const
- else {
- unsigned int const changeCt16 = *dataCursor++;
- unsigned int const changeCt32 = *dataCursor++;
-+ overflow_add(changeCt16, changeCt32);
- unsigned int const changeCt = changeCt16 + changeCt32;
-
- unsigned int i;
-
- remDataSize -= 2;
-
-+ overflow_add(changeCt, 1);
- MALLOCARRAY_NOFAIL(cmapP->mp_change[row], changeCt + 1);
- for (i = 0; i < changeCt; ++i) {
- if (totalChangeCt >= pchgP->TotalChanges) goto fail;
-@@ -2122,6 +2127,7 @@ read_pchg(FILE * const ifP,
- "is less than minreg (%u)",
- PCHG.MaxReg, PCHG.MinReg);
- else {
-+ overflow_add(PCHG.MaxReg-PCHG.MinReg, 2);
- unsigned int const nch = PCHG.MaxReg - PCHG.MinReg + 1;
-
- unsigned int i;
-diff -urNp a/converter/ppm/imgtoppm.c b/converter/ppm/imgtoppm.c
---- a/converter/ppm/imgtoppm.c 2025-02-03 09:24:28.330500563 +0100
-+++ b/converter/ppm/imgtoppm.c 2025-02-03 18:10:34.478961449 +0100
-@@ -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 (len != cmaplen * 3) {
- pm_message(
- "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);
-+ overflow2(cols, rows);
- if (len != cols * rows)
- pm_message(
- "pixel data length (%u) does not match image size (%u)",
-diff -urNp a/converter/ppm/Makefile b/converter/ppm/Makefile
---- a/converter/ppm/Makefile 2025-02-03 09:24:28.331500558 +0100
-+++ b/converter/ppm/Makefile 2025-02-03 17:39:13.338685028 +0100
+ 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 \
@@ -387,84 +1038,544 @@ diff -urNp a/converter/ppm/Makefile b/converter/ppm/Makefile
ppmtoacad ppmtoapplevol ppmtoarbtxt ppmtoascii \
ppmtobmp ppmtoeyuv ppmtogif ppmtoicr ppmtoilbm \
ppmtoleaf ppmtolj ppmtomitsu ppmtoneo \
-diff -urNp a/converter/ppm/pcxtoppm.c b/converter/ppm/pcxtoppm.c
---- a/converter/ppm/pcxtoppm.c 2025-02-03 09:24:28.329500569 +0100
-+++ b/converter/ppm/pcxtoppm.c 2025-02-03 18:12:34.245400166 +0100
-@@ -378,6 +378,7 @@ pcxPlanesToPixels(unsigned char * const
- to conceive how this subroutine should work with other numbers of bits per
- sample, but it doesn't.
- -----------------------------------------------------------------------------*/
-+ overflow2(bytesPerLine, 8);
- unsigned int const pixelCt = bytesPerLine * 8;
+diff --git a/converter/ppm/ilbmtoppm.c b/converter/ppm/ilbmtoppm.c
+index 92d4d6f..60853dd 100644
+--- a/converter/ppm/ilbmtoppm.c
++++ b/converter/ppm/ilbmtoppm.c
+@@ -608,6 +608,7 @@ decode_row(FILE * const ifP,
+ rawtype *chp;
- unsigned int bitPlanesIdx;
-diff -urNp a/converter/ppm/pjtoppm.c b/converter/ppm/pjtoppm.c
---- a/converter/ppm/pjtoppm.c 2025-02-03 09:24:28.329500569 +0100
-+++ b/converter/ppm/pjtoppm.c 2025-02-03 18:21:28.636228030 +0100
-@@ -77,6 +77,7 @@ modifyImageMode1(unsigned int const
- val = image[plane + row * planes][col+1];
- cmd >= 0 && i < newcols; --cmd, ++i)
- buf[i] = val;
-+ overflow_add(i, 1);
- }
- cols = MAX(cols, i);
- free(image[row * planes + plane]);
-@@ -90,6 +91,7 @@ modifyImageMode1(unsigned int const
- }
- }
+ 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/ilbmtoppm.c.rej b/converter/ppm/ilbmtoppm.c.rej
+new file mode 100644
+index 0000000..972cad0
+--- /dev/null
++++ b/converter/ppm/ilbmtoppm.c.rej
+@@ -0,0 +1,46 @@
++--- converter/ppm/ilbmtoppm.c
+++++ converter/ppm/ilbmtoppm.c
++@@ -694,6 +695,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(cmap, row, palchange)
++@@ -1356,6 +1374,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);
++@@ -1785,7 +1806,9 @@ PCHG_ConvertSmall(PCHG, cmap, mask, datasize)
++ ChangeCount32 = *data++;
++ datasize -= 2;
++
+++ overflow_add(ChangeCount16, ChangeCount32);
++ changes = ChangeCount16 + ChangeCount32;
+++ overflow_add(changes, 1);
++ for( i = 0; i < changes; i++ ) {
++ if( totalchanges >= PCHG->TotalChanges ) goto fail;
++ if( datasize < 2 ) goto fail;
+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,
}
-+ overflow2(cols, 8);
- *colsP = cols * 8; assert(cols < UINT_MAX/8);
+
+ /* 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 b8fb864..177bc30 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 b8b94f7..62ce77e 100644
+--- a/converter/ppm/pjtoppm.c
++++ b/converter/ppm/pjtoppm.c
+@@ -11,87 +11,65 @@
+ */
+
+ #include "ppm.h"
+-#include "pm_c_util.h"
+ #include "mallocvar.h"
+
+ static char usage[] = "[paintjetfile]";
+
+-
+-
+-static unsigned int
+-uintProduct(unsigned int const multiplicand,
+- unsigned int const multiplier) {
+-
+- if (UINT_MAX / multiplier < multiplicand)
+- pm_error("Airthmetic overflow");
+-
+- return multiplicand * multiplier;
+-}
+-
+-
+-
++static int egetc ARGS((FILE *fp));
+ static int
+-egetc(FILE * const ifP) {
++egetc(fp)
++ FILE *fp;
++{
+ int c;
+-
+- c = fgetc(ifP);
+-
+- if (c == -1)
++ if ((c = fgetc(fp)) == -1)
+ pm_error("unexpected end of file");
+-
+- return c;
++ return(c);
}
-@@ -265,8 +267,10 @@ main(int argc, const char ** argv) {
+-
+-
+ int
+-main(int argc, const char ** argv) {
+-
++main(argc, argv)
++ int argc;
++ char *argv[];
++{
+ int cmd, val;
+ char buffer[BUFSIZ];
+ int planes = 3, rows = -1, cols = -1;
++ int r = 0, c = 0, p = 0, i;
+ unsigned char **image = NULL;
+ int *imlen;
+- FILE * ifP;
++ FILE *fp = stdin;
+ int mode;
+ int argn;
+ unsigned char bf[3];
+- pixel * pixrow;
+- int c;
+- int row;
+- int plane;
++ pixel *pixrow;
+
+- pm_proginit(&argc, argv);
+
++ ppm_init(&argc, argv);
+ argn = 1;
+ if (argn != argc)
+- ifP = pm_openr(argv[argn++]);
++ fp = pm_openr(argv[argn++]);
+ else
+- ifP = stdin;
++ fp = stdin;
+
+ if (argn != argc)
+ pm_usage(usage);
+
+- row = 0; /* initial value */
+- plane = 0; /* initial value */
+-
+- while ((c = fgetc(ifP)) != -1) {
++ while ((c = fgetc(fp)) != -1) {
+ if (c != '\033')
+ continue;
+- switch (c = egetc(ifP)) {
++ switch (c = egetc(fp)) {
+ case 'E': /* reset */
+ break;
+- case '*': {
+- unsigned int i;
+- cmd = egetc(ifP);
++ case '*':
++ cmd = egetc(fp);
+ for (i = 0; i < BUFSIZ; i++) {
+- if (!isdigit(c = egetc(ifP)) && c != '+' && c != '-')
++ if (!isdigit(c = egetc(fp)) && c != '+' && c != '-')
+ break;
+ buffer[i] = c;
+ }
+ if (i != 0) {
+ buffer[i] = '\0';
+- if (sscanf(buffer, "%d", &val) != 1)
++ if (sscanf(buffer, "%d", &val) != 1)
+ pm_error("bad value `%s' at *%c%c", buffer, cmd, c);
+ }
+ else
+@@ -122,7 +100,7 @@ main(int argc, const char ** argv) {
+ break;
+ case 'U': /* planes */
+ planes = val;
+- if (planes != 3)
++ if (planes != 3)
+ pm_error("can handle only 3 plane files");
+ break;
+ case 'A': /* begin raster */
+@@ -148,33 +126,40 @@ main(int argc, const char ** argv) {
+ break;
case 'V': /* send plane */
case 'W': /* send last plane */
- if (row >= rowsX || image == NULL) {
-- if (row >= rowsX)
-+ if (row >= rowsX) {
+- if (rows == -1 || row >= rows || image == NULL) {
+- if (rows == -1 || row >= rows)
++ if (rows == -1 || r >= rows || image == NULL) {
++ if (rows == -1 || r >= rows) {
+ overflow_add(rows, 100);
- rowsX += 100;
+ rows += 100;
+ }
- REALLOCARRAY(image, uintProduct(rowsX, planes));
- REALLOCARRAY(imlen, uintProduct(rowsX, planes));
++
+ if (image == NULL) {
+- MALLOCARRAY(image, uintProduct(rows, planes));
+- MALLOCARRAY(imlen, uintProduct(rows, planes));
+- } else {
+- REALLOCARRAY(image, uintProduct(rows, planes));
+- REALLOCARRAY(imlen, uintProduct(rows, planes));
++ image = (unsigned char **)
++ malloc3(rows , planes , sizeof(unsigned char *));
++ imlen = (int *) malloc3(rows , planes, sizeof(int));
+ }
++ else {
++ overflow2(rows,planes);
++ image = (unsigned char **)
++ realloc2(image, rows * planes,
++ sizeof(unsigned char *));
++ imlen = (int *) realloc2(imlen, rows * planes, sizeof(int)); }
}
-@@ -277,6 +281,8 @@ main(int argc, const char ** argv) {
- if (!colsIsSet)
- pm_error("missing width value");
+ if (image == NULL || imlen == NULL)
+ pm_error("out of memory");
+- if (plane >= planes)
++ if (p == planes)
+ pm_error("too many planes");
+- cols = MAX(cols, val);
+- imlen[row * planes + plane] = val;
+- MALLOCARRAY(image[row * planes + plane], val);
+- if (image[row * planes + plane] == NULL)
++ cols = cols > val ? cols : val;
++ imlen[r * planes + p] = val;
++ MALLOCARRAY(image[r * planes + p], val);
++ if (image[r * planes + p] == NULL)
+ pm_error("out of memory");
+- if (fread(image[row * planes + plane], 1, val, ifP) != val)
++ if (fread(image[r * planes + p], 1, val, fp) != val)
+ pm_error("short data");
+ if (c == 'V')
+- ++plane;
++ p++;
+ else {
+- plane = 0;
+- ++row;
++ p = 0;
++ r++;
+ }
+ break;
+ default:
+@@ -183,7 +168,7 @@ main(int argc, const char ** argv) {
+ }
+ break;
+ case 'p': /* Position */
+- if (plane != 0)
++ if (p != 0)
+ pm_error("changed position in the middle of "
+ "transferring planes");
+ switch (c) {
+@@ -192,15 +177,15 @@ main(int argc, const char ** argv) {
+ break;
+ case 'Y':
+ if (buffer[0] == '+')
+- val = row + val;
++ val = r + val;
+ if (buffer[0] == '-')
+- val = row - val;
+- for (; val > row; ++row)
+- for (plane = 0; plane < 3; ++plane) {
+- imlen[row * planes + plane] = 0;
+- image[row * planes + plane] = NULL;
++ val = r - val;
++ for (; val > r; r++)
++ for (p = 0; p < 3; p++) {
++ imlen[r * planes + p] = 0;
++ image[r * planes + p] = NULL;
+ }
+- row = val;
++ r = val;
+ break;
+ default:
+ pm_message("uninmplemented *%c%d%c", cmd, val, c);
+@@ -209,80 +194,65 @@ main(int argc, const char ** argv) {
+ default:
+ pm_message("uninmplemented *%c%d%c", cmd, val, c);
+ break;
+- }
+- } /* case */
+- } /* switch */
++ }
++ }
+ }
+- pm_close(ifP);
+- rows = row;
++ pm_close(fp);
++ rows = r;
+ if (mode == 1) {
+- int const newcols = 10240; /* It could not be larger that that! */
+- unsigned char * buf;
+- unsigned int row;
+-
+- for (row = 0, cols = 0; row < rows; ++row) {
+- unsigned int plane;
+- if (image[row * planes] == NULL)
++ unsigned char *buf;
++ int newcols = 0;
++ newcols = 10240; /* It could not be larger that that! */
++ cols = 0;
++ for (r = 0; r < rows; r++) {
++ if (image[r * planes] == NULL)
+ continue;
+- for (plane = 0; plane < planes; ++plane) {
+- unsigned int i;
+- unsigned int col;
++ for (p = 0; p < planes; p++) {
+ MALLOCARRAY(buf, newcols);
+- if (buf == NULL)
++ if (buf == NULL)
+ pm_error("out of memory");
+- for (i = 0, col = 0;
+- col < imlen[plane + row * planes];
+- col += 2)
+- for (cmd = image[plane + row * planes][col],
+- val = image[plane + row * planes][col+1];
+- cmd >= 0 && i < newcols; cmd--, i++)
++ for (i = 0, c = 0; c < imlen[p + r * planes]; c += 2)
++ for (cmd = image[p + r * planes][c],
++ val = image[p + r * planes][c+1];
++ cmd >= 0 && i < newcols; cmd--, i++) {
+ buf[i] = val;
+- cols = MAX(cols, i);
+- free(image[plane + row * planes]);
+- /*
+- * This is less than what we have so it realloc should
++ overflow_add(i, 1);
++ }
++ cols = cols > i ? cols : i;
++ free(image[p + r * planes]);
++ /*
++ * This is less than what we have so it realloc should
+ * not return null. Even if it does, tough! We will
+ * lose a line, and probably die on the next line anyway
+ */
+- image[plane + row * planes] = realloc(buf, i);
++ image[p + r * planes] = (unsigned char *) realloc(buf, i);
+ }
+ }
++ overflow2(cols, 8);
+ cols *= 8;
+ }
+-
++
++
+ ppm_writeppminit(stdout, cols, rows, (pixval) 255, 0);
+ pixrow = ppm_allocrow(cols);
+-
+- for (row = 0; row < rows; ++row) {
+- if (image[row * planes] == NULL) {
+- unsigned int col;
+- for (col = 0; col < cols; ++col)
+- PPM_ASSIGN(pixrow[col], 0, 0, 0);
++ for (r = 0; r < rows; r++) {
++ if (image[r * planes] == NULL) {
++ for (c = 0; c < cols; c++)
++ PPM_ASSIGN(pixrow[c], 0, 0, 0);
+ continue;
+ }
+- {
+- unsigned int col;
+- unsigned int cmd;
+- for (cmd = 0, col = 0; col < cols; col += 8, ++cmd) {
+- unsigned int i;
+- for (i = 0; i < 8 && col + i < cols; ++i) {
+- unsigned int plane;
+- for (plane = 0; plane < planes; ++plane)
+- if (mode == 0 && cmd >= imlen[row * planes + plane])
+- bf[plane] = 0;
+- else
+- bf[plane] = (image[row * planes + plane][cmd] &
+- (1 << (7 - i))) ? 255 : 0;
+- PPM_ASSIGN(pixrow[col + i], bf[0], bf[1], bf[2]);
+- }
++ for (cmd = 0, c = 0; c < cols; c += 8, cmd++)
++ for (i = 0; i < 8 && c + i < cols; i++) {
++ for (p = 0; p < planes; p++)
++ if (mode == 0 && cmd >= imlen[r * planes + p])
++ bf[p] = 0;
++ else
++ bf[p] = (image[r * planes + p][cmd] &
++ (1 << (7 - i))) ? 255 : 0;
++ PPM_ASSIGN(pixrow[c + i], bf[0], bf[1], bf[2]);
+ }
+- }
+- ppm_writeppmrow(stdout, pixrow, cols, 255, 0);
++ ppm_writeppmrow(stdout, pixrow, cols, (pixval) 255, 0);
+ }
+ pm_close(stdout);
+-
+- return 0;
++ exit(0);
+ }
+-
+-
+-
+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) {
-+ overflow2(rows,planes);
-+ overflow_add(rows * planes, plane);
- cols = MAX(cols, val);
- imlen[row * planes + plane] = val;
- MALLOCARRAY(image[row * planes + plane], val);
-diff -urNp a/converter/ppm/ppmtoeyuv.c b/converter/ppm/ppmtoeyuv.c
---- a/converter/ppm/ppmtoeyuv.c 2025-02-03 09:24:28.330500563 +0100
-+++ b/converter/ppm/ppmtoeyuv.c 2025-02-03 18:22:08.012087384 +0100
-@@ -117,6 +117,7 @@ chrominanceBlue(pixel const p) {
- static void
- createMultiplicationTables(pixval const maxval) {
+ int index;
+ overflow_add(maxval, 1);
MALLOCARRAY_NOFAIL(mult299 , maxval+1);
MALLOCARRAY_NOFAIL(mult587 , maxval+1);
MALLOCARRAY_NOFAIL(mult114 , maxval+1);
-diff -urNp a/converter/ppm/ppmtolj.c b/converter/ppm/ppmtolj.c
---- a/converter/ppm/ppmtolj.c 2025-02-03 09:24:28.330500563 +0100
-+++ b/converter/ppm/ppmtolj.c 2025-02-03 18:24:55.523489226 +0100
-@@ -212,6 +212,8 @@ printRaster(FILE * const ifP,
- pm_error("Image is uncomputably wide (%u columns)", cols);
- }
+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));
-
-diff -urNp a/converter/ppm/ppmtomitsu.c b/converter/ppm/ppmtomitsu.c
---- a/converter/ppm/ppmtomitsu.c 2025-02-03 09:24:28.331500558 +0100
-+++ b/converter/ppm/ppmtomitsu.c 2025-02-03 18:27:10.691006400 +0100
-@@ -68,6 +68,8 @@ mediaSize(const char * const media,
+ if (mode == C_TRANS_MODE_DELTA)
+diff --git a/converter/ppm/ppmtomitsu.c b/converter/ppm/ppmtomitsu.c
+index 5b0b324..11db755 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) {
@@ -473,145 +1584,428 @@ diff -urNp a/converter/ppm/ppmtomitsu.c b/converter/ppm/ppmtomitsu.c
medias.maxcols *= 2;
medias.maxrows *= 2;
}
-diff -urNp a/converter/ppm/ppmtopcx.c b/converter/ppm/ppmtopcx.c
---- a/converter/ppm/ppmtopcx.c 2025-02-03 09:24:28.330500563 +0100
-+++ b/converter/ppm/ppmtopcx.c 2025-02-03 18:31:08.699156362 +0100
-@@ -314,6 +314,8 @@ writeHeader(FILE * const of
- putbyte(0, ofP); /* reserved byte */
- putbyte(planes, ofP); /* number of color planes */
-
-+ overflow2(bitsPerPixel, cols);
-+ overflow_add(bitsPerPixel * cols, 7);
- bytesPerLine = ((cols * bitsPerPixel) + 7) / 8;
- putword(bytesPerLine, ofP); /* number of bytes per scanline */
-
-diff -urNp a/converter/ppm/ppmtopict.c b/converter/ppm/ppmtopict.c
---- a/converter/ppm/ppmtopict.c 2025-02-03 09:24:28.330500563 +0100
-+++ b/converter/ppm/ppmtopict.c 2025-02-03 18:41:02.377096627 +0100
-@@ -394,6 +394,9 @@ writeRaster(FILE * const ofP,
- pm_error("Image is too wide (%u columns) for computation", cols);
+diff --git a/converter/ppm/ppmtopcx.c b/converter/ppm/ppmtopcx.c
+index fa68edc..97dfb2b 100644
+--- a/converter/ppm/ppmtopcx.c
++++ b/converter/ppm/ppmtopcx.c
+@@ -425,6 +425,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);
-+
- MALLOCARRAY(outBuf, cols + cols/MAX_COUNT + 1);
- if (!outBuf)
- pm_error("Unable to allocate %u-byte row buffer",
-diff -urNp a/converter/ppm/ppmtopjxl.c b/converter/ppm/ppmtopjxl.c
---- a/converter/ppm/ppmtopjxl.c 2025-02-03 09:24:28.331500558 +0100
-+++ b/converter/ppm/ppmtopjxl.c 2025-02-03 18:48:46.550503012 +0100
-@@ -535,6 +535,8 @@ main(int argc, const char * argv[]) {
- pm_error("image too large; reduce with ppmscale");
+ 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..fc84cac 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..af2b445 100644
+--- a/converter/ppm/ppmtowinicon.c
++++ b/converter/ppm/ppmtowinicon.c
+@@ -12,6 +12,7 @@
- computeColormap(pixels, cols, rows, MAXCOLORS, &chv, &cht, &colorCt);
-
-diff -urNp a/converter/ppm/ppmtowinicon.c b/converter/ppm/ppmtowinicon.c
---- a/converter/ppm/ppmtowinicon.c 2025-02-03 09:24:28.330500563 +0100
-+++ b/converter/ppm/ppmtowinicon.c 2025-02-03 18:56:25.509890831 +0100
-@@ -14,6 +14,7 @@
- #include
#include
#include
+#include
#include "pm_c_util.h"
#include "winico.h"
-@@ -207,6 +208,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 */
-@@ -706,6 +708,11 @@ addEntryToIcon(MS_Ico * const MSIcon
- /* all the icons I looked at ignored this value */
- entryP->ih = newInfoHeader(*entryP);
- entryP->colors = paletteP->colors;
-+ overflow2(4, entryCols);
-+ overflow_add(xorBitmapP->size, andBitmapP->size);
-+ overflow_add(xorBitmapP->size + andBitmapP->size, 40);
-+ overflow_add(xorBitmapP->size + andBitmapP->size + 40, 4 * entryCols);
-+
- entryP->size_in_bytes =
- xorBitmapP->size + andBitmapP->size + 40 + (4 * entryCols);
- if (verbose)
-diff -urNp a/converter/ppm/ppmtoxpm.c b/converter/ppm/ppmtoxpm.c
---- a/converter/ppm/ppmtoxpm.c 2025-02-03 09:24:28.329500569 +0100
-+++ b/converter/ppm/ppmtoxpm.c 2025-02-03 18:59:21.646266347 +0100
-@@ -193,6 +193,7 @@ numstr(unsigned int const input,
+@@ -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;
+- entry->size_in_bytes =
++ 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)
+ pm_message("entry->size_in_bytes = %d + %d + %d = %d",
+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(digitCt, 1);
- MALLOCARRAY_NOFAIL(str, digitCt + 1);
++ overflow_add(digits, 1);
+ if (!(str = (char *) malloc(digits + 1)))
+ pm_error("out of memory");
- i = input; /* initial value */
-@@ -296,6 +297,7 @@ genCmap(colorhist_vector const chv,
- Return as *charsPerPixel the number of characters, or digits, that
- will be needed in the XPM raster to form an index into this color map.
- -----------------------------------------------------------------------------*/
+@@ -315,6 +316,7 @@ genCmap(colorhist_vector const chv,
+ unsigned int charsPerPixel;
+ unsigned int xpmMaxval;
+
+ if (includeTransparent) overflow_add(ncolors, 1);
- unsigned int const cmapSize = ncolors + (includeTransparent ? 1 : 0);
+ 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 )
- CixelMap * cmap; /* malloc'ed */
-diff -urNp a/converter/ppm/qrttoppm.c b/converter/ppm/qrttoppm.c
---- a/converter/ppm/qrttoppm.c 2025-02-03 09:24:28.331500558 +0100
-+++ b/converter/ppm/qrttoppm.c 2025-02-03 19:00:16.846070585 +0100
-@@ -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);
+diff --git a/converter/ppm/sldtoppm.c b/converter/ppm/sldtoppm.c
+index 2dc049f..2a482be 100644
+--- a/converter/ppm/sldtoppm.c
++++ b/converter/ppm/sldtoppm.c
+@@ -154,127 +154,85 @@ vscale(int * const px,
-+ overflow2(cols, 3);
- MALLOCARRAY(buf, 3 * cols);
- if (!buf)
-diff -urNp a/converter/ppm/sldtoppm.c b/converter/ppm/sldtoppm.c
---- a/converter/ppm/sldtoppm.c 2025-02-03 09:24:28.330500563 +0100
-+++ b/converter/ppm/sldtoppm.c 2025-02-03 19:02:13.580656717 +0100
-@@ -542,6 +542,8 @@ slider(slvecfn slvec,
+
+-static void
+-upcase(const char * const sname,
+- char * const uname) {
+-
+- unsigned int i;
+- const char * ip;
+-
+- for (i = 0, ip = sname; i < 31; ++i) {
+- char const ch = *ip++;
+-
+- if (ch != EOS)
+- uname[i] = islower(ch) ? toupper(ch) : ch;
+- }
+- uname[i] = EOS;
+-}
+-
+-
+-
+-static void
+-skipBytes(FILE * const fileP,
+- unsigned int const count) {
+-
+- unsigned int i;
+-
+- for (i = 0; i < count; ++i)
+- getc(fileP);
+-}
+-
+-
+-
+-static void
+-scanDirectory(FILE * const slFileP,
+- long const dirPos,
+- bool const dirOnly,
+- const char * const uname,
+- bool * const foundP) {
+-/*----------------------------------------------------------------------------
+- Scan the directory at the current position in *slFileP, either listing
+- the directory ('dirOnly' true) or searching for a slide named
+- 'uname' ('dirOnly' false).
+-
+- 'dirPos' is the offset in the file of the directory, i.e. the current
+- position of *slFileP.
+-
+- In the latter case, return as *foundP whether the slide name is there.
+------------------------------------------------------------------------------*/
+- bool found;
+- bool eof;
+- long pos;
+- unsigned char libent[36];
+-
+- for (found = false, eof = false, pos = dirPos; !found && !eof; ) {
+- size_t readCt;
+- readCt = fread(libent, 36, 1, slFileP);
+- if (readCt != 1)
+- eof = true;
+- else {
+- /* The directory entry is 32 bytes of NUL-terminated slide name
+- followed by 4 bytes of offset of the next directory entry.
+- */
+- const char * const slideName = (const char *)(&libent[0]);
+- if (pm_strnlen(slideName, 32) == 32)
+- pm_error("Invalid input: slide name field is not "
+- "nul-terminated");
+- else {
+- if (strlen(slideName) == 0)
+- eof = true;
+- else {
+- pos += 36;
+- if (dirOnly) {
+- pm_message(" %s", slideName);
+- } else if (streq(slideName, uname)) {
+- long const dpos =
+- (((((libent[35] << 8) | libent[34]) << 8) |
+- libent[33]) << 8) | libent[32];
+-
+- if ((slFileP == stdin) ||
+- (fseek(slFileP, dpos, 0) == -1)) {
+-
+- skipBytes(slFileP, dpos - pos);
+- }
+- found = true;
+- }
+- }
+- }
+- }
+- }
+- *foundP = found;
+-}
+-
+ /* SLIDEFIND -- Find a slide in a library or, if DIRONLY is
+ nonzero, print a directory listing of the library.
+ If UCASEN is nonzero, the requested slide name is
+ converted to upper case. */
+
+ static void
+-slidefind(const char * const slideName,
+- bool const dirOnly,
++slidefind(const char * const sname,
++ bool const dironly,
+ bool const ucasen) {
+
+- char uname[32]; /* upper case translation of 'slideName' */
+- char header[32]; /* (supposed) header read from file */
++ char uname[32];
++ unsigned char libent[36];
++ long pos;
+ bool found;
++ bool eof;
+
+- if (dirOnly)
++ if (dironly)
+ pm_message("Slides in library:");
+ else {
+- upcase(slideName, uname);
++ unsigned int i;
++ const char * ip;
++
++ ip = sname; /* initial value */
++
++ for (i = 0; i < 31; ++i) {
++ char const ch = *ip++;
++ if (ch == EOS)
++ break;
++
++ {
++ char const upperCh =
++ ucasen && islower(ch) ? toupper(ch) : ch;
++
++ uname[i] = upperCh;
++ }
++ }
++ uname[i] = EOS;
+ }
+
+ /* Read slide library header and verify. */
+-
+- if ((fread(header, 32, 1, slfile) != 1) ||
+- (!STRSEQ(header, "AutoCAD Slide Library 1.0\r\n\32"))) {
++
++ if ((fread(libent, 32, 1, slfile) != 1) ||
++ (!streq((char *)libent, "AutoCAD Slide Library 1.0\015\012\32"))) {
+ pm_error("not an AutoCAD slide library file.");
+ }
++ pos = 32;
++
++ /* Search for a slide with the requested name or list the directory */
++
++ for (found = false, eof = false; !found && !eof; ) {
++ size_t readCt;
++ readCt = fread(libent, 36, 1, slfile);
++ if (readCt != 1)
++ eof = true;
++ else if (strlen((char *)libent) == 0)
++ eof = true;
++ }
++ if (!eof) {
++ pos += 36;
++ if (dironly) {
++ pm_message(" %s", libent);
++ } else if (streq((char *)libent, uname)) {
++ long dpos;
++
++ dpos = (((((libent[35] << 8) | libent[34]) << 8) |
++ libent[33]) << 8) | libent[32];
++
++ if ((slfile == stdin) || (fseek(slfile, dpos, 0) == -1)) {
++ dpos -= pos;
++
++ while (dpos-- > 0)
++ getc(slfile);
++ }
++ found = true;
++ }
++ }
+
+- scanDirectory(slfile, 32, dirOnly, ucasen ? uname : slideName, &found);
+-
+- if (!found && !dirOnly)
+- pm_error("slide '%s' not in library.", slideName);
++ if (!found && !dironly)
++ pm_error("slide '%s' not in library.", sname);
+ }
+
+
+@@ -392,7 +350,7 @@ slider(slvecfn slvec,
+
+ /* Verify that slide format is compatible with this program. */
+
+- if (!STRSEQ(slfrof.slh, slhi.slh))
++ if (streq(slfrof.slh, slhi.slh))
+ pm_error("this is not an AutoCAD slide file.");
+
+ /* Verify that the number format and file level in the header are
+@@ -506,6 +464,8 @@ slider(slvecfn slvec,
/* Allocate image buffer and clear it to black. */
+ overflow_add(ixdots, 1);
+ overflow_add(iydots, 1);
- pixcols = ixdots + 1;
- pixrows = iydots + 1;
- pixels = ppm_allocarray(pixcols, pixrows);
-diff -urNp a/converter/ppm/ximtoppm.c b/converter/ppm/ximtoppm.c
---- a/converter/ppm/ximtoppm.c 2025-02-03 09:24:28.330500563 +0100
-+++ b/converter/ppm/ximtoppm.c 2025-02-03 19:06:57.979648387 +0100
-@@ -204,8 +204,7 @@ readImageChannel(FILE * const if
- }
- /* return to the beginning of the next image's buffer */
- if (fseek(ifP, marker, 0) == -1) {
-- pm_message("ReadImageChannel: can't fseek to location "
-- "in image buffer");
-+ pm_message("ReadImageChannel: can't fseek to location in image buffer");
- return 0;
- }
- free(line);
-diff -urNp a/editor/pamcut.c b/editor/pamcut.c
---- a/editor/pamcut.c 2025-02-03 09:24:28.296500747 +0100
-+++ b/editor/pamcut.c 2025-02-04 09:20:22.743237833 +0100
-@@ -833,6 +833,8 @@ cutOneImage(FILE * const ifP
- } else {
- 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;
+ 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 75faac6..5758739 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 db5b5b3..5fc0267 100644
+--- a/editor/pamcut.c
++++ b/editor/pamcut.c
+@@ -773,6 +773,8 @@ cutOneImage(FILE * const ifP,
-diff -urNp a/editor/pnmgamma.c b/editor/pnmgamma.c
---- a/editor/pnmgamma.c 2025-02-03 09:24:28.296500747 +0100
-+++ b/editor/pnmgamma.c 2025-02-04 09:21:03.587045507 +0100
-@@ -596,6 +596,7 @@ createGammaTables(enum transferFunction
+ 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 b357b0d..ec612d3 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. */
@@ -619,10 +2013,11 @@ diff -urNp a/editor/pnmgamma.c b/editor/pnmgamma.c
MALLOCARRAY(*rtableP, maxval+1);
MALLOCARRAY(*gtableP, maxval+1);
MALLOCARRAY(*btableP, maxval+1);
-diff -urNp a/editor/pnmhisteq.c b/editor/pnmhisteq.c
---- a/editor/pnmhisteq.c 2025-02-03 09:24:28.296500747 +0100
-+++ b/editor/pnmhisteq.c 2025-02-04 09:21:41.957864812 +0100
-@@ -106,6 +106,7 @@ computeLuminosityHistogram(xel * const *
+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;
@@ -630,10 +2025,23 @@ diff -urNp a/editor/pnmhisteq.c b/editor/pnmhisteq.c
MALLOCARRAY(lumahist, maxval + 1);
if (lumahist == NULL)
pm_error("Out of storage allocating array for %u histogram elements",
-diff -urNp a/editor/pnmpad.c b/editor/pnmpad.c
---- a/editor/pnmpad.c 2025-02-03 09:24:28.299500730 +0100
-+++ b/editor/pnmpad.c 2025-02-04 09:22:39.237595043 +0100
-@@ -1127,6 +1127,8 @@ main(int argc, const char ** argv) {
+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 9c7a77e..1aa578c 100644
+--- a/editor/pnmpad.c
++++ b/editor/pnmpad.c
+@@ -634,6 +634,8 @@ main(int argc, const char ** argv) {
computePadSizes(cmdline, cols, rows, &lpad, &rpad, &tpad, &bpad);
@@ -641,19 +2049,20 @@ diff -urNp a/editor/pnmpad.c b/editor/pnmpad.c
+ overflow_add(cols + lpad, rpad);
newcols = cols + lpad + rpad;
- if (cmdline.reportonly)
-diff -urNp a/editor/pnmremap.c b/editor/pnmremap.c
---- a/editor/pnmremap.c 2025-02-03 09:24:28.296500747 +0100
-+++ b/editor/pnmremap.c 2025-02-04 09:42:44.340919042 +0100
+ if (PNM_FORMAT_TYPE(format) == PBM_TYPE)
+diff --git a/editor/pnmremap.c b/editor/pnmremap.c
+index 0038f4d..a5950be 100644
+--- a/editor/pnmremap.c
++++ b/editor/pnmremap.c
@@ -468,6 +468,7 @@ fserr_init(struct pam * const pamP,
- -----------------------------------------------------------------------------*/
- unsigned int plane;
+
+ unsigned int const fserrSize = pamP->width + 2;
+ overflow_add(pamP->width, 2);
- unsigned int const fserrSz = pamP->width + 2;
-
fserrP->width = pamP->width;
-@@ -508,6 +509,7 @@ floydInitRow(struct pam * const pamP,
+
+ MALLOCARRAY(fserrP->thiserr, pamP->depth);
+@@ -506,6 +507,7 @@ floydInitRow(struct pam * const pamP,
unsigned int col;
@@ -661,82 +2070,122 @@ diff -urNp a/editor/pnmremap.c b/editor/pnmremap.c
for (col = 0; col < pamP->width + 2; ++col) {
unsigned int plane;
for (plane = 0; plane < pamP->depth; ++plane)
-diff -urNp a/editor/pnmscalefixed.c b/editor/pnmscalefixed.c
---- a/editor/pnmscalefixed.c 2025-02-03 09:24:28.299500730 +0100
-+++ b/editor/pnmscalefixed.c 2025-02-04 09:49:53.152275133 +0100
-@@ -215,6 +215,7 @@ compute_output_dimensions(const struct c
+diff --git a/editor/pnmremap.c.rej b/editor/pnmremap.c.rej
+new file mode 100644
+index 0000000..c627c20
+--- /dev/null
++++ b/editor/pnmremap.c.rej
+@@ -0,0 +1,10 @@
++--- editor/pnmremap.c
+++++ editor/pnmremap.c
++@@ -506,6 +507,7 @@ floydInitRow(struct pam * const pamP, struct Fserr * const fserrP) {
++
++ 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..747cd8f 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 <= cmdline.pixels / cols) {
+ if (rows * cols <= cmdline.pixels) {
*newrowsP = rows;
-@@ -222,6 +223,8 @@ compute_output_dimensions(const struct c
- } else {
- const double scale =
- sqrt( (float) cmdline.pixels / ((float) cols * (float) rows));
-+ overflow2(rows, scale);
-+ overflow2(scale, cols);
- *newrowsP = rows * scale;
- *newcolsP = cols * scale;
- }
-@@ -455,6 +458,9 @@ main(int argc, char **argv ) {
- pm_error("New image width (%d) is uncomputably large", newcols);
- if (newrows > INT_MAX / SCALE)
- pm_error("New image height (%d) is uncomputably large", newrows);
+@@ -265,6 +266,8 @@ compute_output_dimensions(const struct cmdline_info cmdline,
+
+ if (*newcolsP < 1) *newcolsP = 1;
+ if (*newrowsP < 1) *newrowsP = 1;
++
++ overflow2(*newcolsP, *newrowsP);
+ }
+
+
+@@ -446,6 +449,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;
-diff -urNp a/editor/specialty/pamoil.c b/editor/specialty/pamoil.c
---- a/editor/specialty/pamoil.c 2025-02-03 09:24:28.301500720 +0100
-+++ b/editor/specialty/pamoil.c 2025-02-04 09:56:21.543650456 +0100
-@@ -185,6 +185,7 @@ main(int argc, const char ** argv) {
-
- tuples = pnm_readpam(ifP, &inpam, PAM_STRUCT_SIZE(tuple_type));
+diff --git a/editor/ppmdither.c b/editor/ppmdither.c
+index ec1b977..e701e09 100644
+--- a/editor/ppmdither.c
++++ b/editor/ppmdither.c
+@@ -356,6 +356,11 @@ dithMatrix(unsigned int const dithPower) {
+ (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)
+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 -urNp a/lib/libpam.c b/lib/libpam.c
---- a/lib/libpam.c 2025-02-03 09:24:28.326500585 +0100
-+++ b/lib/libpam.c 2025-02-04 10:04:33.126859799 +0100
-@@ -258,6 +258,7 @@ allocPamRow(const struct pam * const pam
+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 = malloc(pamP->width * (sizeof(tuple *) + bytesPerTuple));
++ tuplerow = malloc2(pamP->width, (sizeof(tuple *) + bytesPerTuple));
if (tuplerow != NULL) {
-diff -urNp a/lib/libpammap.c b/lib/libpammap.c
---- a/lib/libpammap.c 2025-02-03 09:24:28.325500590 +0100
-+++ b/lib/libpammap.c 2025-02-04 10:05:45.382614292 +0100
-@@ -111,6 +111,9 @@ allocTupleIntListItem(struct pam * const
- if (pamP->depth > (UINT_MAX - sizeof(*retval)) / sizeof(sample))
- pm_error("Depth %u is too large for computation", pamP->depth);
+ /* Now we initialize the pointers to the individual tuples
+diff --git a/lib/libpammap.c b/lib/libpammap.c
+index 2222491..ba27a4c 100644
+--- a/lib/libpammap.c
++++ b/lib/libpammap.c
+@@ -108,7 +108,9 @@ allocTupleIntListItem(struct pam * const pamP) {
+ */
+ struct tupleint_list_item * retval;
+- unsigned int const size =
+ 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)
++ unsigned int const size =
+ sizeof(*retval) - sizeof(retval->tupleint.tuple)
+ pamP->depth * sizeof(sample);
-diff -urNp a/lib/libpm.c b/lib/libpm.c
---- a/lib/libpm.c 2025-02-03 09:24:28.324500595 +0100
-+++ b/lib/libpm.c 2025-02-04 10:27:02.795619696 +0100
-@@ -926,4 +926,52 @@ pm_parse_maxval(const char * const arg)
- return maxval;
+
+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
++ * Maths wrapping
+ */
-+
+
+void __overflow2(int a, int b)
+{
+ if(a < 0 || b < 0)
@@ -774,20 +2223,22 @@ diff -urNp a/lib/libpm.c b/lib/libpm.c
+ 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)
++ overflow2(b, c);
++ if(b*c == 0)
+ pm_error("Zero byte allocation");
+ return realloc(a, b*c);
+}
-diff -urNp a/lib/pm.h b/lib/pm.h
---- a/lib/pm.h 2025-02-03 09:24:28.327500579 +0100
-+++ b/lib/pm.h 2025-02-04 10:28:10.427411309 +0100
-@@ -439,6 +439,13 @@ pm_parse_height(const char * const arg);
- unsigned int
- pm_parse_maxval(const char * const arg);
+diff --git a/lib/pm.h b/lib/pm.h
+index 3fc92fb..1e30ce9 100644
+--- a/lib/pm.h
++++ b/lib/pm.h
+@@ -441,5 +441,12 @@ pm_parse_height(const char * const arg);
+ }
+ #endif
+void *malloc2(int, int);
+void *malloc3(int, int, int);
@@ -796,58 +2247,54 @@ diff -urNp a/lib/pm.h b/lib/pm.h
+void overflow3(int, int, int);
+void overflow_add(int, int);
+
- #ifdef __cplusplus
- }
+
#endif
-diff -urNp a/other/pnmcolormap.c b/other/pnmcolormap.c
---- a/other/pnmcolormap.c 2025-02-03 09:24:28.303500709 +0100
-+++ b/other/pnmcolormap.c 2025-02-04 10:29:08.620231936 +0100
-@@ -1130,8 +1130,10 @@ colormapToSquare(struct pam * const pamP
- unsigned int const intsqrt = (int)sqrt((float)colormap.size);
- if (SQR(intsqrt) == colormap.size)
+diff --git a/other/pnmcolormap.c b/other/pnmcolormap.c
+index f687f03..20cbfbd 100644
+--- a/other/pnmcolormap.c
++++ b/other/pnmcolormap.c
+@@ -840,6 +840,7 @@ colormapToSquare(struct pam * const pamP,
pamP->width = intsqrt;
-- else
-+ else {
-+ overflow_add(intsqrt, 1);
+ else
pamP->width = intsqrt + 1;
-+ }
++ overflow_add(intsqrt, 1);
}
{
unsigned int const intQuotient = colormap.size / pamP->width;
-diff -urNp a/urt/rle_addhist.c b/urt/rle_addhist.c
---- a/urt/rle_addhist.c 2025-02-03 09:24:28.360500401 +0100
-+++ b/urt/rle_addhist.c 2025-02-04 10:37:56.010607217 +0100
-@@ -52,6 +52,8 @@ newCommentLen(const char * const histoi
- for (i = 0; argv[i]; ++i) {
- size_t const thisArgLen = strlen(argv[i]);
- if (thisArgLen < UINT_MAX - length - 100) {
-+ overflow_add(length, thisArgLen);
-+ overflow_add(length+thisArgLen, 1);
- length += thisArgLen;
- length += 1; /* For the space */
- }
-@@ -61,10 +63,16 @@ newCommentLen(const char * const histoi
- 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;
-
-- if (old && *old)
-+ overflow_add(length, 1);
-+ if (old && *old) {
-+ overflow_add(length, strlen(old));
- length += strlen(old); /* add length if there. */
-+ }
-
- ++length; /* Add size of terminating NUL. */
-
-diff -urNp a/urt/rle.h b/urt/rle.h
---- a/urt/rle.h 2025-02-03 09:24:28.360500401 +0100
-+++ b/urt/rle.h 2025-02-04 10:33:12.842479585 +0100
-@@ -153,6 +153,17 @@ rle_hdr /* End of typedef. *
+diff --git a/urt/Runput.c b/urt/Runput.c
+index 3bc562a..645a376 100644
+--- a/urt/Runput.c
++++ b/urt/Runput.c
+@@ -202,10 +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 int *bg_color;
+- /*
++ 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 +225,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 0766d22..c80a5fa 100644
+--- a/urt/rle.h
++++ b/urt/rle.h
+@@ -160,6 +160,17 @@ rle_hdr /* End of typedef. */
*/
extern rle_hdr rle_dflt_hdr;
@@ -865,56 +2312,223 @@ diff -urNp a/urt/rle.h b/urt/rle.h
/* Declare RLE library routines. */
-diff -urNp a/urt/rle_hdr.c b/urt/rle_hdr.c
---- a/urt/rle_hdr.c 2025-02-03 09:24:28.360500401 +0100
-+++ b/urt/rle_hdr.c 2025-02-04 10:42:11.745682618 +0100
-@@ -148,7 +148,7 @@ rle_hdr_cp(rle_hdr * const fromHdrP,
- if (toHdrP->cmap) {
- size_t const size =
- toHdrP->ncmap * (1 << toHdrP->cmaplen) * sizeof(rle_map);
-- toHdrP->cmap = malloc(size);
-+ toHdrP->cmap = malloc3(toHdrP->ncmap, 1<cmaplen, sizeof(rle_map));
- if (!toHdrP->cmap)
- pm_error("Failed to allocate memory for %u color maps "
- "of length %u", toHdrP->ncmap, 1 << toHdrP->cmaplen);
-@@ -163,12 +163,16 @@ rle_hdr_cp(rle_hdr * const fromHdrP,
- const char ** cp;
+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. */
++ }
- /* Count the comments. */
-- for (cp = toHdrP->comments, size = 0; *cp; ++cp)
-+ for (cp = toHdrP->comments, size = 0; *cp; ++cp) {
-+ overflow_add(size,1);
- ++size;
+ 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 679811c..cc1f5cb 100644
+--- a/urt/rle_getrow.c
++++ b/urt/rle_getrow.c
+@@ -160,6 +160,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 1611324..7c9c010 100644
+--- a/urt/rle_hdr.c
++++ b/urt/rle_hdr.c
+@@ -80,7 +80,10 @@ int img_num;
+ /* Fill in with copies of the strings. */
+ if ( the_hdr->cmd != pgmname )
+ {
+- char *tmp = (char *)malloc( strlen( pgmname ) + 1 );
++ char *tmp;
++
++ overflow_add(strlen(pgmname), 1);
++ tmp = malloc( strlen(pgmname) + 1 );
+ RLE_CHECK_ALLOC( pgmname, tmp, 0 );
+ strcpy( tmp, pgmname );
+ the_hdr->cmd = tmp;
+@@ -88,8 +91,10 @@ int img_num;
+
+ if ( the_hdr->file_name != fname )
+ {
+- char *tmp = (char *)malloc( strlen( fname ) + 1 );
+- RLE_CHECK_ALLOC( pgmname, tmp, 0 );
++ char *tmp;
++ overflow_add(strlen(fname), 1);
++ tmp = malloc( strlen( fname ) + 1 );
++ RLE_CHECK_ALLOC( pgmname, tmp, 0 );
+ strcpy( tmp, fname );
+ the_hdr->file_name = tmp;
+ }
+@@ -153,6 +158,7 @@ rle_hdr *from_hdr, *to_hdr;
+ if ( to_hdr->bg_color )
+ {
+ int size = to_hdr->ncolors * sizeof(int);
++ overflow2(to_hdr->ncolors, sizeof(int));
+ to_hdr->bg_color = (int *)malloc( size );
+ RLE_CHECK_ALLOC( to_hdr->cmd, to_hdr->bg_color, "background color" );
+ memcpy( to_hdr->bg_color, from_hdr->bg_color, size );
+@@ -161,7 +167,7 @@ rle_hdr *from_hdr, *to_hdr;
+ if ( to_hdr->cmap )
+ {
+ int size = to_hdr->ncmap * (1 << to_hdr->cmaplen) * sizeof(rle_map);
+- to_hdr->cmap = (rle_map *)malloc( size );
++ to_hdr->cmap = (rle_map *)malloc3( to_hdr->ncmap, 1<cmaplen, sizeof(rle_map));
+ RLE_CHECK_ALLOC( to_hdr->cmd, to_hdr->cmap, "color map" );
+ memcpy( to_hdr->cmap, from_hdr->cmap, size );
+ }
+@@ -173,12 +179,17 @@ rle_hdr *from_hdr, *to_hdr;
+ {
+ int size = 0;
+ CONST_DECL char **cp;
+- for ( cp=to_hdr->comments; *cp; cp++ )
++ for ( cp=to_hdr->comments; *cp; cp++ )
++ {
++ overflow_add(size, 1);
+ size++; /* Count the comments. */
+ }
-
- /* Check if there are really any comments. */
- if (size > 0) {
-+ overflow_add(size,1);
- ++size; /* Copy the NULL pointer, too. */
+ /* Check if there are really any comments. */
+ if ( size )
+ {
++ 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 -urNp a/urt/rle_putcom.c b/urt/rle_putcom.c
---- a/urt/rle_putcom.c 2025-02-03 09:24:28.360500401 +0100
-+++ b/urt/rle_putcom.c 2025-02-04 10:43:04.472477242 +0100
-@@ -101,6 +101,7 @@ rle_putcom(const char * const value,
- for (i = 2, cp = hdrP->comments;
- *cp != NULL && i < UINT_MAX;
- ++i, ++cp) {
+ size *= sizeof(char *);
+ to_hdr->comments = (CONST_DECL char **)malloc( size );
+ RLE_CHECK_ALLOC( to_hdr->cmd, to_hdr->comments, "comments" );
+diff --git a/urt/rle_open_f.c b/urt/rle_open_f.c
+index ae8548b..c2ef37d 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;
-diff -urNp a/urt/Runput.c b/urt/Runput.c
---- a/urt/Runput.c 2025-02-03 09:24:28.360500401 +0100
-+++ b/urt/Runput.c 2025-02-04 10:30:24.683997548 +0100
-@@ -236,7 +236,7 @@ RunSetup(rle_hdr * const hdrP) {
- int * bg_color;
-
- assert(hdrP->ncolors < UINT_MAX);
+ 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..5e114bb 100644
+--- a/urt/scanargs.c
++++ b/urt/scanargs.c
+@@ -62,9 +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 ) )
-
-+ overflow_add(hdrP->ncolors, 1);
- MALLOCARRAY_NOFAIL(background, hdrP->ncolors + 1);
-
- /* If even number of bg color bytes, put out one more to get to
++#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 );
+ static int _do_scanargs( int argc, char **argv, CONST_DECL char *format,
diff --git a/netpbm-security-scripts.patch b/netpbm-security-scripts.patch
new file mode 100644
index 0000000..0ba822a
--- /dev/null
+++ b/netpbm-security-scripts.patch
@@ -0,0 +1,267 @@
+diff --git a/editor/ppmfade b/editor/ppmfade
+index dcd7bf2..5091651 100755
+--- a/editor/ppmfade
++++ b/editor/ppmfade
+@@ -40,6 +40,7 @@ exec perl -w -x -S -- "$0" "$@"
+ #
+ ##############################################################################
+ use strict;
++use File::Temp "tempdir";
+
+ sub doVersionHack($) {
+ my ($argvR) = @_;
+@@ -149,20 +150,26 @@ if ($first_file ne "undefined") {
+
+ print("Frames are " . $width . "W x " . $height . "H\n");
+
++#
++# We create a tmp-directory right here
++#
++my $tmpdir = tempdir("ppmfade.XXXXXX", CLEANUP => 1);
++
++
+ if ($first_file eq "undefined") {
+ print "Fading from black to ";
+- system("ppmmake \\#000 $width $height >junk1$$.ppm");
++ system("ppmmake \\#000 $width $height >$tmpdir/junk1$$.ppm");
+ } else {
+ print "Fading from $first_file to ";
+- system("cp", $first_file, "junk1$$.ppm");
++ system("cp", $first_file, "$tmpdir/junk1$$.ppm");
+ }
+
+ if ($last_file eq "undefined") {
+ print "black.\n";
+- system("ppmmake \\#000 $width $height >junk2$$.ppm");
++ system("ppmmake \\#000 $width $height >$tmpdir/junk2$$.ppm");
+ } else {
+ print "$last_file\n";
+- system("cp", $last_file, "junk2$$.ppm");
++ system("cp", $last_file, "$tmpdir/junk2$$.ppm");
+ }
+
+ #
+@@ -170,14 +177,14 @@ if ($last_file eq "undefined") {
+ #
+
+ # Here's what our temporary files are:
+-# junk1$$.ppm: The original (fade-from) image
+-# junk2$$.ppm: The target (fade-from) image
+-# junk3$$.ppm: The frame of the fade for the current iteration of the
+-# the for loop.
+-# junk1a$$.ppm: If the fade involves a ppmmix sequence from one intermediate
+-# image to another, this is the first frame of that
+-# sequence.
+-# junk2a$$.ppm: This is the last frame of the above-mentioned ppmmix sequence
++# $tmpdir/junk1$$.ppm: The original (fade-from) image
++# $tmpdir/junk2$$.ppm: The target (fade-from) image
++# $tmpdir/junk3$$.ppm: The frame of the fade for the current iteration of the
++# the for loop.
++# $tmpdir/junk1a$$.ppm: If the fade involves a ppmmix sequence from one intermediate
++# image to another, this is the first frame of that
++# sequence.
++# $tmpdir/junk2a$$.ppm: This is the last frame of the above-mentioned ppmmix sequence
+
+ my $i; # Frame number
+ for ($i = 1; $i <= $nframes; $i++) {
+@@ -185,147 +192,147 @@ for ($i = 1; $i <= $nframes; $i++) {
+ if ($mode eq $SPREAD) {
+ if ($i <= 10) {
+ my $n = $spline20[$i] * 100;
+- system("ppmspread $n junk1$$.ppm >junk3$$.ppm");
++ system("ppmspread $n $tmpdir/junk1$$.ppm >$tmpdir/junk3$$.ppm");
+ } elsif ($i <= 20) {
+ my $n;
+ $n = $spline20[$i] * 100;
+- system("ppmspread $n junk1$$.ppm >junk1a$$.ppm");
++ system("ppmspread $n $tmpdir/junk1$$.ppm >$tmpdir/junk1a$$.ppm");
+ $n = (1-$spline20[$i-10]) * 100;
+- system("ppmspread $n junk2$$.ppm >junk2a$$.ppm");
++ system("ppmspread $n $tmpdir/junk2$$.ppm >$tmpdir/junk2a$$.ppm");
+ $n = $spline10[$i-10];
+- system("ppmmix $n junk1a$$.ppm junk2a$$.ppm >junk3$$.ppm");
++ system("ppmmix $n $tmpdir/junk1a$$.ppm $tmpdir/junk2a$$.ppm >$tmpdir/junk3$$.ppm");
+ } else {
+ my $n = (1-$spline20[$i-10])*100;
+- system("ppmspread $n junk2$$.ppm >junk3$$.ppm");
++ system("ppmspread $n $tmpdir/junk2$$.ppm >$tmpdir/junk3$$.ppm");
+ }
+ } elsif ($mode eq $SHIFT) {
+ if ($i <= 10) {
+ my $n = $spline20[$i] * 100;
+- system("ppmshift $n junk1$$.ppm >junk3$$.ppm");
++ system("ppmshift $n $tmpdir/junk1$$.ppm >$tmpdir/junk3$$.ppm");
+ } elsif ($i <= 20) {
+ my $n;
+ $n = $spline20[$i] * 100;
+- system("ppmshift $n junk1$$.ppm >junk1a$$.ppm");
++ system("ppmshift $n $tmpdir/junk1$$.ppm >$tmpdir/junk1a$$.ppm");
+ $n = (1-$spline20[$i-10])*100;
+- system("ppmshift $n junk2$$.ppm >junk2a$$.ppm");
++ system("ppmshift $n $tmpdir/junk2$$.ppm >$tmpdir/junk2a$$.ppm");
+ $n = $spline10[$i-10];
+- system("ppmmix $n junk1a$$.ppm junk2a$$.ppm >junk3$$.ppm");
++ system("ppmmix $n $tmpdir/junk1a$$.ppm $tmpdir/junk2a$$.ppm >$tmpdir/junk3$$.ppm");
+ } else {
+ my $n = (1-$spline20[$i-10]) * 100;
+- system("ppmshift $n junk2$$.ppm >junk3$$.ppm");
++ system("ppmshift $n $tmpdir/junk2$$.ppm >$tmpdir/junk3$$.ppm");
+ }
+ } elsif ($mode eq $RELIEF) {
+ if ($i == 1) {
+- system("ppmrelief junk1$$.ppm >junk1r$$.ppm");
++ system("ppmrelief $tmpdir/junk1$$.ppm >$tmpdir/junk1r$$.ppm");
+ }
+ if ($i <= 10) {
+ my $n = $spline10[$i];
+- system("ppmmix $n junk1$$.ppm junk1r$$.ppm >junk3$$.ppm");
++ system("ppmmix $n $tmpdir/junk1$$.ppm $tmpdir/junk1r$$.ppm >$tmpdir/junk3$$.ppm");
+ } elsif ($i <= 20) {
+ my $n = $spline10[$i-10];
+- system("ppmmix $n junk1r$$.ppm junk2r$$.ppm >junk3$$.ppm");
++ system("ppmmix $n $tmpdir/junk1r$$.ppm $tmpdir/junk2r$$.ppm >$tmpdir/junk3$$.ppm");
+ } else {
+ my $n = $spline10[$i-20];
+- system("ppmmix $n junk2r$$.ppm junk2$$.ppm >junk3$$.ppm");
++ system("ppmmix $n $tmpdir/junk2r$$.ppm $tmpdir/junk2$$.ppm >$tmpdir/junk3$$.ppm");
+ }
+ if ($i == 10) {
+- system("ppmrelief junk2$$.ppm >junk2r$$.ppm");
++ system("ppmrelief $tmpdir/junk2$$.ppm >$tmpdir/junk2r$$.ppm");
+ }
+ } elsif ($mode eq $OIL) {
+ if ($i == 1) {
+- system("ppmtopgm junk1$$.ppm | pgmoil >junko$$.ppm");
+- system("rgb3toppm junko$$.ppm junko$$.ppm junko$$.ppm " .
+- ">junk1o$$.ppm");
++ system("ppmtopgm $tmpdir/junk1$$.ppm | pgmoil >$tmpdir/junko$$.ppm");
++ system("rgb3toppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm " .
++ ">$tmpdir/junk1o$$.ppm");
+ }
+ if ($i <= 10) {
+ my $n = $spline10[$i];
+- system("ppmmix $n junk1$$.ppm junk1o$$.ppm >junk3$$.ppm");
++ system("ppmmix $n $tmpdir/junk1$$.ppm $tmpdir/junk1o$$.ppm >$tmpdir/junk3$$.ppm");
+ } elsif ($i <= 20) {
+ my $n = $spline10[$i-10];
+- system("ppmmix $n junk1o$$.ppm junk2o$$.ppm >junk3$$.ppm");
++ system("ppmmix $n $tmpdir/junk1o$$.ppm $tmpdir/junk2o$$.ppm >$tmpdir/junk3$$.ppm");
+ } else {
+ my $n = $spline10[$i-20];
+- system("ppmmix $n junk2o$$.ppm junk2$$.ppm >junk3$$.ppm");
++ system("ppmmix $n $tmpdir/junk2o$$.ppm $tmpdir/junk2$$.ppm >$tmpdir/junk3$$.ppm");
+ }
+ if ($i == 10) {
+- system("ppmtopgm junk2$$.ppm | pgmoil >junko$$.ppm");
+- system("rgb3toppm junko$$.ppm junko$$.ppm junko$$.ppm " .
+- ">junk2o$$.ppm");
++ system("ppmtopgm $tmpdir/junk2$$.ppm | pgmoil >$tmpdir/junko$$.ppm");
++ system("rgb3toppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm " .
++ ">$tmpdir/junk2o$$.ppm");
+ }
+ } elsif ($mode eq $EDGE) {
+ if ($i == 1) {
+- system("ppmtopgm junk1$$.ppm | pgmedge >junko$$.ppm");
+- system("rgb3toppm junko$$.ppm junko$$.ppm junko$$.ppm " .
+- ">junk1o$$.ppm");
++ system("ppmtopgm $tmpdir/junk1$$.ppm | pgmedge >$tmpdir/junko$$.ppm");
++ system("rgb3toppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm " .
++ ">$tmpdir/junk1o$$.ppm");
+ }
+ if ($i <= 10) {
+ my $n = $spline10[$i];
+- system("ppmmix $n junk1$$.ppm junk1o$$.ppm >junk3$$.ppm");
++ system("ppmmix $n $tmpdir/junk1$$.ppm $tmpdir/junk1o$$.ppm >$tmpdir/junk3$$.ppm");
+ } elsif ($i <= 20) {
+ my $n = $spline10[$i-10];
+- system("ppmmix $n junk1o$$.ppm junk2o$$.ppm >junk3$$.ppm");
++ system("ppmmix $n $tmpdir/junk1o$$.ppm $tmpdir/junk2o$$.ppm >$tmpdir/junk3$$.ppm");
+ } else {
+ my $n = $spline10[$i-20];
+- system("ppmmix $n junk2o$$.ppm junk2$$.ppm >junk3$$.ppm");
++ system("ppmmix $n $tmpdir/junk2o$$.ppm $tmpdir/junk2$$.ppm >$tmpdir/junk3$$.ppm");
+ }
+ if ($i == 10) {
+- system("ppmtopgm junk2$$.ppm | pgmedge >junko$$.ppm");
+- system("rgb3toppm junko$$.ppm junko$$.ppm junko$$.ppm " .
+- ">junk2o$$.ppm");
++ system("ppmtopgm $tmpdir/junk2$$.ppm | pgmedge >$tmpdir/junko$$.ppm");
++ system("rgb3toppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm " .
++ ">$tmpdir/junk2o$$.ppm");
+ }
+ } elsif ($mode eq $BENTLEY) {
+ if ($i == 1) {
+- system("ppmtopgm junk1$$.ppm | pgmbentley >junko$$.ppm");
+- system("rgb3toppm junko$$.ppm junko$$.ppm junko$$.ppm " .
+- ">junk1o$$.ppm");
++ system("ppmtopgm $tmpdir/junk1$$.ppm | pgmbentley >$tmpdir/junko$$.ppm");
++ system("rgb3toppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm " .
++ ">$tmpdir/junk1o$$.ppm");
+ }
+ if ($i <= 10) {
+ my $n = $spline10[$i];
+- system("ppmmix $n junk1$$.ppm junk1o$$.ppm >junk3$$.ppm");
++ system("ppmmix $n $tmpdir/junk1$$.ppm $tmpdir/junk1o$$.ppm >$tmpdir/junk3$$.ppm");
+ } elsif ($i <= 20) {
+ my $n = $spline10[$i-10];
+- system("ppmmix $n junk1o$$.ppm junk2o$$.ppm >junk3$$.ppm");
++ system("ppmmix $n $tmpdir/junk1o$$.ppm $tmpdir/junk2o$$.ppm >$tmpdir/junk3$$.ppm");
+ } else {
+ my $n = $spline10[$i-20];
+- system("ppmmix $n junk2o$$.ppm junk2$$.ppm >junk3$$.ppm");
++ system("ppmmix $n $tmpdir/junk2o$$.ppm $tmpdir/junk2$$.ppm >$tmpdir/junk3$$.ppm");
+ }
+ if ($i == 10) {
+- system("ppmtopgm junk2$$.ppm | pgmbentley >junko$$.ppm");
+- system("rgb3toppm junko$$.ppm junko$$.ppm junko$$.ppm " .
+- ">junk2o$$.ppm");
++ system("ppmtopgm $tmpdir/junk2$$.ppm | pgmbentley >$tmpdir/junko$$.ppm");
++ system("rgb3toppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm $tmpdir/junko$$.ppm " .
++ ">$tmpdir/junk2o$$.ppm");
+ }
+ } elsif ($mode eq $BLOCK) {
+ if ($i <= 10) {
+ my $n = 1 - 1.9*$spline20[$i];
+- system("pamscale $n junk1$$.ppm | " .
+- "pamscale -width $width -height $height >junk3$$.ppm");
++ system("pamscale $n $tmpdir/junk1$$.ppm | " .
++ "pamscale -width $width -height $height >$tmpdir/junk3$$.ppm");
+ } elsif ($i <= 20) {
+ my $n = $spline10[$i-10];
+- system("ppmmix $n junk1a$$.ppm junk2a$$.ppm >junk3$$.ppm");
++ system("ppmmix $n $tmpdir/junk1a$$.ppm $tmpdir/junk2a$$.ppm >$tmpdir/junk3$$.ppm");
+ } else {
+ my $n = 1 - 1.9*$spline20[31-$i];
+- system("pamscale $n junk2$$.ppm | " .
+- "pamscale -width $width -height $height >junk3$$.ppm");
++ system("pamscale $n $tmpdir/junk2$$.ppm | " .
++ "pamscale -width $width -height $height >$tmpdir/junk3$$.ppm");
+ }
+ if ($i == 10) {
+- system("cp", "junk3$$.ppm", "junk1a$$.ppm");
+- system("pamscale $n junk2$$.ppm | " .
+- "pamscale -width $width -height $height >junk2a$$.ppm");
++ system("cp", "$tmpdir/junk3$$.ppm", "$tmpdir/junk1a$$.ppm");
++ system("pamscale $n $tmpdir/junk2$$.ppm | " .
++ "pamscale -width $width -height $height >$tmpdir/junk2a$$.ppm");
+ }
+ } elsif ($mode eq $MIX) {
+ my $fade_factor = sqrt(1/($nframes-$i+1));
+- system("ppmmix $fade_factor junk1$$.ppm junk2$$.ppm >junk3$$.ppm");
++ system("ppmmix $fade_factor $tmpdir/junk1$$.ppm $tmpdir/junk2$$.ppm >$tmpdir/junk3$$.ppm");
+ } else {
+ print("Internal error: impossible mode value '$mode'\n");
+ }
+
+ my $outfile = sprintf("%s.%04d.ppm", $base_name, $i);
+- system("cp", "junk3$$.ppm", $outfile);
++ system("cp", "$tmpdir/junk3$$.ppm", $outfile);
+ }
+
+ #
+ # Clean up shop.
+ #
+-system("rm junk*$$.ppm");
++system("rm $tmpdir/junk*$$.ppm");
+
+ exit(0);
diff --git a/netpbm-shlib-ldflags.patch b/netpbm-shlib-ldflags.patch
deleted file mode 100644
index ffad115..0000000
--- a/netpbm-shlib-ldflags.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff --git a/config.mk.in b/config.mk.in
-index 50687ba..d35c982 100644
---- a/config.mk.in
-+++ b/config.mk.in
-@@ -250,7 +250,7 @@ EXE =
-
- # Here, $(SONAME) resolves to the soname for the shared library being created.
- # The following are gcc options. This works on GNU libc systems.
--LDSHLIB = -shared -Wl,-soname,$(SONAME)
-+LDSHLIB = $(LDFLAGS) -shared -Wl,-soname,$(SONAME)
- # You need -nostart instead of -shared on BeOS. Though the BeOS compiler is
- # ostensibly gcc, it has the -nostart option, which is not mentioned in gcc
- # documentation and doesn't exist in at least one non-BeOS installation.
diff --git a/netpbm-userguide.patch b/netpbm-userguide.patch
new file mode 100644
index 0000000..3efdb6f
--- /dev/null
+++ b/netpbm-userguide.patch
@@ -0,0 +1,9 @@
+diff --git a/userguide/pammixmulti.html b/userguide/pammixmulti.html
+index c5854c3..a18fa14 100755
+--- a/userguide/pammixmulti.html
++++ b/userguide/pammixmulti.html
+@@ -1,4 +1,3 @@
+-
+
+
+
diff --git a/netpbm.spec b/netpbm.spec
index 110e827..baaf050 100644
--- a/netpbm.spec
+++ b/netpbm.spec
@@ -1,9 +1,9 @@
Summary: A library for handling different graphics file formats
Name: netpbm
-Version: 11.13.00
+Version: 10.87.00
Release: 1%{?dist}
# See copyright_summary for details
-License: BSD-3-Clause AND GPL-2.0-only AND LGPL-2.1-or-later AND GPL-3.0-or-later AND IJG AND MIT AND NTP AND PostgreSQL AND LicenseRef-MIT-CRL-Xim AND LicenseRef-Fedora-Public-Domain
+License: BSD and GPLv2 and IJG and MIT and Public Domain
URL: http://netpbm.sourceforge.net/
# Source0 is prepared by
# svn checkout https://svn.code.sf.net/p/netpbm/code/advanced netpbm-%%{version}
@@ -11,6 +11,7 @@ URL: http://netpbm.sourceforge.net/
# svn checkout https://svn.code.sf.net/p/netpbm/code/trunk/test netpbm-%%{version}/test
# and removing the .svn directories ( find -name "\.svn" -type d -print0 | xargs -0 rm -rf )
Source0: netpbm-%{version}.tar.xz
+Patch0: netpbm-security-scripts.patch
Patch1: netpbm-security-code.patch
Patch2: netpbm-ppmfadeusage.patch
Patch3: netpbm-CVE-2017-2587.patch
@@ -23,18 +24,17 @@ Patch9: netpbm-xwdfix.patch
Patch10: netpbm-multilib.patch
Patch11: netpbm-glibc.patch
Patch12: netpbm-docfix.patch
-Patch13: netpbm-pamtojpeg2k.patch
-Patch14: netpbm-manfix.patch
-Patch15: netpbm-jasper.patch
-Patch16: netpbm-libdir-so.patch
-Patch17: netpbm-c99.patch
-Patch18: netpbm-shlib-ldflags.patch
+Patch13: netpbm-fiasco-overflow.patch
+Patch14: netpbm-cmuwtopbm.patch
+Patch15: netpbm-pamtojpeg2k.patch
+Patch16: netpbm-manfix.patch
+Patch17: netpbm-manual-pages.patch
+Patch18: netpbm-jasper.patch
+Patch19: netpbm-userguide.patch
+Patch20: netpbm-libdir-so.patch
-BuildRequires: make
BuildRequires: libjpeg-devel, libpng-devel, libtiff-devel, flex, gcc, jbigkit-devel
BuildRequires: libX11-devel, perl-generators, python3, jasper-devel, libxml2-devel
-BuildRequires: perl(Config), perl(Cwd), perl(English), perl(Fcntl), perl(File::Basename)
-BuildRequires: perl(strict)
%if (0%{?fedora} && 0%{?fedora} < 28) || (0%{?rhel} || 0%{?rhel} <= 7)
BuildRequires: ghostscript-core
%else
@@ -92,7 +92,6 @@ rm -rf converter/other/jpeg2000/libjasper/
rm -rf converter/other/jbig/libjbig/
%build
-%set_build_flags
./configure < - 11.13.00-1
-- New upstream release 11.13.00
-
-* Tue Oct 14 2025 Josef Ridky - 11.12.00-1
-- New upstream release 11.12.00
-
-* Thu Jul 24 2025 Fedora Release Engineering - 11.10.00-2
-- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild
-
-* Tue Apr 08 2025 Josef Ridky - 11.10.00-1
-- New upstream release 11.10.00 (#2355869)
-
-* Thu Feb 06 2025 Josef Ridky - 11.09.00-2
-- add LDFLAGS patch (RHEL-70899)
-
-* Tue Jan 28 2025 Josef Ridky - 11.09.00-1
-- New upstream release 11.09.00 (#2218312)
-- Review and update license field
-
-* Fri Jan 17 2025 Fedora Release Engineering - 11.02.00-10
-- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild
-
-* Fri Dec 13 2024 Lukáš Zaoral - 11.02.00-9
-- build netpbm with correct LDFLAGS (RHEL-70899)
-
-* Mon Sep 02 2024 Miroslav Suchý - 11.02.00-8
-- convert license to SPDX
-
-* Thu Jul 18 2024 Fedora Release Engineering - 11.02.00-7
-- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild
-
-* Thu Jan 25 2024 Fedora Release Engineering - 11.02.00-6
-- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
-
-* Sun Jan 21 2024 Florian Weimer - 11.02.00-5
-- GCC 14 compatibility fixes:
- Drop netpbm-cmuwtopbm.patch to fix an out-of-bounds stack write (#2259450)
- Stub out unused converter/other/jpeg2000/libjasper_compat.c (#2259448)
-
-* Sun Jan 21 2024 Fedora Release Engineering - 11.02.00-4
-- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
-
-* Tue Nov 28 2023 Orion Poplawski - 11.02.00-3
-- Rebuild for jasper 4.1
-
-* Thu Jul 20 2023 Fedora Release Engineering - 11.02.00-2
-- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
-
-* Mon Mar 27 2023 Josef Ridky - 11.02.00-1
-- New upstream release 11.02.00 (#2157125)
-
-* Thu Jan 19 2023 Fedora Release Engineering - 11.01.00-2
-- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
-
-* Mon Jan 02 2023 Josef Ridky - 11.01.00-1
-- New upstream release 11.01.00 (#2157125)
-
-* Fri Dec 02 2022 Florian Weimer - 11.00.00-2
-- Port downstream-specific patches to C99
-
-* Tue Oct 04 2022 Josef Ridky - 11.00.00-1
-- New upstream release 11.00.00 (#2130384)
-
-* Fri Jul 22 2022 Fedora Release Engineering - 10.99.00-2
-- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
-
-* Tue Jun 28 2022 Josef Ridky - 10.99.00-1
-- New upstream release 10.99.00 (#2068865)
-- Use %%set_build_flags to set environment variables
-
-* Sun Feb 13 2022 Josef Ridky - 10.97.00-4
-- Bump spec for new jasper
-
-* Fri Feb 11 2022 Josef Ridky - 10.97.00-3
-- Rebuild for new jasper
-
-* Thu Jan 20 2022 Fedora Release Engineering - 10.97.00-2
-- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
-
-* Mon Jan 03 2022 Josef Ridky - 10.97.00-1
-- New upstream release 10.97.00 (#2035806)
-
-* Mon Oct 04 2021 Josef Ridky - 10.96.00-1
-- New upstream release 10.96.00 (#2007871)
-
-* Thu Jul 22 2021 Fedora Release Engineering - 10.95.00-2
-- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
-
-* Thu Jul 15 2021 Josef Ridky - 10.95.00-1
-- New upstream release 10.95.00 (#1977974)
-
-* Wed Mar 31 2021 Josef Ridky - 10.94.05-1
-- New upstream release 10.94.05 (#1943837)
-
-* Mon Jan 25 2021 Josef Ridky - 10.93.00-1
-- New upstream release 10.93.00 (#1911159)
-
-* Wed Oct 07 2020 Josef Ridky - 10.92.00-1
-- New upstream release 10.92.00 (#1851753)
-
-* Tue Jul 28 2020 Fedora Release Engineering - 10.90.00-2
-- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
-
-* Thu Mar 26 2020 Josef Ridky - 10.90.00-1
-- New upstream release 10.90.00 (#1817279)
-
-* Wed Mar 25 2020 Jitka Plesnikova - 10.89.00-3
-- Add perl dependencies for build
-
-* Wed Jan 29 2020 Fedora Release Engineering - 10.89.00-2
-- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
-
-* Mon Jan 06 2020 Josef Ridky - 10.89.00-1
-- New upstream release 10.89.00 (#1787801)
-
-* Mon Dec 09 2019 Josef Ridky - 10.88.00-1
-- New upstream release (#1756647)
-
* Wed Aug 21 2019 Josef Ridky - 10.87.00-1
- New upstream release (#1725280)
diff --git a/sources b/sources
index 4e39977..c5c4c64 100644
--- a/sources
+++ b/sources
@@ -1 +1 @@
-SHA512 (netpbm-11.13.00.tar.xz) = 0914061c7c8d638147afb76cbf23609b3ae43aca4120e4297fd5db6887d5381469d6944cdbdc1c66d26f54ec68d62355693c08b830dde823061e37c51480b678
+SHA512 (netpbm-10.87.00.tar.xz) = 8245dd4b181d9e9b74b47af3e04e94143f03197ac4bc1f50009d66e16ec156c4d4a8fcefcfa90f6fea902f12cf3e5d3f34d220b1ed3333e2fe2d23da2293ea24