|
|
608b37 |
diff -urNp old/analyzer/pgmtexture.c new/analyzer/pgmtexture.c
|
|
|
608b37 |
--- old/analyzer/pgmtexture.c 2017-09-05 15:09:00.975207528 +0200
|
|
|
608b37 |
+++ new/analyzer/pgmtexture.c 2017-09-05 15:11:44.193390835 +0200
|
|
|
608b37 |
@@ -97,7 +97,7 @@ vector(unsigned int const nl,
|
|
|
608b37 |
float * v;
|
|
|
608b37 |
|
|
|
608b37 |
assert(nh >= nl);
|
|
|
608b37 |
-
|
|
|
608b37 |
+ overflow_add(nh - nl, 1);
|
|
|
608b37 |
MALLOCARRAY(v, (unsigned) (nh - nl + 1));
|
|
|
608b37 |
|
|
|
608b37 |
if (v == NULL)
|
|
|
608b37 |
@@ -129,6 +129,7 @@ matrix (unsigned int const nrl,
|
|
|
608b37 |
assert(nrh >= nrl);
|
|
|
608b37 |
|
|
|
608b37 |
/* allocate pointers to rows */
|
|
|
608b37 |
+ overflow_add(nrh - nrl, 1);
|
|
|
608b37 |
MALLOCARRAY(m, (unsigned) (nrh - nrl + 1));
|
|
|
608b37 |
if (m == NULL)
|
|
|
608b37 |
pm_error("Unable to allocate memory for a matrix.");
|
|
|
608b37 |
@@ -137,6 +138,7 @@ matrix (unsigned int const nrl,
|
|
|
608b37 |
|
|
|
608b37 |
assert (nch >= ncl);
|
|
|
608b37 |
|
|
|
608b37 |
+ overflow_add(nch - ncl, 1);
|
|
|
608b37 |
/* allocate rows and set pointers to them */
|
|
|
608b37 |
for (i = nrl; i <= nrh; ++i) {
|
|
|
608b37 |
MALLOCARRAY(m[i], (unsigned) (nch - ncl + 1));
|
|
|
608b37 |
diff -urNp old/converter/other/gemtopnm.c new/converter/other/gemtopnm.c
|
|
|
608b37 |
--- old/converter/other/gemtopnm.c 2017-09-05 15:09:00.990207453 +0200
|
|
|
608b37 |
+++ new/converter/other/gemtopnm.c 2017-09-05 15:12:20.786208419 +0200
|
|
|
608b37 |
@@ -106,6 +106,7 @@ main(argc, argv)
|
|
|
608b37 |
|
|
|
608b37 |
pnm_writepnminit( stdout, cols, rows, MAXVAL, type, 0 );
|
|
|
608b37 |
|
|
|
608b37 |
+ overflow_add(cols, padright);
|
|
|
608b37 |
{
|
|
|
608b37 |
/* allocate input row data structure */
|
|
|
608b37 |
int plane;
|
|
|
608b37 |
diff -urNp old/converter/other/jpegtopnm.c new/converter/other/jpegtopnm.c
|
|
|
608b37 |
--- old/converter/other/jpegtopnm.c 2017-09-05 15:09:00.993207438 +0200
|
|
|
608b37 |
+++ new/converter/other/jpegtopnm.c 2017-09-05 15:13:02.322001620 +0200
|
|
|
608b37 |
@@ -862,6 +862,8 @@ convertImage(FILE *
|
|
|
608b37 |
/* Calculate output image dimensions so we can allocate space */
|
|
|
608b37 |
jpeg_calc_output_dimensions(cinfoP);
|
|
|
608b37 |
|
|
|
608b37 |
+ overflow2(cinfoP->output_width, cinfoP->output_components);
|
|
|
608b37 |
+
|
|
|
608b37 |
/* Start decompressor */
|
|
|
608b37 |
jpeg_start_decompress(cinfoP);
|
|
|
608b37 |
|
|
|
608b37 |
diff -urNp old/converter/other/pbmtopgm.c new/converter/other/pbmtopgm.c
|
|
|
608b37 |
--- old/converter/other/pbmtopgm.c 2017-09-05 15:09:00.991207448 +0200
|
|
|
608b37 |
+++ new/converter/other/pbmtopgm.c 2017-09-05 15:13:32.640850830 +0200
|
|
|
608b37 |
@@ -47,6 +47,7 @@ main(int argc, char *argv[]) {
|
|
|
608b37 |
"than the image height (%u rows)", height, rows);
|
|
|
608b37 |
|
|
|
608b37 |
outrow = pgm_allocrow(cols) ;
|
|
|
608b37 |
+ overflow2(width, height);
|
|
|
608b37 |
maxval = MIN(PGM_OVERALLMAXVAL, width*height);
|
|
|
608b37 |
pgm_writepgminit(stdout, cols, rows, maxval, 0) ;
|
|
|
608b37 |
|
|
|
608b37 |
diff -urNp old/converter/other/pnmtoddif.c new/converter/other/pnmtoddif.c
|
|
|
608b37 |
--- old/converter/other/pnmtoddif.c 2017-09-05 15:09:00.991207448 +0200
|
|
|
608b37 |
+++ new/converter/other/pnmtoddif.c 2017-09-05 15:14:34.400564239 +0200
|
|
|
608b37 |
@@ -629,6 +629,7 @@ main(int argc, char *argv[]) {
|
|
|
608b37 |
switch (PNM_FORMAT_TYPE(format)) {
|
|
|
608b37 |
case PBM_TYPE:
|
|
|
608b37 |
ip.bits_per_pixel = 1;
|
|
|
608b37 |
+ overflow_add(cols, 7);
|
|
|
608b37 |
ip.bytes_per_line = (cols + 7) / 8;
|
|
|
608b37 |
ip.spectral = 2;
|
|
|
608b37 |
ip.components = 1;
|
|
|
608b37 |
@@ -644,6 +645,7 @@ main(int argc, char *argv[]) {
|
|
|
608b37 |
ip.polarity = 2;
|
|
|
608b37 |
break;
|
|
|
608b37 |
case PPM_TYPE:
|
|
|
608b37 |
+ overflow2(cols, 3);
|
|
|
608b37 |
ip.bytes_per_line = 3 * cols;
|
|
|
608b37 |
ip.bits_per_pixel = 24;
|
|
|
608b37 |
ip.spectral = 5;
|
|
|
608b37 |
diff -urNp old/converter/other/pnmtojpeg.c new/converter/other/pnmtojpeg.c
|
|
|
608b37 |
--- old/converter/other/pnmtojpeg.c 2017-09-05 15:09:00.992207443 +0200
|
|
|
608b37 |
+++ new/converter/other/pnmtojpeg.c 2017-09-05 15:16:52.065875364 +0200
|
|
|
608b37 |
@@ -606,7 +606,11 @@ read_scan_script(j_compress_ptr const ci
|
|
|
608b37 |
want JPOOL_PERMANENT.
|
|
|
608b37 |
*/
|
|
|
608b37 |
const unsigned int scan_info_size = nscans * sizeof(jpeg_scan_info);
|
|
|
608b37 |
- jpeg_scan_info * const scan_info =
|
|
|
608b37 |
+ const jpeg_scan_info * scan_info;
|
|
|
608b37 |
+
|
|
|
608b37 |
+ overflow2(nscans, sizeof(jpeg_scan_info));
|
|
|
608b37 |
+
|
|
|
608b37 |
+ scan_info =
|
|
|
608b37 |
(jpeg_scan_info *)
|
|
|
608b37 |
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
|
|
608b37 |
scan_info_size);
|
|
|
608b37 |
@@ -938,6 +942,8 @@ compute_rescaling_array(JSAMPLE ** const
|
|
|
608b37 |
const long half_maxval = maxval / 2;
|
|
|
608b37 |
long val;
|
|
|
608b37 |
|
|
|
608b37 |
+ overflow_add(maxval, 1);
|
|
|
608b37 |
+ overflow2(maxval+1, sizeof(JSAMPLE));
|
|
|
608b37 |
*rescale_p = (JSAMPLE *)
|
|
|
608b37 |
(cinfo.mem->alloc_small) ((j_common_ptr) &cinfo, JPOOL_IMAGE,
|
|
|
608b37 |
(size_t) (((long) maxval + 1L) *
|
|
|
608b37 |
@@ -1016,6 +1022,7 @@ convert_scanlines(struct jpeg_compress_s
|
|
|
608b37 |
*/
|
|
|
608b37 |
|
|
|
608b37 |
/* Allocate the libpnm output and compressor input buffers */
|
|
|
608b37 |
+ overflow2(cinfo_p->image_width, cinfo_p->input_components);
|
|
|
608b37 |
buffer = (*cinfo_p->mem->alloc_sarray)
|
|
|
608b37 |
((j_common_ptr) cinfo_p, JPOOL_IMAGE,
|
|
|
608b37 |
(unsigned int) cinfo_p->image_width * cinfo_p->input_components,
|
|
|
608b37 |
diff -urNp old/converter/other/pnmtops.c new/converter/other/pnmtops.c
|
|
|
608b37 |
--- old/converter/other/pnmtops.c 2017-09-05 15:09:00.993207438 +0200
|
|
|
608b37 |
+++ new/converter/other/pnmtops.c 2017-09-05 15:18:52.602038826 +0200
|
|
|
608b37 |
@@ -293,18 +293,22 @@ parseCommandLine(int argc, const char **
|
|
|
608b37 |
|
|
|
608b37 |
validateCompDimension(width, 72, "-width value");
|
|
|
608b37 |
validateCompDimension(height, 72, "-height value");
|
|
|
608b37 |
-
|
|
|
608b37 |
+
|
|
|
608b37 |
+ overflow2(width, 72);
|
|
|
608b37 |
cmdlineP->width = width * 72;
|
|
|
608b37 |
+ overflow2(height, 72);
|
|
|
608b37 |
cmdlineP->height = height * 72;
|
|
|
608b37 |
|
|
|
608b37 |
if (imagewidthSpec) {
|
|
|
608b37 |
validateCompDimension(imagewidth, 72, "-imagewidth value");
|
|
|
608b37 |
+ overflow2(imagewidth, 72);
|
|
|
608b37 |
cmdlineP->imagewidth = imagewidth * 72;
|
|
|
608b37 |
}
|
|
|
608b37 |
else
|
|
|
608b37 |
cmdlineP->imagewidth = 0;
|
|
|
608b37 |
if (imageheightSpec) {
|
|
|
608b37 |
- validateCompDimension(imagewidth, 72, "-imageheight value");
|
|
|
608b37 |
+ validateCompDimension(imageheight, 72, "-imageheight value");
|
|
|
608b37 |
+ overflow2(imageheight, 72);
|
|
|
608b37 |
cmdlineP->imageheight = imageheight * 72;
|
|
|
608b37 |
}
|
|
|
608b37 |
else
|
|
|
608b37 |
diff -urNp old/converter/other/pnmtorle.c new/converter/other/pnmtorle.c
|
|
|
608b37 |
--- old/converter/other/pnmtorle.c 2017-09-05 15:09:00.993207438 +0200
|
|
|
608b37 |
+++ new/converter/other/pnmtorle.c 2017-09-05 15:19:42.218061079 +0200
|
|
|
608b37 |
@@ -19,6 +19,8 @@
|
|
|
608b37 |
* If you modify this software, you should include a notice giving the
|
|
|
608b37 |
* name of the person performing the modification, the date of modification,
|
|
|
608b37 |
* and the reason for such modification.
|
|
|
608b37 |
+ *
|
|
|
608b37 |
+ * 2002-12-19: Fix maths wrapping bugs. Alan Cox <alan@redhat.com>
|
|
|
608b37 |
*/
|
|
|
608b37 |
/*
|
|
|
608b37 |
* pnmtorle - A program which will convert pbmplus (ppm or pgm) images
|
|
|
608b37 |
diff -urNp old/converter/other/pnmtosgi.c new/converter/other/pnmtosgi.c
|
|
|
608b37 |
--- old/converter/other/pnmtosgi.c 2017-09-05 15:09:00.992207443 +0200
|
|
|
608b37 |
+++ new/converter/other/pnmtosgi.c 2017-09-05 15:23:54.121864563 +0200
|
|
|
608b37 |
@@ -139,6 +139,8 @@ compress(ScanElem * const tempArg,
|
|
|
608b37 |
break;
|
|
|
608b37 |
case STORAGE_RLE: {
|
|
|
608b37 |
unsigned int const tabrow = chanNum * rows + row;
|
|
|
608b37 |
+ overflow2(chanNum, rows);
|
|
|
608b37 |
+ overflow_add(chanNum * rows, row);
|
|
|
608b37 |
|
|
|
608b37 |
unsigned int len;
|
|
|
608b37 |
size_t lenBytes;
|
|
|
608b37 |
@@ -185,6 +187,7 @@ buildChannels(FILE * const ifP,
|
|
|
608b37 |
ScanElem * temp;
|
|
|
608b37 |
|
|
|
608b37 |
if (storage != STORAGE_VERBATIM) {
|
|
|
608b37 |
+ overflow2(channels, rows);
|
|
|
608b37 |
MALLOCARRAY_NOFAIL(table, channels * rows);
|
|
|
608b37 |
} else
|
|
|
608b37 |
table = NULL;
|
|
|
608b37 |
diff -urNp old/converter/other/rletopnm.c new/converter/other/rletopnm.c
|
|
|
608b37 |
--- old/converter/other/rletopnm.c 2017-09-05 15:09:00.991207448 +0200
|
|
|
608b37 |
+++ new/converter/other/rletopnm.c 2017-09-05 15:24:29.441803825 +0200
|
|
|
608b37 |
@@ -19,6 +19,8 @@
|
|
|
608b37 |
* If you modify this software, you should include a notice giving the
|
|
|
608b37 |
* name of the person performing the modification, the date of modification,
|
|
|
608b37 |
* and the reason for such modification.
|
|
|
608b37 |
+ *
|
|
|
608b37 |
+ * 2002-12-19: Fix maths wrapping bugs. Alan Cox <alan@redhat.com>
|
|
|
608b37 |
*/
|
|
|
608b37 |
/*
|
|
|
608b37 |
* rletopnm - A conversion program to convert from Utah's "rle" image format
|
|
|
608b37 |
diff -urNp old/converter/other/sgitopnm.c new/converter/other/sgitopnm.c
|
|
|
608b37 |
--- old/converter/other/sgitopnm.c 2017-09-05 15:09:00.991207448 +0200
|
|
|
608b37 |
+++ new/converter/other/sgitopnm.c 2017-09-05 15:26:59.320478129 +0200
|
|
|
608b37 |
@@ -377,10 +377,14 @@ readChannels(FILE * const ifP,
|
|
|
608b37 |
MALLOCARRAY_NOFAIL(image, head->ysize);
|
|
|
608b37 |
} else {
|
|
|
608b37 |
maxchannel = 3;
|
|
|
608b37 |
+ overflow2(head->ysize, maxchannel);
|
|
|
608b37 |
MALLOCARRAY_NOFAIL(image, head->ysize * maxchannel);
|
|
|
608b37 |
}
|
|
|
608b37 |
- if (table)
|
|
|
608b37 |
+ if (table) {
|
|
|
608b37 |
+ overflow2(head->xsize, 2);
|
|
|
608b37 |
+ overflow_add(head->xsize*2, 2);
|
|
|
608b37 |
MALLOCARRAY_NOFAIL(temp, WORSTCOMPR(head->xsize));
|
|
|
608b37 |
+ }
|
|
|
608b37 |
|
|
|
608b37 |
for (channel = 0; channel < maxchannel; ++channel) {
|
|
|
608b37 |
unsigned int row;
|
|
|
608b37 |
diff -urNp old/converter/other/sirtopnm.c new/converter/other/sirtopnm.c
|
|
|
608b37 |
--- old/converter/other/sirtopnm.c 2017-09-05 15:09:00.993207438 +0200
|
|
|
608b37 |
+++ new/converter/other/sirtopnm.c 2017-09-05 15:27:29.784400243 +0200
|
|
|
608b37 |
@@ -69,6 +69,7 @@ char* argv[];
|
|
|
608b37 |
}
|
|
|
608b37 |
break;
|
|
|
608b37 |
case PPM_TYPE:
|
|
|
608b37 |
+ overflow3(cols, rows, 3);
|
|
|
608b37 |
picsize = cols * rows * 3;
|
|
|
608b37 |
planesize = cols * rows;
|
|
|
608b37 |
if ( !( sirarray = (unsigned char*) malloc( picsize ) ) )
|
|
|
608b37 |
diff -urNp old/converter/other/tifftopnm.c new/converter/other/tifftopnm.c
|
|
|
608b37 |
--- old/converter/other/tifftopnm.c 2017-09-05 15:09:00.991207448 +0200
|
|
|
608b37 |
+++ new/converter/other/tifftopnm.c 2017-09-05 15:29:34.649047220 +0200
|
|
|
608b37 |
@@ -1372,7 +1372,9 @@ convertRasterByRows(pnmOut * const
|
|
|
608b37 |
if (scanbuf == NULL)
|
|
|
608b37 |
pm_error("can't allocate memory for scanline buffer");
|
|
|
608b37 |
|
|
|
608b37 |
- MALLOCARRAY(samplebuf, cols * spp);
|
|
|
608b37 |
+ /* samplebuf is unsigned int * !!! */
|
|
|
608b37 |
+ samplebuf = (unsigned int *) malloc3(cols , sizeof(unsigned int) , spp);
|
|
|
608b37 |
+
|
|
|
608b37 |
if (samplebuf == NULL)
|
|
|
608b37 |
pm_error("can't allocate memory for row buffer");
|
|
|
608b37 |
|
|
|
608b37 |
diff -urNp old/converter/other/xwdtopnm.c new/converter/other/xwdtopnm.c
|
|
|
608b37 |
--- old/converter/other/xwdtopnm.c 2017-09-05 15:09:00.994207433 +0200
|
|
|
608b37 |
+++ new/converter/other/xwdtopnm.c 2017-09-05 15:30:51.608806353 +0200
|
|
|
608b37 |
@@ -210,6 +210,10 @@ processX10Header(X10WDFileHeader * cons
|
|
|
608b37 |
*colorsP = pnm_allocrow(2);
|
|
|
608b37 |
PNM_ASSIGN1((*colorsP)[0], 0);
|
|
|
608b37 |
PNM_ASSIGN1((*colorsP)[1], *maxvalP);
|
|
|
608b37 |
+ overflow_add(h10P->pixmap_width, 15);
|
|
|
608b37 |
+ if(h10P->pixmap_width < 0)
|
|
|
608b37 |
+ pm_error("assert: negative width");
|
|
|
608b37 |
+ overflow2((((h10P->pixmap_width + 15) / 16) * 16 - h10P->pixmap_width), 8);
|
|
|
608b37 |
*padrightP =
|
|
|
608b37 |
(((h10P->pixmap_width + 15) / 16) * 16 - h10P->pixmap_width) * 8;
|
|
|
608b37 |
*bits_per_itemP = 16;
|
|
|
608b37 |
@@ -635,6 +639,7 @@ processX11Header(X11WDFileHeader * cons
|
|
|
608b37 |
|
|
|
608b37 |
*colsP = h11FixedP->pixmap_width;
|
|
|
608b37 |
*rowsP = h11FixedP->pixmap_height;
|
|
|
608b37 |
+ overflow2(h11FixedP->bytes_per_line, 8);
|
|
|
608b37 |
*padrightP =
|
|
|
608b37 |
h11FixedP->bytes_per_line * 8 -
|
|
|
608b37 |
h11FixedP->pixmap_width * h11FixedP->bits_per_pixel;
|
|
|
608b37 |
diff -urNp old/converter/pbm/mdatopbm.c new/converter/pbm/mdatopbm.c
|
|
|
608b37 |
--- old/converter/pbm/mdatopbm.c 2017-09-05 15:09:00.988207463 +0200
|
|
|
608b37 |
+++ new/converter/pbm/mdatopbm.c 2017-09-05 15:31:47.007612804 +0200
|
|
|
608b37 |
@@ -245,10 +245,13 @@ main(int argc, char **argv) {
|
|
|
608b37 |
pm_readlittleshort(infile, &yy;; nInCols = yy;
|
|
|
608b37 |
}
|
|
|
608b37 |
|
|
|
608b37 |
+ overflow2(nOutCols, 8);
|
|
|
608b37 |
nOutCols = 8 * nInCols;
|
|
|
608b37 |
nOutRows = nInRows;
|
|
|
608b37 |
- if (bScale)
|
|
|
608b37 |
+ if (bScale) {
|
|
|
608b37 |
+ overflow2(nOutRows, 2);
|
|
|
608b37 |
nOutRows *= 2;
|
|
|
608b37 |
+ }
|
|
|
608b37 |
|
|
|
608b37 |
data = pbm_allocarray(nOutCols, nOutRows);
|
|
|
608b37 |
|
|
|
608b37 |
diff -urNp old/converter/pbm/mgrtopbm.c new/converter/pbm/mgrtopbm.c
|
|
|
608b37 |
--- old/converter/pbm/mgrtopbm.c 2017-09-05 15:09:00.988207463 +0200
|
|
|
608b37 |
+++ new/converter/pbm/mgrtopbm.c 2017-09-05 15:32:29.335457328 +0200
|
|
|
608b37 |
@@ -65,6 +65,8 @@ readMgrHeader(FILE * const ifP,
|
|
|
608b37 |
if (head.h_high < ' ' || head.l_high < ' ')
|
|
|
608b37 |
pm_error("Invalid width field in MGR header");
|
|
|
608b37 |
|
|
|
608b37 |
+ overflow_add(*colsP, pad);
|
|
|
608b37 |
+
|
|
|
608b37 |
*colsP = (((int)head.h_wide - ' ') << 6) + ((int)head.l_wide - ' ');
|
|
|
608b37 |
*rowsP = (((int)head.h_high - ' ') << 6) + ((int) head.l_high - ' ');
|
|
|
608b37 |
*padrightP = ( ( *colsP + pad - 1 ) / pad ) * pad - *colsP;
|
|
|
608b37 |
diff -urNp old/converter/pbm/pbmtogem.c new/converter/pbm/pbmtogem.c
|
|
|
608b37 |
--- old/converter/pbm/pbmtogem.c 2017-09-05 15:09:00.988207463 +0200
|
|
|
608b37 |
+++ new/converter/pbm/pbmtogem.c 2017-09-05 15:33:20.015266347 +0200
|
|
|
608b37 |
@@ -79,6 +79,7 @@ putinit (int const rows, int const cols)
|
|
|
608b37 |
bitsperitem = 0;
|
|
|
608b37 |
bitshift = 7;
|
|
|
608b37 |
outcol = 0;
|
|
|
608b37 |
+ overflow_add(cols, 7);
|
|
|
608b37 |
outmax = (cols + 7) / 8;
|
|
|
608b37 |
outrow = (unsigned char *) pm_allocrow (outmax, sizeof (unsigned char));
|
|
|
608b37 |
lastrow = (unsigned char *) pm_allocrow (outmax, sizeof (unsigned char));
|
|
|
608b37 |
diff -urNp old/converter/pbm/pbmtogo.c new/converter/pbm/pbmtogo.c
|
|
|
608b37 |
--- old/converter/pbm/pbmtogo.c 2017-09-05 15:09:00.988207463 +0200
|
|
|
608b37 |
+++ new/converter/pbm/pbmtogo.c 2017-09-05 15:33:44.200173491 +0200
|
|
|
608b37 |
@@ -158,6 +158,7 @@ main(int argc,
|
|
|
608b37 |
bitrow = pbm_allocrow(cols);
|
|
|
608b37 |
|
|
|
608b37 |
/* Round cols up to the nearest multiple of 8. */
|
|
|
608b37 |
+ overflow_add(cols, 7);
|
|
|
608b37 |
rucols = ( cols + 7 ) / 8;
|
|
|
608b37 |
bytesperrow = rucols; /* GraphOn uses bytes */
|
|
|
608b37 |
rucols = rucols * 8;
|
|
|
608b37 |
diff -urNp old/converter/pbm/pbmtolj.c new/converter/pbm/pbmtolj.c
|
|
|
608b37 |
--- old/converter/pbm/pbmtolj.c 2017-09-05 15:09:00.987207468 +0200
|
|
|
608b37 |
+++ new/converter/pbm/pbmtolj.c 2017-09-05 15:34:35.767972087 +0200
|
|
|
608b37 |
@@ -120,7 +120,11 @@ parseCommandLine(int argc, char ** argv,
|
|
|
608b37 |
static void
|
|
|
608b37 |
allocateBuffers(unsigned int const cols) {
|
|
|
608b37 |
|
|
|
608b37 |
+ overflow_add(cols, 8);
|
|
|
608b37 |
rowBufferSize = (cols + 7) / 8;
|
|
|
608b37 |
+ overflow_add(rowBufferSize, 128);
|
|
|
608b37 |
+ overflow_add(rowBufferSize, rowBufferSize+128);
|
|
|
608b37 |
+ overflow_add(rowBufferSize+10, rowBufferSize/8);
|
|
|
608b37 |
packBufferSize = rowBufferSize + (rowBufferSize + 127) / 128 + 1;
|
|
|
608b37 |
deltaBufferSize = rowBufferSize + rowBufferSize / 8 + 10;
|
|
|
608b37 |
|
|
|
608b37 |
diff -urNp old/converter/pbm/pbmtomda.c new/converter/pbm/pbmtomda.c
|
|
|
608b37 |
--- old/converter/pbm/pbmtomda.c 2017-09-05 15:09:00.987207468 +0200
|
|
|
608b37 |
+++ new/converter/pbm/pbmtomda.c 2017-09-05 15:47:39.279563827 +0200
|
|
|
608b37 |
@@ -179,6 +179,8 @@ int main(int argc, char **argv)
|
|
|
608b37 |
|
|
|
608b37 |
nOutRowsUnrounded = bScale ? nInRows/2 : nInRows;
|
|
|
608b37 |
|
|
|
608b37 |
+ overflow_add(nOutRowsUnrounded, 3);
|
|
|
608b37 |
+
|
|
|
608b37 |
nOutRows = ((nOutRowsUnrounded + 3) / 4) * 4;
|
|
|
608b37 |
/* MDA wants rows a multiple of 4 */
|
|
|
608b37 |
nOutCols = nInCols / 8;
|
|
|
608b37 |
diff -urNp old/converter/pbm/pbmtoppa/pbm.c new/converter/pbm/pbmtoppa/pbm.c
|
|
|
608b37 |
--- old/converter/pbm/pbmtoppa/pbm.c 2017-09-05 15:09:00.990207453 +0200
|
|
|
608b37 |
+++ new/converter/pbm/pbmtoppa/pbm.c 2017-09-05 15:49:13.364155211 +0200
|
|
|
608b37 |
@@ -106,6 +106,7 @@ int pbm_readline(pbm_stat* pbm,unsigned
|
|
|
608b37 |
return 0;
|
|
|
608b37 |
|
|
|
608b37 |
case P4:
|
|
|
608b37 |
+ overflow_add(pbm->width, 7);
|
|
|
608b37 |
tmp=(pbm->width+7)/8;
|
|
|
608b37 |
tmp2=fread(data,1,tmp,pbm->fptr);
|
|
|
608b37 |
if(tmp2 == tmp)
|
|
|
608b37 |
@@ -130,7 +131,8 @@ void pbm_unreadline (pbm_stat *pbm, void
|
|
|
608b37 |
return;
|
|
|
608b37 |
|
|
|
608b37 |
pbm->unread = 1;
|
|
|
608b37 |
- pbm->revdata = malloc ((pbm->width+7)/8);
|
|
|
608b37 |
+ overflow_add(pbm->width, 7);
|
|
|
608b37 |
+ pbm->revdata = malloc((pbm->width+7)/8);
|
|
|
608b37 |
memcpy (pbm->revdata, data, (pbm->width+7)/8);
|
|
|
608b37 |
pbm->current_line--;
|
|
|
608b37 |
}
|
|
|
608b37 |
diff -urNp old/converter/pbm/pbmtoppa/pbmtoppa.c new/converter/pbm/pbmtoppa/pbmtoppa.c
|
|
|
608b37 |
--- old/converter/pbm/pbmtoppa/pbmtoppa.c 2017-09-05 15:09:00.990207453 +0200
|
|
|
608b37 |
+++ new/converter/pbm/pbmtoppa/pbmtoppa.c 2017-09-05 15:50:10.811968059 +0200
|
|
|
608b37 |
@@ -453,6 +453,7 @@ main(int argc, char *argv[]) {
|
|
|
608b37 |
pm_error("main(): unrecognized parameter '%s'", argv[argn]);
|
|
|
608b37 |
}
|
|
|
608b37 |
|
|
|
608b37 |
+ overflow_add(Width, 7);
|
|
|
608b37 |
Pwidth=(Width+7)/8;
|
|
|
608b37 |
printer.fptr=out;
|
|
|
608b37 |
|
|
|
608b37 |
diff -urNp old/converter/pbm/pbmtoxbm.c new/converter/pbm/pbmtoxbm.c
|
|
|
608b37 |
--- old/converter/pbm/pbmtoxbm.c 2017-09-05 15:09:00.987207468 +0200
|
|
|
608b37 |
+++ new/converter/pbm/pbmtoxbm.c 2017-09-05 15:51:01.843793892 +0200
|
|
|
608b37 |
@@ -353,6 +353,8 @@ convertRaster(FILE * const ifP,
|
|
|
608b37 |
unsigned char * bitrow;
|
|
|
608b37 |
unsigned int row;
|
|
|
608b37 |
|
|
|
608b37 |
+ overflow_add(cols, padright);
|
|
|
608b37 |
+
|
|
|
608b37 |
putinit(xbmVersion);
|
|
|
608b37 |
|
|
|
608b37 |
bitrow = pbm_allocrow_packed(cols + padright);
|
|
|
608b37 |
diff -urNp old/converter/pbm/pbmto4425.c new/converter/pbm/pbmto4425.c
|
|
|
608b37 |
--- old/converter/pbm/pbmto4425.c 2017-09-05 15:09:00.988207463 +0200
|
|
|
608b37 |
+++ new/converter/pbm/pbmto4425.c 2017-09-05 15:54:37.077992604 +0200
|
|
|
608b37 |
@@ -160,7 +160,7 @@ main(int argc, char * argv[]) {
|
|
|
608b37 |
xres = vmap_width * 2;
|
|
|
608b37 |
yres = vmap_height * 3;
|
|
|
608b37 |
|
|
|
608b37 |
- vmap = malloc(vmap_width * vmap_height * sizeof(char));
|
|
|
608b37 |
+ vmap = malloc3(vmap_width, vmap_height, sizeof(char));
|
|
|
608b37 |
if(vmap == NULL)
|
|
|
608b37 |
{
|
|
|
608b37 |
pm_error( "Cannot allocate memory" );
|
|
|
608b37 |
diff -urNp old/converter/pbm/pktopbm.c new/converter/pbm/pktopbm.c
|
|
|
608b37 |
--- old/converter/pbm/pktopbm.c 2017-09-05 15:09:00.988207463 +0200
|
|
|
608b37 |
+++ new/converter/pbm/pktopbm.c 2017-09-05 15:55:35.736759083 +0200
|
|
|
608b37 |
@@ -280,6 +280,7 @@ main(int argc, char *argv[]) {
|
|
|
608b37 |
if (flagbyte == 7) { /* long form preamble */
|
|
|
608b37 |
integer packetlength = get32() ; /* character packet length */
|
|
|
608b37 |
car = get32() ; /* character number */
|
|
|
608b37 |
+ overflow_add(packetlength, pktopbm_pkloc);
|
|
|
608b37 |
endofpacket = packetlength + pktopbm_pkloc;
|
|
|
608b37 |
/* calculate end of packet */
|
|
|
608b37 |
if ((car >= MAXPKCHAR) || !filename[car]) {
|
|
|
608b37 |
diff -urNp old/converter/pbm/thinkjettopbm.l new/converter/pbm/thinkjettopbm.l
|
|
|
608b37 |
--- old/converter/pbm/thinkjettopbm.l 2017-09-05 15:09:00.988207463 +0200
|
|
|
608b37 |
+++ new/converter/pbm/thinkjettopbm.l 2017-09-05 15:57:03.449400388 +0200
|
|
|
608b37 |
@@ -114,7 +114,9 @@ DIG [0-9]
|
|
|
608b37 |
<RASTERMODE>\033\*b{DIG}+W {
|
|
|
608b37 |
int l;
|
|
|
608b37 |
if (rowCount >= rowCapacity) {
|
|
|
608b37 |
+ overflow_add(rowCapacity, 100);
|
|
|
608b37 |
rowCapacity += 100;
|
|
|
608b37 |
+ overflow2(rowCapacity, sizeof *rows);
|
|
|
608b37 |
rows = realloc (rows, rowCapacity * sizeof *rows);
|
|
|
608b37 |
if (rows == NULL)
|
|
|
608b37 |
pm_error ("Out of memory.");
|
|
|
608b37 |
@@ -226,6 +228,7 @@ yywrap (void)
|
|
|
608b37 |
/*
|
|
|
608b37 |
* Quite simple since ThinkJet bit arrangement matches PBM
|
|
|
608b37 |
*/
|
|
|
608b37 |
+ overflow2(maxRowLength, 8);
|
|
|
608b37 |
pbm_writepbminit(stdout, maxRowLength*8, rowCount, 0);
|
|
|
608b37 |
|
|
|
608b37 |
packed_bitrow = malloc(maxRowLength);
|
|
|
608b37 |
diff -urNp old/converter/pgm/lispmtopgm.c new/converter/pgm/lispmtopgm.c
|
|
|
608b37 |
--- old/converter/pgm/lispmtopgm.c 2017-09-05 15:09:01.002207393 +0200
|
|
|
608b37 |
+++ new/converter/pgm/lispmtopgm.c 2017-09-05 15:59:07.145878261 +0200
|
|
|
608b37 |
@@ -58,6 +58,7 @@ main( argc, argv )
|
|
|
608b37 |
pm_error( "depth (%d bits) is too large", depth);
|
|
|
608b37 |
|
|
|
608b37 |
pgm_writepgminit( stdout, cols, rows, (gray) maxval, 0 );
|
|
|
608b37 |
+ overflow_add(cols, 7);
|
|
|
608b37 |
grayrow = pgm_allocrow( ( cols + 7 ) / 8 * 8 );
|
|
|
608b37 |
|
|
|
608b37 |
for ( row = 0; row < rows; ++row )
|
|
|
608b37 |
@@ -102,7 +103,9 @@ getinit( file, colsP, rowsP, depthP, pad
|
|
|
608b37 |
|
|
|
608b37 |
if ( *depthP == 0 )
|
|
|
608b37 |
*depthP = 1; /* very old file */
|
|
|
608b37 |
-
|
|
|
608b37 |
+
|
|
|
608b37 |
+ overflow_add((int)colsP, 31);
|
|
|
608b37 |
+
|
|
|
608b37 |
*padrightP = ( ( *colsP + 31 ) / 32 ) * 32 - *colsP;
|
|
|
608b37 |
|
|
|
608b37 |
if ( *colsP != (cols_32 - *padrightP) ) {
|
|
|
608b37 |
diff -urNp old/converter/pgm/psidtopgm.c new/converter/pgm/psidtopgm.c
|
|
|
608b37 |
--- old/converter/pgm/psidtopgm.c 2017-09-05 15:09:01.002207393 +0200
|
|
|
608b37 |
+++ new/converter/pgm/psidtopgm.c 2017-09-05 15:59:42.457726237 +0200
|
|
|
608b37 |
@@ -78,6 +78,7 @@ main(int argc,
|
|
|
608b37 |
pm_error("bits/sample (%d) is too large.", bitspersample);
|
|
|
608b37 |
|
|
|
608b37 |
pgm_writepgminit(stdout, cols, rows, maxval, 0);
|
|
|
608b37 |
+ overflow_add(cols, 7);
|
|
|
608b37 |
grayrow = pgm_allocrow((cols + 7) / 8 * 8);
|
|
|
608b37 |
for (row = 0; row < rows; ++row) {
|
|
|
608b37 |
unsigned int col;
|
|
|
608b37 |
diff -urNp old/converter/ppm/ilbmtoppm.c new/converter/ppm/ilbmtoppm.c
|
|
|
608b37 |
--- old/converter/ppm/ilbmtoppm.c 2017-09-05 15:09:01.003207388 +0200
|
|
|
608b37 |
+++ new/converter/ppm/ilbmtoppm.c 2017-09-05 16:04:33.011437671 +0200
|
|
|
608b37 |
@@ -606,6 +606,7 @@ decode_row(FILE * const ifP,
|
|
|
608b37 |
rawtype *chp;
|
|
|
608b37 |
|
|
|
608b37 |
cols = bmhdP->w;
|
|
|
608b37 |
+ overflow_add(cols, 15);
|
|
|
608b37 |
bytes = RowBytes(cols);
|
|
|
608b37 |
for( plane = 0; plane < nPlanes; plane++ ) {
|
|
|
608b37 |
int mask;
|
|
|
608b37 |
@@ -693,6 +694,23 @@ decode_mask(FILE * const ifP,
|
|
|
608b37 |
Multipalette handling
|
|
|
608b37 |
****************************************************************************/
|
|
|
608b37 |
|
|
|
608b37 |
+static void *
|
|
|
608b37 |
+xmalloc2(x, y)
|
|
|
608b37 |
+ int x;
|
|
|
608b37 |
+ int y;
|
|
|
608b37 |
+{
|
|
|
608b37 |
+ void *mem;
|
|
|
608b37 |
+
|
|
|
608b37 |
+ overflow2(x,y);
|
|
|
608b37 |
+ if( x * y == 0 )
|
|
|
608b37 |
+ return NULL;
|
|
|
608b37 |
+
|
|
|
608b37 |
+ mem = malloc2(x,y);
|
|
|
608b37 |
+ if( mem == NULL )
|
|
|
608b37 |
+ pm_error("out of memory allocating %d bytes", x * y);
|
|
|
608b37 |
+ return mem;
|
|
|
608b37 |
+}
|
|
|
608b37 |
+
|
|
|
608b37 |
|
|
|
608b37 |
static void
|
|
|
608b37 |
multi_adjust(cmap, row, palchange)
|
|
|
608b37 |
@@ -1355,6 +1373,9 @@ dcol_to_ppm(FILE * const ifP,
|
|
|
608b37 |
if( redmaxval != maxval || greenmaxval != maxval || bluemaxval != maxval )
|
|
|
608b37 |
pm_message("scaling colors to %d bits", pm_maxvaltobits(maxval));
|
|
|
608b37 |
|
|
|
608b37 |
+ overflow_add(redmaxval, 1);
|
|
|
608b37 |
+ overflow_add(greenmaxval, 1);
|
|
|
608b37 |
+ overflow_add(bluemaxval, 1);
|
|
|
608b37 |
MALLOCARRAY_NOFAIL(redtable, redmaxval +1);
|
|
|
608b37 |
MALLOCARRAY_NOFAIL(greentable, greenmaxval +1);
|
|
|
608b37 |
MALLOCARRAY_NOFAIL(bluetable, bluemaxval +1);
|
|
|
608b37 |
@@ -1784,7 +1805,9 @@ PCHG_ConvertSmall(PCHG, cmap, mask, data
|
|
|
608b37 |
ChangeCount32 = *data++;
|
|
|
608b37 |
datasize -= 2;
|
|
|
608b37 |
|
|
|
608b37 |
+ overflow_add(ChangeCount16, ChangeCount32);
|
|
|
608b37 |
changes = ChangeCount16 + ChangeCount32;
|
|
|
608b37 |
+ overflow_add(changes, 1);
|
|
|
608b37 |
for( i = 0; i < changes; i++ ) {
|
|
|
608b37 |
if( totalchanges >= PCHG->TotalChanges ) goto fail;
|
|
|
608b37 |
if( datasize < 2 ) goto fail;
|
|
|
608b37 |
@@ -2049,6 +2072,9 @@ read_pchg(FILE * const ifP,
|
|
|
608b37 |
cmap->mp_change[i] = NULL;
|
|
|
608b37 |
if( PCHG.StartLine < 0 ) {
|
|
|
608b37 |
int nch;
|
|
|
608b37 |
+ if(PCHG.MaxReg < PCHG.MinReg)
|
|
|
608b37 |
+ pm_error("assert: MinReg > MaxReg");
|
|
|
608b37 |
+ overflow_add(PCHG.MaxReg-PCHG.MinReg, 2);
|
|
|
608b37 |
nch = PCHG.MaxReg - PCHG.MinReg +1;
|
|
|
608b37 |
MALLOCARRAY_NOFAIL(cmap->mp_init, nch + 1);
|
|
|
608b37 |
for( i = 0; i < nch; i++ )
|
|
|
608b37 |
@@ -2125,6 +2151,7 @@ process_body( FILE * const ifP,
|
|
|
608b37 |
if (typeid == ID_ILBM) {
|
|
|
608b37 |
int isdeep;
|
|
|
608b37 |
|
|
|
608b37 |
+ overflow_add(bmhdP->w, 15);
|
|
|
608b37 |
MALLOCARRAY_NOFAIL(ilbmrow, RowBytes(bmhdP->w));
|
|
|
608b37 |
*viewportmodesP |= fakeviewport; /* -isham/-isehb */
|
|
|
608b37 |
|
|
|
608b37 |
diff -urNp old/converter/ppm/imgtoppm.c new/converter/ppm/imgtoppm.c
|
|
|
608b37 |
--- old/converter/ppm/imgtoppm.c 2017-09-05 15:09:01.003207388 +0200
|
|
|
608b37 |
+++ new/converter/ppm/imgtoppm.c 2017-09-06 09:21:05.977198159 +0200
|
|
|
608b37 |
@@ -84,6 +84,7 @@ main(int argc, char ** argv) {
|
|
|
608b37 |
len = atoi((char*) buf );
|
|
|
608b37 |
if ( fread( buf, len, 1, ifp ) != 1 )
|
|
|
608b37 |
pm_error( "bad colormap buf" );
|
|
|
608b37 |
+ overflow2(cmaplen, 3);
|
|
|
608b37 |
if ( cmaplen * 3 != len )
|
|
|
608b37 |
{
|
|
|
608b37 |
pm_message(
|
|
|
608b37 |
@@ -105,6 +106,7 @@ main(int argc, char ** argv) {
|
|
|
608b37 |
pm_error( "bad pixel data header" );
|
|
|
608b37 |
buf[8] = '\0';
|
|
|
608b37 |
len = atoi((char*) buf );
|
|
|
608b37 |
+ overflow2(cols, rows);
|
|
|
608b37 |
if ( len != cols * rows )
|
|
|
608b37 |
pm_message(
|
|
|
608b37 |
"pixel data length (%d) does not match image size (%d)",
|
|
|
608b37 |
diff -urNp old/converter/ppm/Makefile new/converter/ppm/Makefile
|
|
|
608b37 |
--- old/converter/ppm/Makefile 2017-09-05 15:09:01.004207383 +0200
|
|
|
608b37 |
+++ new/converter/ppm/Makefile 2017-09-06 09:21:56.848867561 +0200
|
|
|
608b37 |
@@ -11,7 +11,7 @@ SUBDIRS = hpcdtoppm
|
|
|
608b37 |
|
|
|
608b37 |
PORTBINARIES = 411toppm eyuvtoppm gouldtoppm ilbmtoppm imgtoppm \
|
|
|
608b37 |
leaftoppm mtvtoppm neotoppm \
|
|
|
608b37 |
- pcxtoppm pc1toppm pi1toppm picttoppm pjtoppm \
|
|
|
608b37 |
+ pcxtoppm pc1toppm pi1toppm pjtoppm \
|
|
|
608b37 |
ppmtoacad ppmtoapplevol ppmtoarbtxt ppmtoascii \
|
|
|
608b37 |
ppmtobmp ppmtoeyuv ppmtogif ppmtoicr ppmtoilbm \
|
|
|
608b37 |
ppmtoleaf ppmtolj ppmtomitsu ppmtoneo \
|
|
|
608b37 |
diff -urNp old/converter/ppm/pcxtoppm.c new/converter/ppm/pcxtoppm.c
|
|
|
608b37 |
--- old/converter/ppm/pcxtoppm.c 2017-09-05 15:09:01.004207383 +0200
|
|
|
608b37 |
+++ new/converter/ppm/pcxtoppm.c 2017-09-06 09:33:20.821565782 +0200
|
|
|
608b37 |
@@ -409,6 +409,7 @@ pcx_planes_to_pixels(pixels, bitplanes,
|
|
|
608b37 |
/*
|
|
|
608b37 |
* clear the pixel buffer
|
|
|
608b37 |
*/
|
|
|
608b37 |
+ overflow2(bytesperline, 8);
|
|
|
608b37 |
npixels = (bytesperline * 8) / bitsperpixel;
|
|
|
608b37 |
p = pixels;
|
|
|
608b37 |
while (--npixels >= 0)
|
|
|
608b37 |
@@ -470,6 +471,7 @@ pcx_16col_to_ppm(FILE * const ifP,
|
|
|
608b37 |
}
|
|
|
608b37 |
|
|
|
608b37 |
/* BytesPerLine should be >= BitsPerPixel * cols / 8 */
|
|
|
608b37 |
+ overflow2(BytesPerLine, 8);
|
|
|
608b37 |
rawcols = BytesPerLine * 8 / BitsPerPixel;
|
|
|
608b37 |
if (headerCols > rawcols) {
|
|
|
608b37 |
pm_message("warning - BytesPerLine = %d, "
|
|
|
608b37 |
diff -urNp old/converter/ppm/picttoppm.c new/converter/ppm/picttoppm.c
|
|
|
608b37 |
--- old/converter/ppm/picttoppm.c 2017-09-05 15:09:01.003207388 +0200
|
|
|
608b37 |
+++ new/converter/ppm/picttoppm.c 2017-09-06 09:35:38.693912426 +0200
|
|
|
608b37 |
@@ -1,4 +1,6 @@
|
|
|
608b37 |
-/*
|
|
|
608b37 |
+/* !!!WARNING!!! -> error "Unfixable. Don't ship me"
|
|
|
608b37 |
+ *
|
|
|
608b37 |
+ *
|
|
|
608b37 |
* picttoppm.c -- convert a MacIntosh PICT file to PPM format.
|
|
|
608b37 |
*
|
|
|
608b37 |
* Copyright 1989,1992,1993 George Phillips
|
|
|
608b37 |
diff -urNp old/converter/ppm/pjtoppm.c new/converter/ppm/pjtoppm.c
|
|
|
608b37 |
--- old/converter/ppm/pjtoppm.c 2017-09-05 15:09:01.003207388 +0200
|
|
|
608b37 |
+++ new/converter/ppm/pjtoppm.c 2017-09-06 09:39:54.747634431 +0200
|
|
|
608b37 |
@@ -127,19 +127,21 @@ main(argc, argv)
|
|
|
608b37 |
case 'V': /* send plane */
|
|
|
608b37 |
case 'W': /* send last plane */
|
|
|
608b37 |
if (rows == -1 || r >= rows || image == NULL) {
|
|
|
608b37 |
- if (rows == -1 || r >= rows)
|
|
|
608b37 |
+ if (rows == -1 || r >= rows) {
|
|
|
608b37 |
+ overflow_add(rows, 100);
|
|
|
608b37 |
rows += 100;
|
|
|
608b37 |
+ }
|
|
|
608b37 |
if (image == NULL) {
|
|
|
608b37 |
- MALLOCARRAY(image, rows * planes);
|
|
|
608b37 |
- MALLOCARRAY(imlen, rows * planes);
|
|
|
608b37 |
+ image = (unsigned char **)
|
|
|
608b37 |
+ malloc3(rows , planes , sizeof(unsigned char *));
|
|
|
608b37 |
+ imlen = (int *) malloc3(rows , planes, sizeof(int));
|
|
|
608b37 |
}
|
|
|
608b37 |
else {
|
|
|
608b37 |
+ overflow2(rows,planes);
|
|
|
608b37 |
image = (unsigned char **)
|
|
|
608b37 |
- realloc(image,
|
|
|
608b37 |
- rows * planes *
|
|
|
608b37 |
+ realloc2(image, rows * planes,
|
|
|
608b37 |
sizeof(unsigned char *));
|
|
|
608b37 |
- imlen = (int *)
|
|
|
608b37 |
- realloc(imlen, rows * planes * sizeof(int));
|
|
|
608b37 |
+ imlen = (int *) realloc2(imlen, rows * planes, sizeof(int));
|
|
|
608b37 |
}
|
|
|
608b37 |
}
|
|
|
608b37 |
if (image == NULL || imlen == NULL)
|
|
|
608b37 |
@@ -212,8 +214,10 @@ main(argc, argv)
|
|
|
608b37 |
for (i = 0, c = 0; c < imlen[p + r * planes]; c += 2)
|
|
|
608b37 |
for (cmd = image[p + r * planes][c],
|
|
|
608b37 |
val = image[p + r * planes][c+1];
|
|
|
608b37 |
- cmd >= 0 && i < newcols; cmd--, i++)
|
|
|
608b37 |
+ cmd >= 0 && i < newcols; cmd--, i++) {
|
|
|
608b37 |
buf[i] = val;
|
|
|
608b37 |
+ overflow_add(i, 1);
|
|
|
608b37 |
+ }
|
|
|
608b37 |
cols = cols > i ? cols : i;
|
|
|
608b37 |
free(image[p + r * planes]);
|
|
|
608b37 |
/*
|
|
|
608b37 |
@@ -224,6 +228,7 @@ main(argc, argv)
|
|
|
608b37 |
image[p + r * planes] = (unsigned char *) realloc(buf, i);
|
|
|
608b37 |
}
|
|
|
608b37 |
}
|
|
|
608b37 |
+ overflow2(cols, 8);
|
|
|
608b37 |
cols *= 8;
|
|
|
608b37 |
}
|
|
|
608b37 |
|
|
|
608b37 |
diff -urNp old/converter/ppm/ppmtoeyuv.c new/converter/ppm/ppmtoeyuv.c
|
|
|
608b37 |
--- old/converter/ppm/ppmtoeyuv.c 2017-09-05 15:09:01.003207388 +0200
|
|
|
608b37 |
+++ new/converter/ppm/ppmtoeyuv.c 2017-09-06 09:40:38.859425818 +0200
|
|
|
608b37 |
@@ -114,6 +114,7 @@ create_multiplication_tables(const pixva
|
|
|
608b37 |
|
|
|
608b37 |
int index;
|
|
|
608b37 |
|
|
|
608b37 |
+ overflow_add(maxval, 1);
|
|
|
608b37 |
MALLOCARRAY_NOFAIL(mult299 , maxval+1);
|
|
|
608b37 |
MALLOCARRAY_NOFAIL(mult587 , maxval+1);
|
|
|
608b37 |
MALLOCARRAY_NOFAIL(mult114 , maxval+1);
|
|
|
608b37 |
diff -urNp old/converter/ppm/ppmtoilbm.c new/converter/ppm/ppmtoilbm.c
|
|
|
608b37 |
--- old/converter/ppm/ppmtoilbm.c 2017-09-05 15:09:01.004207383 +0200
|
|
|
608b37 |
+++ new/converter/ppm/ppmtoilbm.c 2017-09-06 09:48:06.002139282 +0200
|
|
|
608b37 |
@@ -190,6 +190,7 @@ makeValTable(int const oldmaxval,
|
|
|
608b37 |
unsigned int i;
|
|
|
608b37 |
int * table;
|
|
|
608b37 |
|
|
|
608b37 |
+ overflow_add(oldmaxval, 1);
|
|
|
608b37 |
MALLOCARRAY_NOFAIL(table, oldmaxval + 1);
|
|
|
608b37 |
for (i = 0; i <= oldmaxval; ++i)
|
|
|
608b37 |
table[i] = ROUNDDIV(i * newmaxval, oldmaxval);
|
|
|
608b37 |
@@ -1644,6 +1645,7 @@ ppmToRgb8(FILE * const ifP,
|
|
|
608b37 |
|
|
|
608b37 |
maskmethod = 0; /* no masking - RGB8 uses genlock bits */
|
|
|
608b37 |
compmethod = 4; /* RGB8 files are always compressed */
|
|
|
608b37 |
+ overflow2(cols, 4);
|
|
|
608b37 |
MALLOCARRAY_NOFAIL(compr_row, cols * 4);
|
|
|
608b37 |
|
|
|
608b37 |
if( maxval != 255 ) {
|
|
|
608b37 |
@@ -1735,6 +1737,7 @@ ppmToRgbn(FILE * const ifP,
|
|
|
608b37 |
|
|
|
608b37 |
maskmethod = 0; /* no masking - RGBN uses genlock bits */
|
|
|
608b37 |
compmethod = 4; /* RGBN files are always compressed */
|
|
|
608b37 |
+ overflow2(cols, 2);
|
|
|
608b37 |
MALLOCARRAY_NOFAIL(compr_row, cols * 2);
|
|
|
608b37 |
|
|
|
608b37 |
if( maxval != 15 ) {
|
|
|
608b37 |
@@ -2298,8 +2301,11 @@ main(int argc, char ** argv) {
|
|
|
608b37 |
MALLOCARRAY_NOFAIL(coded_rowbuf, RowBytes(cols));
|
|
|
608b37 |
for (i = 0; i < RowBytes(cols); ++i)
|
|
|
608b37 |
coded_rowbuf[i] = 0;
|
|
|
608b37 |
- if (DO_COMPRESS)
|
|
|
608b37 |
+ if (DO_COMPRESS) {
|
|
|
608b37 |
+ overflow2(cols,2);
|
|
|
608b37 |
+ overflow_add(cols*2,2);
|
|
|
608b37 |
pm_rlenc_allocoutbuf(&compr_rowbuf, RowBytes(cols), PM_RLE_PACKBITS);
|
|
|
608b37 |
+ }
|
|
|
608b37 |
}
|
|
|
608b37 |
|
|
|
608b37 |
switch (mode) {
|
|
|
608b37 |
diff -urNp old/converter/ppm/ppmtolj.c new/converter/ppm/ppmtolj.c
|
|
|
608b37 |
--- old/converter/ppm/ppmtolj.c 2017-09-05 15:09:01.002207393 +0200
|
|
|
608b37 |
+++ new/converter/ppm/ppmtolj.c 2017-09-06 09:48:48.400910976 +0200
|
|
|
608b37 |
@@ -182,6 +182,7 @@ int main(int argc, char *argv[]) {
|
|
|
608b37 |
ppm_readppminit( ifp, &cols, &rows, &maxval, &format );
|
|
|
608b37 |
pixelrow = ppm_allocrow( cols );
|
|
|
608b37 |
|
|
|
608b37 |
+ overflow2(cols, 6);
|
|
|
608b37 |
obuf = (unsigned char *) pm_allocrow(cols * 3, sizeof(unsigned char));
|
|
|
608b37 |
cbuf = (unsigned char *) pm_allocrow(cols * 6, sizeof(unsigned char));
|
|
|
608b37 |
if (mode == C_TRANS_MODE_DELTA)
|
|
|
608b37 |
diff -urNp old/converter/ppm/ppmtomitsu.c new/converter/ppm/ppmtomitsu.c
|
|
|
608b37 |
--- old/converter/ppm/ppmtomitsu.c 2017-09-05 15:09:01.003207388 +0200
|
|
|
608b37 |
+++ new/converter/ppm/ppmtomitsu.c 2017-09-06 09:49:28.752692414 +0200
|
|
|
608b37 |
@@ -685,6 +685,8 @@ main(int argc, char * argv[]) {
|
|
|
608b37 |
medias = MSize_User;
|
|
|
608b37 |
|
|
|
608b37 |
if (dpi300) {
|
|
|
608b37 |
+ overflow2(medias.maxcols, 2);
|
|
|
608b37 |
+ overflow2(medias.maxrows, 2);
|
|
|
608b37 |
medias.maxcols *= 2;
|
|
|
608b37 |
medias.maxrows *= 2;
|
|
|
608b37 |
}
|
|
|
608b37 |
diff -urNp old/converter/ppm/ppmtopcx.c new/converter/ppm/ppmtopcx.c
|
|
|
608b37 |
--- old/converter/ppm/ppmtopcx.c 2017-09-05 15:09:01.003207388 +0200
|
|
|
608b37 |
+++ new/converter/ppm/ppmtopcx.c 2017-09-06 09:50:31.104352461 +0200
|
|
|
608b37 |
@@ -425,6 +425,8 @@ ppmTo16ColorPcx(pixel ** cons
|
|
|
608b37 |
else Planes = 1;
|
|
|
608b37 |
}
|
|
|
608b37 |
}
|
|
|
608b37 |
+ overflow2(BitsPerPixel, cols);
|
|
|
608b37 |
+ overflow_add(BitsPerPixel * cols, 7);
|
|
|
608b37 |
BytesPerLine = ((cols * BitsPerPixel) + 7) / 8;
|
|
|
608b37 |
MALLOCARRAY_NOFAIL(indexRow, cols);
|
|
|
608b37 |
MALLOCARRAY_NOFAIL(planesrow, BytesPerLine);
|
|
|
608b37 |
diff -urNp old/converter/ppm/ppmtopict.c new/converter/ppm/ppmtopict.c
|
|
|
608b37 |
--- old/converter/ppm/ppmtopict.c 2017-09-05 15:09:01.003207388 +0200
|
|
|
608b37 |
+++ new/converter/ppm/ppmtopict.c 2017-09-06 09:52:06.303828816 +0200
|
|
|
608b37 |
@@ -450,6 +450,8 @@ main(int argc, const char ** argv) {
|
|
|
608b37 |
putShort(stdout, 0); /* mode */
|
|
|
608b37 |
|
|
|
608b37 |
/* Finally, write out the data. */
|
|
|
608b37 |
+ overflow_add(cols/MAX_COUNT, 1);
|
|
|
608b37 |
+ overflow_add(cols, cols/MAX_COUNT+1);
|
|
|
608b37 |
outBuf = malloc((unsigned)(cols+cols/MAX_COUNT+1));
|
|
|
608b37 |
for (row = 0, oc = 0; row < rows; ++row) {
|
|
|
608b37 |
unsigned int rowSize;
|
|
|
608b37 |
diff -urNp old/converter/ppm/ppmtopj.c new/converter/ppm/ppmtopj.c
|
|
|
608b37 |
--- old/converter/ppm/ppmtopj.c 2017-09-05 15:09:01.004207383 +0200
|
|
|
608b37 |
+++ new/converter/ppm/ppmtopj.c 2017-09-06 09:52:34.623672093 +0200
|
|
|
608b37 |
@@ -179,6 +179,7 @@ char *argv[];
|
|
|
608b37 |
pixels = ppm_readppm( ifp, &cols, &rows, &maxval );
|
|
|
608b37 |
|
|
|
608b37 |
pm_close( ifp );
|
|
|
608b37 |
+ overflow2(cols,2);
|
|
|
608b37 |
obuf = (unsigned char *) pm_allocrow(cols, sizeof(unsigned char));
|
|
|
608b37 |
cbuf = (unsigned char *) pm_allocrow(cols * 2, sizeof(unsigned char));
|
|
|
608b37 |
|
|
|
608b37 |
diff -urNp old/converter/ppm/ppmtopjxl.c new/converter/ppm/ppmtopjxl.c
|
|
|
608b37 |
--- old/converter/ppm/ppmtopjxl.c 2017-09-05 15:09:01.004207383 +0200
|
|
|
608b37 |
+++ new/converter/ppm/ppmtopjxl.c 2017-09-06 09:55:28.614593979 +0200
|
|
|
608b37 |
@@ -266,6 +266,8 @@ main(int argc, const char * argv[]) {
|
|
|
608b37 |
pm_error("image too large; reduce with ppmscale");
|
|
|
608b37 |
if (maxval > PCL_MAXVAL)
|
|
|
608b37 |
pm_error("color range too large; reduce with ppmcscale");
|
|
|
608b37 |
+ if (cols < 0 || rows < 0)
|
|
|
608b37 |
+ pm_error("negative size is not possible");
|
|
|
608b37 |
|
|
|
608b37 |
/* Figure out the colormap. */
|
|
|
608b37 |
pm_message("Computing colormap...");
|
|
|
608b37 |
@@ -286,6 +288,8 @@ main(int argc, const char * argv[]) {
|
|
|
608b37 |
case 0: /* direct mode (no palette) */
|
|
|
608b37 |
bpp = bitsperpixel(maxval); /* bits per pixel */
|
|
|
608b37 |
bpg = bpp; bpb = bpp;
|
|
|
608b37 |
+ overflow2(bpp, 3);
|
|
|
608b37 |
+ overflow_add(bpp*3, 7);
|
|
|
608b37 |
bpp = (bpp*3+7)>>3; /* bytes per pixel now */
|
|
|
608b37 |
bpr = (bpp<<3)-bpg-bpb;
|
|
|
608b37 |
bpp *= cols; /* bytes per row now */
|
|
|
608b37 |
@@ -295,9 +299,13 @@ main(int argc, const char * argv[]) {
|
|
|
608b37 |
case 3: case 7: pclindex++;
|
|
|
608b37 |
default:
|
|
|
608b37 |
bpp = 8/pclindex;
|
|
|
608b37 |
+ overflow_add(cols, bpp);
|
|
|
608b37 |
+ if(bpp == 0)
|
|
|
608b37 |
+ pm_error("assert: no bpp");
|
|
|
608b37 |
bpp = (cols+bpp-1)/bpp; /* bytes per row */
|
|
|
608b37 |
}
|
|
|
608b37 |
}
|
|
|
608b37 |
+ overflow2(bpp,2);
|
|
|
608b37 |
inrow = (char *)malloc((unsigned)bpp);
|
|
|
608b37 |
outrow = (char *)malloc((unsigned)bpp*2);
|
|
|
608b37 |
runcnt = (signed char *)malloc((unsigned)bpp);
|
|
|
608b37 |
diff -urNp old/converter/ppm/ppmtowinicon.c new/converter/ppm/ppmtowinicon.c
|
|
|
608b37 |
--- old/converter/ppm/ppmtowinicon.c 2017-09-05 15:09:01.004207383 +0200
|
|
|
608b37 |
+++ new/converter/ppm/ppmtowinicon.c 2017-09-06 10:33:10.865812492 +0200
|
|
|
608b37 |
@@ -12,6 +12,7 @@
|
|
|
608b37 |
|
|
|
608b37 |
#include <math.h>
|
|
|
608b37 |
#include <string.h>
|
|
|
608b37 |
+#include <stdlib.h>
|
|
|
608b37 |
|
|
|
608b37 |
#include "pm_c_util.h"
|
|
|
608b37 |
#include "winico.h"
|
|
|
608b37 |
@@ -214,6 +215,7 @@ createAndBitmap (gray ** const ba, int c
|
|
|
608b37 |
MALLOCARRAY_NOFAIL(rowData, rows);
|
|
|
608b37 |
icBitmap->xBytes = xBytes;
|
|
|
608b37 |
icBitmap->data = rowData;
|
|
|
608b37 |
+ overflow2(xBytes, rows);
|
|
|
608b37 |
icBitmap->size = xBytes * rows;
|
|
|
608b37 |
for (y=0;y
|
|
|
608b37 |
u1 * row;
|
|
|
608b37 |
@@ -342,6 +344,7 @@ create4Bitmap (pixel ** const pa, int co
|
|
|
608b37 |
MALLOCARRAY_NOFAIL(rowData, rows);
|
|
|
608b37 |
icBitmap->xBytes = xBytes;
|
|
|
608b37 |
icBitmap->data = rowData;
|
|
|
608b37 |
+ overflow2(xBytes, rows);
|
|
|
608b37 |
icBitmap->size = xBytes * rows;
|
|
|
608b37 |
|
|
|
608b37 |
for (y=0;y
|
|
|
608b37 |
@@ -402,6 +405,7 @@ create8Bitmap (pixel ** const pa, int co
|
|
|
608b37 |
MALLOCARRAY_NOFAIL(rowData, rows);
|
|
|
608b37 |
icBitmap->xBytes = xBytes;
|
|
|
608b37 |
icBitmap->data = rowData;
|
|
|
608b37 |
+ overflow2(xBytes, rows);
|
|
|
608b37 |
icBitmap->size = xBytes * rows;
|
|
|
608b37 |
|
|
|
608b37 |
for (y=0;y
|
|
|
608b37 |
@@ -709,6 +713,10 @@ addEntryToIcon(MS_Ico const MSIcon
|
|
|
608b37 |
entry->bitcount = bpp;
|
|
|
608b37 |
entry->ih = createInfoHeader(entry, xorBitmap, andBitmap);
|
|
|
608b37 |
entry->colors = palette->colors;
|
|
|
608b37 |
+ overflow2(4, entry->color_count);
|
|
|
608b37 |
+ overflow_add(xorBitmap->size, andBitmap->size);
|
|
|
608b37 |
+ overflow_add(xorBitmap->size + andBitmap->size, 40);
|
|
|
608b37 |
+ overflow_add(xorBitmap->size + andBitmap->size + 40, 4 * entry->color_count);
|
|
|
608b37 |
entry->size_in_bytes =
|
|
|
608b37 |
xorBitmap->size + andBitmap->size + 40 + (4 * entry->color_count);
|
|
|
608b37 |
if (verbose)
|
|
|
608b37 |
diff -urNp old/converter/ppm/ppmtoxpm.c new/converter/ppm/ppmtoxpm.c
|
|
|
608b37 |
--- old/converter/ppm/ppmtoxpm.c 2017-09-05 15:09:01.004207383 +0200
|
|
|
608b37 |
+++ new/converter/ppm/ppmtoxpm.c 2017-09-06 10:34:25.169426581 +0200
|
|
|
608b37 |
@@ -198,6 +198,7 @@ genNumstr(unsigned int const input, int
|
|
|
608b37 |
unsigned int i;
|
|
|
608b37 |
|
|
|
608b37 |
/* Allocate memory for printed number. Abort if error. */
|
|
|
608b37 |
+ overflow_add(digits, 1);
|
|
|
608b37 |
if (!(str = (char *) malloc(digits + 1)))
|
|
|
608b37 |
pm_error("out of memory");
|
|
|
608b37 |
|
|
|
608b37 |
@@ -315,6 +316,7 @@ genCmap(colorhist_vector const chv,
|
|
|
608b37 |
unsigned int charsPerPixel;
|
|
|
608b37 |
unsigned int xpmMaxval;
|
|
|
608b37 |
|
|
|
608b37 |
+ if (includeTransparent) overflow_add(ncolors, 1);
|
|
|
608b37 |
MALLOCARRAY(cmap, cmapSize);
|
|
|
608b37 |
if (cmapP == NULL)
|
|
|
608b37 |
pm_error("Out of memory allocating %u bytes for a color map.",
|
|
|
608b37 |
diff -urNp old/converter/ppm/qrttoppm.c new/converter/ppm/qrttoppm.c
|
|
|
608b37 |
--- old/converter/ppm/qrttoppm.c 2017-09-05 15:09:01.004207383 +0200
|
|
|
608b37 |
+++ new/converter/ppm/qrttoppm.c 2017-09-06 10:35:08.784199292 +0200
|
|
|
608b37 |
@@ -46,7 +46,7 @@ main( argc, argv )
|
|
|
608b37 |
|
|
|
608b37 |
ppm_writeppminit( stdout, cols, rows, maxval, 0 );
|
|
|
608b37 |
pixelrow = ppm_allocrow( cols );
|
|
|
608b37 |
- buf = (unsigned char *) malloc( 3 * cols );
|
|
|
608b37 |
+ buf = (unsigned char *) malloc2( 3, cols );
|
|
|
608b37 |
if ( buf == (unsigned char *) 0 )
|
|
|
608b37 |
pm_error( "out of memory" );
|
|
|
608b37 |
|
|
|
608b37 |
diff -urNp old/converter/ppm/sldtoppm.c new/converter/ppm/sldtoppm.c
|
|
|
608b37 |
--- old/converter/ppm/sldtoppm.c 2017-09-05 15:09:01.002207393 +0200
|
|
|
608b37 |
+++ new/converter/ppm/sldtoppm.c 2017-09-06 10:36:09.873951211 +0200
|
|
|
608b37 |
@@ -463,7 +463,8 @@ slider(slvecfn slvec,
|
|
|
608b37 |
}
|
|
|
608b37 |
|
|
|
608b37 |
/* Allocate image buffer and clear it to black. */
|
|
|
608b37 |
-
|
|
|
608b37 |
+ overflow_add(ixdots,1);
|
|
|
608b37 |
+ overflow_add(iydots,1);
|
|
|
608b37 |
pixels = ppm_allocarray(pixcols = ixdots + 1, pixrows = iydots + 1);
|
|
|
608b37 |
PPM_ASSIGN(rgbcolor, 0, 0, 0);
|
|
|
608b37 |
ppmd_filledrectangle(pixels, pixcols, pixrows, pixmaxval, 0, 0,
|
|
|
608b37 |
diff -urNp old/converter/ppm/ximtoppm.c new/converter/ppm/ximtoppm.c
|
|
|
608b37 |
--- old/converter/ppm/ximtoppm.c 2017-09-05 15:09:01.003207388 +0200
|
|
|
608b37 |
+++ new/converter/ppm/ximtoppm.c 2017-09-06 10:38:43.249091632 +0200
|
|
|
608b37 |
@@ -118,6 +118,7 @@ ReadXimHeader(FILE * const in_fp,
|
|
|
608b37 |
header->bits_channel = atoi(a_head.bits_per_channel);
|
|
|
608b37 |
header->alpha_flag = atoi(a_head.alpha_channel);
|
|
|
608b37 |
if (strlen(a_head.author)) {
|
|
|
608b37 |
+ overflow_add(strlen(a_head.author),1);
|
|
|
608b37 |
if (!(header->author = calloc((unsigned int)strlen(a_head.author)+1,
|
|
|
608b37 |
1))) {
|
|
|
608b37 |
pm_message("ReadXimHeader: can't calloc author string" );
|
|
|
608b37 |
@@ -127,6 +128,7 @@ ReadXimHeader(FILE * const in_fp,
|
|
|
608b37 |
strncpy(header->author, a_head.author, strlen(a_head.author));
|
|
|
608b37 |
}
|
|
|
608b37 |
if (strlen(a_head.date)) {
|
|
|
608b37 |
+ overflow_add(strlen(a_head.date),1);
|
|
|
608b37 |
if (!(header->date =calloc((unsigned int)strlen(a_head.date)+1,1))){
|
|
|
608b37 |
pm_message("ReadXimHeader: can't calloc date string" );
|
|
|
608b37 |
return(0);
|
|
|
608b37 |
@@ -135,6 +137,7 @@ ReadXimHeader(FILE * const in_fp,
|
|
|
608b37 |
strncpy(header->date, a_head.date, strlen(a_head.date));
|
|
|
608b37 |
}
|
|
|
608b37 |
if (strlen(a_head.program)) {
|
|
|
608b37 |
+ overflow_add(strlen(a_head.program),1);
|
|
|
608b37 |
if (!(header->program = calloc(
|
|
|
608b37 |
(unsigned int)strlen(a_head.program) + 1, 1))) {
|
|
|
608b37 |
pm_message("ReadXimHeader: can't calloc program string" );
|
|
|
608b37 |
@@ -161,6 +164,7 @@ ReadXimHeader(FILE * const in_fp,
|
|
|
608b37 |
if (header->nchannels == 3 && header->bits_channel == 8)
|
|
|
608b37 |
header->ncolors = 0;
|
|
|
608b37 |
else if (header->nchannels == 1 && header->bits_channel == 8) {
|
|
|
608b37 |
+ overflow2(header->ncolors, sizeof(Color));
|
|
|
608b37 |
header->colors = (Color *)calloc((unsigned int)header->ncolors,
|
|
|
608b37 |
sizeof(Color));
|
|
|
608b37 |
if (header->colors == NULL) {
|
|
|
608b37 |
diff -urNp old/editor/pamcut.c new/editor/pamcut.c
|
|
|
608b37 |
--- old/editor/pamcut.c 2017-09-05 15:09:00.983207488 +0200
|
|
|
608b37 |
+++ new/editor/pamcut.c 2017-09-06 10:42:53.441815922 +0200
|
|
|
608b37 |
@@ -655,6 +655,8 @@ cutOneImage(FILE * const ifP
|
|
|
608b37 |
|
|
|
608b37 |
outpam = inpam; /* Initial value -- most fields should be same */
|
|
|
608b37 |
outpam.file = ofP;
|
|
|
608b37 |
+ overflow_add(rightcol, 1);
|
|
|
608b37 |
+ overflow_add(bottomrow, 1);
|
|
|
608b37 |
outpam.width = rightcol - leftcol + 1;
|
|
|
608b37 |
outpam.height = bottomrow - toprow + 1;
|
|
|
608b37 |
|
|
|
608b37 |
diff -urNp old/editor/pnmgamma.c new/editor/pnmgamma.c
|
|
|
608b37 |
--- old/editor/pnmgamma.c 2017-09-05 15:09:00.985207478 +0200
|
|
|
608b37 |
+++ new/editor/pnmgamma.c 2017-09-06 10:45:16.328461856 +0200
|
|
|
608b37 |
@@ -596,6 +596,7 @@ createGammaTables(enum transferFunction
|
|
|
608b37 |
xelval ** const btableP) {
|
|
|
608b37 |
|
|
|
608b37 |
/* Allocate space for the tables. */
|
|
|
608b37 |
+ overflow_add(maxval, 1);
|
|
|
608b37 |
MALLOCARRAY(*rtableP, maxval+1);
|
|
|
608b37 |
MALLOCARRAY(*gtableP, maxval+1);
|
|
|
608b37 |
MALLOCARRAY(*btableP, maxval+1);
|
|
|
608b37 |
diff -urNp old/editor/pnmhisteq.c new/editor/pnmhisteq.c
|
|
|
608b37 |
--- old/editor/pnmhisteq.c 2017-09-05 15:09:00.983207488 +0200
|
|
|
608b37 |
+++ new/editor/pnmhisteq.c 2017-09-06 10:46:30.959235397 +0200
|
|
|
608b37 |
@@ -107,6 +107,7 @@ computeLuminosityHistogram(xel * const *
|
|
|
608b37 |
unsigned int pixelCount;
|
|
|
608b37 |
unsigned int * lumahist;
|
|
|
608b37 |
|
|
|
608b37 |
+ overflow_add(maxval, 1);
|
|
|
608b37 |
MALLOCARRAY(lumahist, maxval + 1);
|
|
|
608b37 |
if (lumahist == NULL)
|
|
|
608b37 |
pm_error("Out of storage allocating array for %u histogram elements",
|
|
|
608b37 |
diff -urNp old/editor/pnmindex.csh new/editor/pnmindex.csh
|
|
|
608b37 |
--- old/editor/pnmindex.csh 2017-09-05 15:09:00.986207473 +0200
|
|
|
608b37 |
+++ new/editor/pnmindex.csh 2017-09-06 10:47:46.007983350 +0200
|
|
|
608b37 |
@@ -1,5 +1,8 @@
|
|
|
608b37 |
#!/bin/csh -f
|
|
|
608b37 |
#
|
|
|
608b37 |
+echo "Unsafe code, needs debugging, do not ship"
|
|
|
608b37 |
+exit 1
|
|
|
608b37 |
+#
|
|
|
608b37 |
# pnmindex - build a visual index of a bunch of anymaps
|
|
|
608b37 |
#
|
|
|
608b37 |
# Copyright (C) 1991 by Jef Poskanzer.
|
|
|
608b37 |
diff -urNp old/editor/pnmpad.c new/editor/pnmpad.c
|
|
|
608b37 |
--- old/editor/pnmpad.c 2017-09-05 15:09:00.983207488 +0200
|
|
|
608b37 |
+++ new/editor/pnmpad.c 2017-09-06 10:48:42.415778475 +0200
|
|
|
608b37 |
@@ -634,6 +634,8 @@ main(int argc, const char ** argv) {
|
|
|
608b37 |
|
|
|
608b37 |
computePadSizes(cmdline, cols, rows, &lpad, &rpad, &tpad, &bpad);
|
|
|
608b37 |
|
|
|
608b37 |
+ overflow_add(cols, lpad);
|
|
|
608b37 |
+ overflow_add(cols + lpad, rpad);
|
|
|
608b37 |
newcols = cols + lpad + rpad;
|
|
|
608b37 |
|
|
|
608b37 |
if (PNM_FORMAT_TYPE(format) == PBM_TYPE)
|
|
|
608b37 |
diff -urNp old/editor/pnmremap.c new/editor/pnmremap.c
|
|
|
608b37 |
--- old/editor/pnmremap.c 2017-09-05 15:09:00.984207483 +0200
|
|
|
608b37 |
+++ new/editor/pnmremap.c 2017-09-06 10:49:56.879492310 +0200
|
|
|
608b37 |
@@ -430,6 +430,7 @@ initFserr(struct pam * const pamP,
|
|
|
608b37 |
|
|
|
608b37 |
unsigned int const fserrSize = pamP->width + 2;
|
|
|
608b37 |
|
|
|
608b37 |
+ overflow_add(pamP->width, 2);
|
|
|
608b37 |
fserrP->width = pamP->width;
|
|
|
608b37 |
|
|
|
608b37 |
MALLOCARRAY(fserrP->thiserr, pamP->depth);
|
|
|
608b37 |
@@ -467,6 +468,7 @@ floydInitRow(struct pam * const pamP, st
|
|
|
608b37 |
|
|
|
608b37 |
int col;
|
|
|
608b37 |
|
|
|
608b37 |
+ overflow_add(pamP->width, 2);
|
|
|
608b37 |
for (col = 0; col < pamP->width + 2; ++col) {
|
|
|
608b37 |
unsigned int plane;
|
|
|
608b37 |
for (plane = 0; plane < pamP->depth; ++plane)
|
|
|
608b37 |
diff -urNp old/editor/pnmscalefixed.c new/editor/pnmscalefixed.c
|
|
|
608b37 |
--- old/editor/pnmscalefixed.c 2017-09-05 15:09:00.986207473 +0200
|
|
|
608b37 |
+++ new/editor/pnmscalefixed.c 2017-09-06 10:52:07.110955503 +0200
|
|
|
608b37 |
@@ -214,6 +214,8 @@ compute_output_dimensions(const struct c
|
|
|
608b37 |
const int rows, const int cols,
|
|
|
608b37 |
int * newrowsP, int * newcolsP) {
|
|
|
608b37 |
|
|
|
608b37 |
+ overflow2(rows, cols);
|
|
|
608b37 |
+
|
|
|
608b37 |
if (cmdline.pixels) {
|
|
|
608b37 |
if (rows * cols <= cmdline.pixels) {
|
|
|
608b37 |
*newrowsP = rows;
|
|
|
608b37 |
@@ -265,6 +267,8 @@ compute_output_dimensions(const struct c
|
|
|
608b37 |
|
|
|
608b37 |
if (*newcolsP < 1) *newcolsP = 1;
|
|
|
608b37 |
if (*newrowsP < 1) *newrowsP = 1;
|
|
|
608b37 |
+
|
|
|
608b37 |
+ overflow2(*newcolsP, *newrowsP);
|
|
|
608b37 |
}
|
|
|
608b37 |
|
|
|
608b37 |
|
|
|
608b37 |
@@ -446,6 +450,9 @@ main(int argc, char **argv ) {
|
|
|
608b37 |
unfilled. We can address that by stretching, whereas the other
|
|
|
608b37 |
case would require throwing away some of the input.
|
|
|
608b37 |
*/
|
|
|
608b37 |
+
|
|
|
608b37 |
+ overflow2(newcols, SCALE);
|
|
|
608b37 |
+ overflow2(newrows, SCALE);
|
|
|
608b37 |
sxscale = SCALE * newcols / cols;
|
|
|
608b37 |
syscale = SCALE * newrows / rows;
|
|
|
608b37 |
|
|
|
608b37 |
diff -urNp old/editor/pnmshear.c new/editor/pnmshear.c
|
|
|
608b37 |
--- old/editor/pnmshear.c 2017-09-05 15:09:00.985207478 +0200
|
|
|
608b37 |
+++ new/editor/pnmshear.c 2017-09-06 11:57:18.485705533 +0200
|
|
|
608b37 |
@@ -15,6 +15,7 @@
|
|
|
608b37 |
#include <assert.h>
|
|
|
608b37 |
#include <math.h>
|
|
|
608b37 |
#include <string.h>
|
|
|
608b37 |
+#include <limits.h>
|
|
|
608b37 |
|
|
|
608b37 |
#include "pm_c_util.h"
|
|
|
608b37 |
#include "mallocvar.h"
|
|
|
608b37 |
@@ -242,6 +243,11 @@ main(int argc, const char * argv[]) {
|
|
|
608b37 |
|
|
|
608b37 |
shearfac = fabs(tan(cmdline.angle));
|
|
|
608b37 |
|
|
|
608b37 |
+ if(rows * shearfac >= INT_MAX-1)
|
|
|
608b37 |
+ pm_error("image too large");
|
|
|
608b37 |
+
|
|
|
608b37 |
+ overflow_add(rows * shearfac, cols+1);
|
|
|
608b37 |
+
|
|
|
608b37 |
newcols = rows * shearfac + cols + 0.999999;
|
|
|
608b37 |
|
|
|
608b37 |
pnm_writepnminit(stdout, newcols, rows, newmaxval, newformat, 0);
|
|
|
608b37 |
diff -urNp old/editor/ppmdither.c new/editor/ppmdither.c
|
|
|
608b37 |
--- old/editor/ppmdither.c 2017-09-05 15:09:00.984207483 +0200
|
|
|
608b37 |
+++ new/editor/ppmdither.c 2017-09-06 11:57:58.507533974 +0200
|
|
|
608b37 |
@@ -355,6 +355,10 @@ dithMatrix(unsigned int const dithPower)
|
|
|
608b37 |
unsigned int const dithMatSize =
|
|
|
608b37 |
(dithDim * sizeof(*dithMat)) + /* pointers */
|
|
|
608b37 |
(dithDim * dithDim * sizeof(**dithMat)); /* data */
|
|
|
608b37 |
+
|
|
|
608b37 |
+ overflow2(dithDim, sizeof(*dithMat));
|
|
|
608b37 |
+ overflow3(dithDim, dithDim, sizeof(**dithMat));
|
|
|
608b37 |
+ overflow_add(dithDim * sizeof(*dithMat), dithDim * dithDim * sizeof(**dithMat));
|
|
|
608b37 |
|
|
|
608b37 |
dithMat = malloc(dithMatSize);
|
|
|
608b37 |
|
|
|
608b37 |
diff -urNp old/editor/specialty/pamoil.c new/editor/specialty/pamoil.c
|
|
|
608b37 |
--- old/editor/specialty/pamoil.c 2017-09-05 15:09:00.986207473 +0200
|
|
|
608b37 |
+++ new/editor/specialty/pamoil.c 2017-09-06 11:58:39.091357659 +0200
|
|
|
608b37 |
@@ -112,6 +112,7 @@ main(int argc, char *argv[] ) {
|
|
|
608b37 |
tuples = pnm_readpam(ifp, &inpam, PAM_STRUCT_SIZE(tuple_type));
|
|
|
608b37 |
pm_close(ifp);
|
|
|
608b37 |
|
|
|
608b37 |
+ overflow_add(inpam.maxval, 1);
|
|
|
608b37 |
MALLOCARRAY(hist, inpam.maxval + 1);
|
|
|
608b37 |
if (hist == NULL)
|
|
|
608b37 |
pm_error("Unable to allocate memory for histogram.");
|
|
|
608b37 |
diff -urNp old/generator/pbmtext.c new/generator/pbmtext.c
|
|
|
608b37 |
--- old/generator/pbmtext.c 2017-09-05 15:09:00.957207619 +0200
|
|
|
608b37 |
+++ new/generator/pbmtext.c 2017-09-06 12:02:22.348352850 +0200
|
|
|
608b37 |
@@ -125,6 +125,7 @@ parseCommandLine(int argc, const char **
|
|
|
608b37 |
if (i > 1) {
|
|
|
608b37 |
strcat(text, " ");
|
|
|
608b37 |
}
|
|
|
608b37 |
+ overflow_add(totaltextsize, strlen(argv[i]) + 1);
|
|
|
608b37 |
totaltextsize += strlen(argv[i]) + 1;
|
|
|
608b37 |
if (totaltextsize > MAXLINECHARS)
|
|
|
608b37 |
pm_error("input text too long");
|
|
|
608b37 |
@@ -745,6 +746,7 @@ getText(char const cmdlineText[
|
|
|
608b37 |
pm_error("A line of input text is longer than %u characters."
|
|
|
608b37 |
"Cannot process", (unsigned int) MAXLINECHARS-1);
|
|
|
608b37 |
if (lineCount >= maxlines) {
|
|
|
608b37 |
+ overflow2(maxlines, 2);
|
|
|
608b37 |
maxlines *= 2;
|
|
|
608b37 |
REALLOCARRAY(textArray, maxlines);
|
|
|
608b37 |
if (textArray == NULL)
|
|
|
608b37 |
@@ -781,6 +783,7 @@ computeMargins(struct CmdlineInfo const
|
|
|
608b37 |
*hmarginP = fontP->maxwidth;
|
|
|
608b37 |
} else {
|
|
|
608b37 |
*vmarginP = fontP->maxheight;
|
|
|
608b37 |
+ overflow2(2, fontP->maxwidth);
|
|
|
608b37 |
*hmarginP = 2 * fontP->maxwidth;
|
|
|
608b37 |
}
|
|
|
608b37 |
}
|
|
|
608b37 |
diff -urNp old/lib/libpam.c new/lib/libpam.c
|
|
|
608b37 |
--- old/lib/libpam.c 2017-09-05 15:09:00.978207513 +0200
|
|
|
608b37 |
+++ new/lib/libpam.c 2017-09-06 12:06:07.132297384 +0200
|
|
|
608b37 |
@@ -225,7 +225,8 @@ allocPamRow(const struct pam * const pam
|
|
|
608b37 |
unsigned int const bytesPerTuple = allocationDepth(pamP) * sizeof(sample);
|
|
|
608b37 |
tuple * tuplerow;
|
|
|
608b37 |
|
|
|
608b37 |
- tuplerow = malloc(pamP->width * (sizeof(tuple *) + bytesPerTuple));
|
|
|
608b37 |
+ overflow_add(sizeof(tuple *), bytesPerTuple);
|
|
|
608b37 |
+ tuplerow = malloc2(pamP->width, (sizeof(tuple *) + bytesPerTuple));
|
|
|
608b37 |
|
|
|
608b37 |
if (tuplerow != NULL) {
|
|
|
608b37 |
/* Now we initialize the pointers to the individual tuples
|
|
|
608b37 |
diff -urNp old/lib/libpammap.c new/lib/libpammap.c
|
|
|
608b37 |
--- old/lib/libpammap.c 2017-09-05 15:09:00.977207518 +0200
|
|
|
608b37 |
+++ new/lib/libpammap.c 2017-09-06 12:06:50.764088850 +0200
|
|
|
608b37 |
@@ -108,6 +108,8 @@ allocTupleIntListItem(struct pam * const
|
|
|
608b37 |
*/
|
|
|
608b37 |
struct tupleint_list_item * retval;
|
|
|
608b37 |
|
|
|
608b37 |
+ overflow2(pamP->depth, sizeof(sample));
|
|
|
608b37 |
+ overflow_add(sizeof(*retval)-sizeof(retval->tupleint.tuple), pamP->depth*sizeof(sample));
|
|
|
608b37 |
unsigned int const size =
|
|
|
608b37 |
sizeof(*retval) - sizeof(retval->tupleint.tuple)
|
|
|
608b37 |
+ pamP->depth * sizeof(sample);
|
|
|
608b37 |
diff -urNp old/lib/libpbm1.c new/lib/libpbm1.c
|
|
|
608b37 |
--- old/lib/libpbm1.c 2017-09-05 15:09:00.978207513 +0200
|
|
|
608b37 |
+++ new/lib/libpbm1.c 2017-09-06 12:11:41.063680260 +0200
|
|
|
608b37 |
@@ -77,6 +77,7 @@ pbm_check(FILE * const fil
|
|
|
608b37 |
if (retvalP)
|
|
|
608b37 |
*retvalP = PM_CHECK_UNCHECKABLE;
|
|
|
608b37 |
} else {
|
|
|
608b37 |
+ overflow_add(cols, 7);
|
|
|
608b37 |
pm_filepos const bytesPerRow = (cols+7)/8;
|
|
|
608b37 |
pm_filepos const needRasterSize = rows * bytesPerRow;
|
|
|
608b37 |
pm_check(fileP, checkType, needRasterSize, retvalP);
|
|
|
608b37 |
diff -urNp old/lib/libpm.c new/lib/libpm.c
|
|
|
608b37 |
--- old/lib/libpm.c 2017-09-05 15:09:00.977207518 +0200
|
|
|
608b37 |
+++ new/lib/libpm.c 2017-09-06 12:13:26.144162930 +0200
|
|
|
608b37 |
@@ -889,4 +889,52 @@ pm_parse_height(const char * const arg)
|
|
|
608b37 |
}
|
|
|
608b37 |
|
|
|
608b37 |
|
|
|
608b37 |
+/*
|
|
|
608b37 |
+ * Maths wrapping
|
|
|
608b37 |
+ */
|
|
|
608b37 |
+
|
|
|
608b37 |
+void __overflow2(int a, int b)
|
|
|
608b37 |
+{
|
|
|
608b37 |
+ if(a < 0 || b < 0)
|
|
|
608b37 |
+ pm_error("object too large");
|
|
|
608b37 |
+ if(b == 0)
|
|
|
608b37 |
+ return;
|
|
|
608b37 |
+ if(a > INT_MAX / b)
|
|
|
608b37 |
+ pm_error("object too large");
|
|
|
608b37 |
+}
|
|
|
608b37 |
+
|
|
|
608b37 |
+void overflow3(int a, int b, int c)
|
|
|
608b37 |
+{
|
|
|
608b37 |
+ overflow2(a,b);
|
|
|
608b37 |
+ overflow2(a*b, c);
|
|
|
608b37 |
+}
|
|
|
608b37 |
+
|
|
|
608b37 |
+void overflow_add(int a, int b)
|
|
|
608b37 |
+{
|
|
|
608b37 |
+ if( a > INT_MAX - b)
|
|
|
608b37 |
+ pm_error("object too large");
|
|
|
608b37 |
+}
|
|
|
608b37 |
|
|
|
608b37 |
+void *malloc2(int a, int b)
|
|
|
608b37 |
+{
|
|
|
608b37 |
+ overflow2(a, b);
|
|
|
608b37 |
+ if(a*b == 0)
|
|
|
608b37 |
+ pm_error("Zero byte allocation");
|
|
|
608b37 |
+ return malloc(a*b);
|
|
|
608b37 |
+}
|
|
|
608b37 |
+
|
|
|
608b37 |
+void *malloc3(int a, int b, int c)
|
|
|
608b37 |
+{
|
|
|
608b37 |
+ overflow3(a, b, c);
|
|
|
608b37 |
+ if(a*b*c == 0)
|
|
|
608b37 |
+ pm_error("Zero byte allocation");
|
|
|
608b37 |
+ return malloc(a*b*c);
|
|
|
608b37 |
+}
|
|
|
608b37 |
+
|
|
|
608b37 |
+void *realloc2(void * a, int b, int c)
|
|
|
608b37 |
+{
|
|
|
608b37 |
+ overflow2(b, c);
|
|
|
608b37 |
+ if(b*c == 0)
|
|
|
608b37 |
+ pm_error("Zero byte allocation");
|
|
|
608b37 |
+ return realloc(a, b*c);
|
|
|
608b37 |
+}
|
|
|
608b37 |
diff -urNp old/lib/pm.h new/lib/pm.h
|
|
|
608b37 |
--- old/lib/pm.h 2017-09-05 15:09:00.979207508 +0200
|
|
|
608b37 |
+++ new/lib/pm.h 2017-09-06 12:14:44.159772344 +0200
|
|
|
608b37 |
@@ -435,5 +435,11 @@ pm_parse_height(const char * const arg);
|
|
|
608b37 |
}
|
|
|
608b37 |
#endif
|
|
|
608b37 |
|
|
|
608b37 |
+void *malloc2(int, int);
|
|
|
608b37 |
+void *malloc3(int, int, int);
|
|
|
608b37 |
+#define overflow2(a,b) __overflow2(a,b)
|
|
|
608b37 |
+void __overflow2(int, int);
|
|
|
608b37 |
+void overflow3(int, int, int);
|
|
|
608b37 |
+void overflow_add(int, int);
|
|
|
608b37 |
|
|
|
608b37 |
#endif
|
|
|
608b37 |
diff -urNp old/other/pnmcolormap.c new/other/pnmcolormap.c
|
|
|
608b37 |
--- old/other/pnmcolormap.c 2017-09-05 15:09:00.982207493 +0200
|
|
|
608b37 |
+++ new/other/pnmcolormap.c 2017-09-06 12:16:38.998195226 +0200
|
|
|
608b37 |
@@ -836,10 +836,12 @@ colormapToSquare(struct pam * const pamP
|
|
|
608b37 |
tuple *** const outputRasterP) {
|
|
|
608b37 |
{
|
|
|
608b37 |
unsigned int const intsqrt = (int)sqrt((float)colormap.size);
|
|
|
608b37 |
- if (intsqrt * intsqrt == colormap.size)
|
|
|
608b37 |
+ if (intsqrt * intsqrt == colormap.size)
|
|
|
608b37 |
pamP->width = intsqrt;
|
|
|
608b37 |
- else
|
|
|
608b37 |
- pamP->width = intsqrt + 1;
|
|
|
608b37 |
+ else {
|
|
|
608b37 |
+ overflow_add(intsqrt, 1);
|
|
|
608b37 |
+ pamP->width = intsqrt + 1;
|
|
|
608b37 |
+ }
|
|
|
608b37 |
}
|
|
|
608b37 |
{
|
|
|
608b37 |
unsigned int const intQuotient = colormap.size / pamP->width;
|
|
|
608b37 |
diff -urNp old/urt/README new/urt/README
|
|
|
608b37 |
--- old/urt/README 2017-09-05 15:09:00.975207528 +0200
|
|
|
608b37 |
+++ new/urt/README 2017-09-06 12:18:11.582728375 +0200
|
|
|
608b37 |
@@ -18,3 +18,12 @@ in its initializer in the original. But
|
|
|
608b37 |
defines stdout as a variable, so that wouldn't compile. So I changed
|
|
|
608b37 |
it to NULL and added a line to rle_hdr_init to set that field to
|
|
|
608b37 |
'stdout' dynamically. 2000.06.02 BJH.
|
|
|
608b37 |
+
|
|
|
608b37 |
+Redid the code to check for maths overflows and other crawly horrors.
|
|
|
608b37 |
+Removed pipe through and compress support (unsafe)
|
|
|
608b37 |
+
|
|
|
608b37 |
+Alan Cox <alan@redhat.com>
|
|
|
608b37 |
+
|
|
|
608b37 |
+Update Alan's changes for version 10.79.00.
|
|
|
608b37 |
+
|
|
|
608b37 |
+Josef Ridky <jridky@redhat.com>
|
|
|
608b37 |
diff -urNp old/urt/rle_addhist.c new/urt/rle_addhist.c
|
|
|
608b37 |
--- old/urt/rle_addhist.c 2017-09-05 15:09:00.976207523 +0200
|
|
|
608b37 |
+++ new/urt/rle_addhist.c 2017-09-06 12:20:37.615007358 +0200
|
|
|
608b37 |
@@ -14,6 +14,8 @@
|
|
|
608b37 |
* If you modify this software, you should include a notice giving the
|
|
|
608b37 |
* name of the person performing the modification, the date of modification,
|
|
|
608b37 |
* and the reason for such modification.
|
|
|
608b37 |
+ *
|
|
|
608b37 |
+ * 2002-12-19: Fix maths wrapping bugs. Alan Cox <alan@redhat.com>
|
|
|
608b37 |
*/
|
|
|
608b37 |
/*
|
|
|
608b37 |
* rle_addhist.c - Add to the HISTORY comment in header
|
|
|
608b37 |
@@ -70,13 +72,19 @@ rle_addhist(char * argv[],
|
|
|
608b37 |
return;
|
|
|
608b37 |
|
|
|
608b37 |
length = 0;
|
|
|
608b37 |
- for (i = 0; argv[i]; ++i)
|
|
|
608b37 |
+ for (i = 0; argv[i]; ++i) {
|
|
|
608b37 |
+ overflow_add(length, strlen(argv[i]));
|
|
|
608b37 |
+ overflow_add(length+1, strlen(argv[i]));
|
|
|
608b37 |
length += strlen(argv[i]) +1; /* length of each arg plus space. */
|
|
|
608b37 |
+ }
|
|
|
608b37 |
|
|
|
608b37 |
time(&temp);
|
|
|
608b37 |
timedate = ctime(&temp);
|
|
|
608b37 |
length += strlen(timedate); /* length of date and time in ASCII. */
|
|
|
608b37 |
|
|
|
608b37 |
+ overflow_add(strlen(padding), 4);
|
|
|
608b37 |
+ overflow_add(strlen(histoire), strlen(padding) + 4);
|
|
|
608b37 |
+ overflow_add(length, strlen(histoire) + strlen(padding) + 4);
|
|
|
608b37 |
length += strlen(padding) + 3 + strlen(histoire) + 1;
|
|
|
608b37 |
/* length of padding, "on " and length of history name plus "="*/
|
|
|
608b37 |
if (in_hdr) /* if we are interested in the old comments... */
|
|
|
608b37 |
@@ -84,9 +92,12 @@ rle_addhist(char * argv[],
|
|
|
608b37 |
else
|
|
|
608b37 |
old = NULL;
|
|
|
608b37 |
|
|
|
608b37 |
- if (old && *old)
|
|
|
608b37 |
+ if (old && *old) {
|
|
|
608b37 |
+ overflow_add(length, strlen(old));
|
|
|
608b37 |
length += strlen(old); /* add length if there. */
|
|
|
608b37 |
+ }
|
|
|
608b37 |
|
|
|
608b37 |
+ overflow_add(length, 1);
|
|
|
608b37 |
++length; /*Cater for the null. */
|
|
|
608b37 |
|
|
|
608b37 |
MALLOCARRAY(newc, length);
|
|
|
608b37 |
diff -urNp old/urt/rle_getrow.c new/urt/rle_getrow.c
|
|
|
608b37 |
--- old/urt/rle_getrow.c 2017-09-05 15:09:00.976207523 +0200
|
|
|
608b37 |
+++ new/urt/rle_getrow.c 2017-09-06 12:21:51.591095294 +0200
|
|
|
608b37 |
@@ -17,6 +17,8 @@
|
|
|
608b37 |
*
|
|
|
608b37 |
* Modified at BRL 16-May-88 by Mike Muuss to avoid Alliant STDC desire
|
|
|
608b37 |
* to have all "void" functions so declared.
|
|
|
608b37 |
+ *
|
|
|
608b37 |
+ * 2002-12-19: Fix maths wrapping bugs. Alan Cox <alan@redhat.com>
|
|
|
608b37 |
*/
|
|
|
608b37 |
/*
|
|
|
608b37 |
* rle_getrow.c - Read an RLE file in.
|
|
|
608b37 |
@@ -160,6 +162,7 @@ rle_get_setup(rle_hdr * const the_hdr) {
|
|
|
608b37 |
char * cp;
|
|
|
608b37 |
|
|
|
608b37 |
VAXSHORT(comlen, infile); /* get comment length */
|
|
|
608b37 |
+ overflow_add(comlen, 1);
|
|
|
608b37 |
evenlen = (comlen + 1) & ~1; /* make it even */
|
|
|
608b37 |
if (evenlen) {
|
|
|
608b37 |
MALLOCARRAY(comment_buf, evenlen);
|
|
|
608b37 |
diff -urNp old/urt/rle.h new/urt/rle.h
|
|
|
608b37 |
--- old/urt/rle.h 2017-09-05 15:09:00.976207523 +0200
|
|
|
608b37 |
+++ new/urt/rle.h 2017-09-06 12:28:40.502652837 +0200
|
|
|
608b37 |
@@ -14,6 +14,9 @@
|
|
|
608b37 |
* If you modify this software, you should include a notice giving the
|
|
|
608b37 |
* name of the person performing the modification, the date of modification,
|
|
|
608b37 |
* and the reason for such modification.
|
|
|
608b37 |
+ *
|
|
|
608b37 |
+ * 2002-12-19: Fix maths wrapping bugs. Alan Cox <alan@redhat.com>
|
|
|
608b37 |
+ * Header declarations needed
|
|
|
608b37 |
*/
|
|
|
608b37 |
/*
|
|
|
608b37 |
* rle.h - Global declarations for Utah Raster Toolkit RLE programs.
|
|
|
608b37 |
@@ -161,6 +164,17 @@ rle_hdr /* End of typedef. *
|
|
|
608b37 |
*/
|
|
|
608b37 |
extern rle_hdr rle_dflt_hdr;
|
|
|
608b37 |
|
|
|
608b37 |
+/*
|
|
|
608b37 |
+ * Provided by pm library
|
|
|
608b37 |
+ */
|
|
|
608b37 |
+
|
|
|
608b37 |
+extern void overflow_add(int, int);
|
|
|
608b37 |
+#define overflow2(a,b) __overflow2(a,b)
|
|
|
608b37 |
+extern void __overflow2(int, int);
|
|
|
608b37 |
+extern void overflow3(int, int, int);
|
|
|
608b37 |
+extern void *malloc2(int, int);
|
|
|
608b37 |
+extern void *malloc3(int, int, int);
|
|
|
608b37 |
+extern void *realloc2(void *, int, int);
|
|
|
608b37 |
|
|
|
608b37 |
/* Declare RLE library routines. */
|
|
|
608b37 |
|
|
|
608b37 |
diff -urNp old/urt/rle_hdr.c new/urt/rle_hdr.c
|
|
|
608b37 |
--- old/urt/rle_hdr.c 2017-09-05 15:09:00.976207523 +0200
|
|
|
608b37 |
+++ new/urt/rle_hdr.c 2017-09-06 12:27:23.846827208 +0200
|
|
|
608b37 |
@@ -14,6 +14,8 @@
|
|
|
608b37 |
* If you modify this software, you should include a notice giving the
|
|
|
608b37 |
* name of the person performing the modification, the date of modification,
|
|
|
608b37 |
* and the reason for such modification.
|
|
|
608b37 |
+ *
|
|
|
608b37 |
+ * 2002-12-19: Fix maths wrapping bugs. Alan Cox <alan@redhat.com>
|
|
|
608b37 |
*/
|
|
|
608b37 |
/*
|
|
|
608b37 |
* rle_hdr.c - Functions to manipulate rle_hdr structures.
|
|
|
608b37 |
@@ -80,7 +82,10 @@ int img_num;
|
|
|
608b37 |
/* Fill in with copies of the strings. */
|
|
|
608b37 |
if ( the_hdr->cmd != pgmname )
|
|
|
608b37 |
{
|
|
|
608b37 |
- char *tmp = (char *)malloc( strlen( pgmname ) + 1 );
|
|
|
608b37 |
+ char *tmp;
|
|
|
608b37 |
+
|
|
|
608b37 |
+ overflow_add(strlen(pgmname), 1);
|
|
|
608b37 |
+ tmp = (char *)malloc( strlen( pgmname ) + 1 );
|
|
|
608b37 |
RLE_CHECK_ALLOC( pgmname, tmp, 0 );
|
|
|
608b37 |
strcpy( tmp, pgmname );
|
|
|
608b37 |
the_hdr->cmd = tmp;
|
|
|
608b37 |
@@ -88,7 +93,10 @@ int img_num;
|
|
|
608b37 |
|
|
|
608b37 |
if ( the_hdr->file_name != fname )
|
|
|
608b37 |
{
|
|
|
608b37 |
- char *tmp = (char *)malloc( strlen( fname ) + 1 );
|
|
|
608b37 |
+ char *tmp;
|
|
|
608b37 |
+
|
|
|
608b37 |
+ overflow_add(strlen(fname), 1);
|
|
|
608b37 |
+ tmp = (char *)malloc( strlen( fname ) + 1 );
|
|
|
608b37 |
RLE_CHECK_ALLOC( pgmname, tmp, 0 );
|
|
|
608b37 |
strcpy( tmp, fname );
|
|
|
608b37 |
the_hdr->file_name = tmp;
|
|
|
608b37 |
@@ -152,6 +160,7 @@ rle_hdr *from_hdr, *to_hdr;
|
|
|
608b37 |
|
|
|
608b37 |
if ( to_hdr->bg_color )
|
|
|
608b37 |
{
|
|
|
608b37 |
+ overflow2(to_hdr->ncolors, sizeof(int));
|
|
|
608b37 |
int size = to_hdr->ncolors * sizeof(int);
|
|
|
608b37 |
to_hdr->bg_color = (int *)malloc( size );
|
|
|
608b37 |
RLE_CHECK_ALLOC( to_hdr->cmd, to_hdr->bg_color, "background color" );
|
|
|
608b37 |
@@ -161,7 +170,7 @@ rle_hdr *from_hdr, *to_hdr;
|
|
|
608b37 |
if ( to_hdr->cmap )
|
|
|
608b37 |
{
|
|
|
608b37 |
int size = to_hdr->ncmap * (1 << to_hdr->cmaplen) * sizeof(rle_map);
|
|
|
608b37 |
- to_hdr->cmap = (rle_map *)malloc( size );
|
|
|
608b37 |
+ to_hdr->cmap = (rle_map *)malloc3( to_hdr->ncmap, 1<<to_hdr->cmaplen, sizeof(rle_map) );
|
|
|
608b37 |
RLE_CHECK_ALLOC( to_hdr->cmd, to_hdr->cmap, "color map" );
|
|
|
608b37 |
memcpy( to_hdr->cmap, from_hdr->cmap, size );
|
|
|
608b37 |
}
|
|
|
608b37 |
@@ -174,11 +183,16 @@ rle_hdr *from_hdr, *to_hdr;
|
|
|
608b37 |
int size = 0;
|
|
|
608b37 |
CONST_DECL char **cp;
|
|
|
608b37 |
for ( cp=to_hdr->comments; *cp; cp++ )
|
|
|
608b37 |
+ {
|
|
|
608b37 |
+ overflow_add(size, 1);
|
|
|
608b37 |
size++; /* Count the comments. */
|
|
|
608b37 |
+ }
|
|
|
608b37 |
/* Check if there are really any comments. */
|
|
|
608b37 |
if ( size )
|
|
|
608b37 |
{
|
|
|
608b37 |
+ overflow_add(size, 1);
|
|
|
608b37 |
size++; /* Copy the NULL pointer, too. */
|
|
|
608b37 |
+ overflow2(size, sizeof(char *));
|
|
|
608b37 |
size *= sizeof(char *);
|
|
|
608b37 |
to_hdr->comments = (CONST_DECL char **)malloc( size );
|
|
|
608b37 |
RLE_CHECK_ALLOC( to_hdr->cmd, to_hdr->comments, "comments" );
|
|
|
608b37 |
diff -urNp old/urt/rle_open_f.c new/urt/rle_open_f.c
|
|
|
608b37 |
--- old/urt/rle_open_f.c 2017-09-05 15:09:00.976207523 +0200
|
|
|
608b37 |
+++ new/urt/rle_open_f.c 2017-09-06 12:30:07.309418990 +0200
|
|
|
608b37 |
@@ -164,64 +164,7 @@ dealWithSubprocess(const char * const f
|
|
|
608b37 |
bool * const noSubprocessP,
|
|
|
608b37 |
const char ** const errorP) {
|
|
|
608b37 |
|
|
|
608b37 |
-#ifdef NO_OPEN_PIPES
|
|
|
608b37 |
*noSubprocessP = TRUE;
|
|
|
608b37 |
-#else
|
|
|
608b37 |
- const char *cp;
|
|
|
608b37 |
-
|
|
|
608b37 |
- reapChildren(catchingChildrenP, pids);
|
|
|
608b37 |
-
|
|
|
608b37 |
- /* Real file, not stdin or stdout. If name ends in ".Z",
|
|
|
608b37 |
- * pipe from/to un/compress (depending on r/w mode).
|
|
|
608b37 |
- *
|
|
|
608b37 |
- * If it starts with "|", popen that command.
|
|
|
608b37 |
- */
|
|
|
608b37 |
-
|
|
|
608b37 |
- cp = file_name + strlen(file_name) - 2;
|
|
|
608b37 |
- /* Pipe case. */
|
|
|
608b37 |
- if (file_name[0] == '|') {
|
|
|
608b37 |
- pid_t thepid; /* PID from my_popen */
|
|
|
608b37 |
-
|
|
|
608b37 |
- *noSubprocessP = FALSE;
|
|
|
608b37 |
-
|
|
|
608b37 |
- *fpP = my_popen(file_name + 1, mode, &thepid);
|
|
|
608b37 |
- if (*fpP == NULL)
|
|
|
608b37 |
- *errorP = "%s: can't invoke <<%s>> for %s: ";
|
|
|
608b37 |
- else {
|
|
|
608b37 |
- /* One more child to catch, eventually. */
|
|
|
608b37 |
- if (*catchingChildrenP < MAX_CHILDREN)
|
|
|
608b37 |
- pids[(*catchingChildrenP)++] = thepid;
|
|
|
608b37 |
- }
|
|
|
608b37 |
- } else if (cp > file_name && *cp == '.' && *(cp + 1) == 'Z' ) {
|
|
|
608b37 |
- /* Compress case. */
|
|
|
608b37 |
- pid_t thepid; /* PID from my_popen. */
|
|
|
608b37 |
- const char * command;
|
|
|
608b37 |
-
|
|
|
608b37 |
- *noSubprocessP = FALSE;
|
|
|
608b37 |
-
|
|
|
608b37 |
- if (*mode == 'w')
|
|
|
608b37 |
- pm_asprintf(&command, "compress > %s", file_name);
|
|
|
608b37 |
- else if (*mode == 'a')
|
|
|
608b37 |
- pm_asprintf(&command, "compress >> %s", file_name);
|
|
|
608b37 |
- else
|
|
|
608b37 |
- pm_asprintf(&command, "compress -d < %s", file_name);
|
|
|
608b37 |
-
|
|
|
608b37 |
- *fpP = my_popen(command, mode, &thepid);
|
|
|
608b37 |
-
|
|
|
608b37 |
- if (*fpP == NULL)
|
|
|
608b37 |
- *errorP = "%s: can't invoke 'compress' program, "
|
|
|
608b37 |
- "trying to open %s for %s";
|
|
|
608b37 |
- else {
|
|
|
608b37 |
- /* One more child to catch, eventually. */
|
|
|
608b37 |
- if (*catchingChildrenP < MAX_CHILDREN)
|
|
|
608b37 |
- pids[(*catchingChildrenP)++] = thepid;
|
|
|
608b37 |
- }
|
|
|
608b37 |
- pm_strfree(command);
|
|
|
608b37 |
- } else {
|
|
|
608b37 |
- *noSubprocessP = TRUE;
|
|
|
608b37 |
- *errorP = NULL;
|
|
|
608b37 |
- }
|
|
|
608b37 |
-#endif
|
|
|
608b37 |
}
|
|
|
608b37 |
|
|
|
608b37 |
|
|
|
608b37 |
diff -urNp old/urt/rle_putcom.c new/urt/rle_putcom.c
|
|
|
608b37 |
--- old/urt/rle_putcom.c 2017-09-05 15:09:00.976207523 +0200
|
|
|
608b37 |
+++ new/urt/rle_putcom.c 2017-09-06 12:31:29.550158232 +0200
|
|
|
608b37 |
@@ -14,6 +14,8 @@
|
|
|
608b37 |
* If you modify this software, you should include a notice giving the
|
|
|
608b37 |
* name of the person performing the modification, the date of modification,
|
|
|
608b37 |
* and the reason for such modification.
|
|
|
608b37 |
+ *
|
|
|
608b37 |
+ * 2002-12-19: Fix maths wrapping bugs. Alan Cox <alan@redhat.com>
|
|
|
608b37 |
*/
|
|
|
608b37 |
/*
|
|
|
608b37 |
* rle_putcom.c - Add a picture comment to the header struct.
|
|
|
608b37 |
@@ -98,12 +100,14 @@ rle_putcom(const char * const value,
|
|
|
608b37 |
const char * v;
|
|
|
608b37 |
const char ** old_comments;
|
|
|
608b37 |
int i;
|
|
|
608b37 |
- for (i = 2, cp = the_hdr->comments; *cp != NULL; ++i, ++cp)
|
|
|
608b37 |
+ for (i = 2, cp = the_hdr->comments; *cp != NULL; ++i, ++cp) {
|
|
|
608b37 |
+ overflow_add(i, 1);
|
|
|
608b37 |
if (match(value, *cp) != NULL) {
|
|
|
608b37 |
v = *cp;
|
|
|
608b37 |
*cp = value;
|
|
|
608b37 |
return v;
|
|
|
608b37 |
}
|
|
|
608b37 |
+ }
|
|
|
608b37 |
/* Not found */
|
|
|
608b37 |
/* Can't realloc because somebody else might be pointing to this
|
|
|
608b37 |
* comments block. Of course, if this were true, then the
|
|
|
608b37 |
diff -urNp old/urt/Runput.c new/urt/Runput.c
|
|
|
608b37 |
--- old/urt/Runput.c 2017-09-05 15:09:00.976207523 +0200
|
|
|
608b37 |
+++ new/urt/Runput.c 2017-09-06 12:33:47.933658290 +0200
|
|
|
608b37 |
@@ -17,6 +17,8 @@
|
|
|
608b37 |
*
|
|
|
608b37 |
* Modified at BRL 16-May-88 by Mike Muuss to avoid Alliant STDC desire
|
|
|
608b37 |
* to have all "void" functions so declared.
|
|
|
608b37 |
+ *
|
|
|
608b37 |
+ * 2002-12-19: Fix maths wrapping bugs. Alan Cox <alan@redhat.com>
|
|
|
608b37 |
*/
|
|
|
608b37 |
/*
|
|
|
608b37 |
* Runput.c - General purpose Run Length Encoding.
|
|
|
608b37 |
@@ -202,9 +204,11 @@ RunSetup(rle_hdr * the_hdr)
|
|
|
608b37 |
if ( the_hdr->background != 0 )
|
|
|
608b37 |
{
|
|
|
608b37 |
register int i;
|
|
|
608b37 |
- register rle_pixel *background =
|
|
|
608b37 |
- (rle_pixel *)malloc( (unsigned)(the_hdr->ncolors + 1) );
|
|
|
608b37 |
+ register rle_pixel *background;
|
|
|
608b37 |
register int *bg_color;
|
|
|
608b37 |
+
|
|
|
608b37 |
+ overflow_add(the_hdr->ncolors,1);
|
|
|
608b37 |
+ background = (rle_pixel *)malloc( (unsigned)(the_hdr->ncolors + 1) );
|
|
|
608b37 |
/*
|
|
|
608b37 |
* If even number of bg color bytes, put out one more to get to
|
|
|
608b37 |
* 16 bit boundary.
|
|
|
608b37 |
@@ -224,7 +228,7 @@ RunSetup(rle_hdr * the_hdr)
|
|
|
608b37 |
/* Big-endian machines are harder */
|
|
|
608b37 |
register int i, nmap = (1 << the_hdr->cmaplen) *
|
|
|
608b37 |
the_hdr->ncmap;
|
|
|
608b37 |
- register char *h_cmap = (char *)malloc( nmap * 2 );
|
|
|
608b37 |
+ register char *h_cmap = (char *)malloc2( nmap, 2 );
|
|
|
608b37 |
if ( h_cmap == NULL )
|
|
|
608b37 |
{
|
|
|
608b37 |
fprintf( stderr,
|
|
|
608b37 |
diff -urNp old/urt/scanargs.c new/urt/scanargs.c
|
|
|
608b37 |
--- old/urt/scanargs.c 2017-09-05 15:09:00.976207523 +0200
|
|
|
608b37 |
+++ new/urt/scanargs.c 2017-09-06 12:35:21.372289086 +0200
|
|
|
608b37 |
@@ -38,6 +38,8 @@
|
|
|
608b37 |
*
|
|
|
608b37 |
* Modified at BRL 16-May-88 by Mike Muuss to avoid Alliant STDC desire
|
|
|
608b37 |
* to have all "void" functions so declared.
|
|
|
608b37 |
+ *
|
|
|
608b37 |
+ * 2002-12-19: Fix maths wrapping bugs. Alan Cox <alan@redhat.com>
|
|
|
608b37 |
*/
|
|
|
608b37 |
|
|
|
608b37 |
#include <stdio.h>
|
|
|
608b37 |
@@ -62,8 +64,8 @@ typedef int *ptr;
|
|
|
608b37 |
/*
|
|
|
608b37 |
* Storage allocation macros
|
|
|
608b37 |
*/
|
|
|
608b37 |
-#define NEW( type, cnt ) (type *) malloc( (cnt) * sizeof( type ) )
|
|
|
608b37 |
-#define RENEW( type, ptr, cnt ) (type *) realloc( ptr, (cnt) * sizeof( type ) )
|
|
|
608b37 |
+#define NEW( type, cnt ) (type *) malloc2( (cnt), sizeof( type ) )
|
|
|
608b37 |
+#define RENEW( type, ptr, cnt ) (type *) realloc2( ptr, (cnt), sizeof( type ) )
|
|
|
608b37 |
|
|
|
608b37 |
static CONST_DECL char * prformat( CONST_DECL char *, int );
|
|
|
608b37 |
static int isnum( CONST_DECL char *, int, int );
|