diff options
32 files changed, 436 insertions, 415 deletions
diff --git a/GNUmakefile b/GNUmakefile index 06967e8d..a1484786 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -400,6 +400,7 @@ clean: localclean localclean: rm -f netpbm build_started build_complete rm -f pm_config.h inttypes_netpbm.h version.h + rm -f *.deb # Note that removing Makefile.config must be the last thing we do, # because no other makes will work after that is done. diff --git a/Makefile.version b/Makefile.version index fb025076..e43f481f 100644 --- a/Makefile.version +++ b/Makefile.version @@ -1,3 +1,3 @@ NETPBM_MAJOR_RELEASE = 10 NETPBM_MINOR_RELEASE = 35 -NETPBM_POINT_RELEASE = 95 +NETPBM_POINT_RELEASE = 96 diff --git a/converter/other/Makefile b/converter/other/Makefile index 8d4fcb76..a83eeb21 100644 --- a/converter/other/Makefile +++ b/converter/other/Makefile @@ -228,6 +228,9 @@ install.bin.local: $(PKGDIR)/bin # In May 2002, pamtouil replaced ppmtouil cd $(PKGDIR)/bin ; \ $(SYMLINK) pamtouil$(EXE) ppmtouil +# In July 2002, pamtotga replaced ppmtotga + cd $(PKGDIR)/bin ; \ + $(SYMLINK) pamtotga$(EXE) ppmtotga$(EXE) # In March 2005, we realized that pamtopnm obviates pnmtopnm cd $(PKGDIR)/bin ; \ $(SYMLINK) pamtopnm$(EXE) pnmtopnm diff --git a/converter/other/cameratopam/ljpeg.c b/converter/other/cameratopam/ljpeg.c index 18423f4f..4b092933 100644 --- a/converter/other/cameratopam/ljpeg.c +++ b/converter/other/cameratopam/ljpeg.c @@ -33,21 +33,26 @@ ljpeg_start (FILE * ifp, struct jhead *jh) do { fread (data, 2, 2, ifp); tag = data[0] << 8 | data[1]; - len = (data[2] << 8 | data[3]) - 2; - if (tag <= 0xff00 || len > 255) return 0; - fread (data, 1, len, ifp); - switch (tag) { + len = (data[2] << 8 | data[3]); + if (len < 2) + pm_error("Length field is %u; must be at least 2", len); + else { + unsigned int const dataLen = len - 2; + if (tag <= 0xff00 || dataLen > 255) return 0; + fread (data, 1, dataLen, ifp); + switch (tag) { case 0xffc3: - jh->bits = data[0]; - jh->high = data[1] << 8 | data[2]; - jh->wide = data[3] << 8 | data[4]; - jh->clrs = data[5]; - break; + jh->bits = data[0]; + jh->high = data[1] << 8 | data[2]; + jh->wide = data[3] << 8 | data[4]; + jh->clrs = data[5]; + break; case 0xffc4: - for (dp = data; dp < data+len && *dp < 4; ) { - jh->huff[*dp] = free_decode; - dp = make_decoder (++dp, 0); - } + for (dp = data; dp < data+dataLen && *dp < 4; ) { + jh->huff[*dp] = free_decode; + dp = make_decoder (++dp, 0); + } + } } } while (tag != 0xffda); jh->row = calloc (jh->wide*jh->clrs, 2); diff --git a/converter/other/jpeg2000/libjasper/include/jasper/jas_types.h.orig b/converter/other/jpeg2000/libjasper/include/jasper/jas_types.h.orig deleted file mode 100644 index 10c1152d..00000000 --- a/converter/other/jpeg2000/libjasper/include/jasper/jas_types.h.orig +++ /dev/null @@ -1,228 +0,0 @@ -/* - * Copyright (c) 1999-2000 Image Power, Inc. and the University of - * British Columbia. - * Copyright (c) 2001-2002 Michael David Adams. - * All rights reserved. - */ - -/* __START_OF_JASPER_LICENSE__ - * - * JasPer Software License - * - * IMAGE POWER JPEG-2000 PUBLIC LICENSE - * ************************************ - * - * GRANT: - * - * Permission is hereby granted, free of charge, to any person (the "User") - * obtaining a copy of this software and associated documentation, to deal - * in the JasPer Software without restriction, including without limitation - * the right to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the JasPer Software (in source and binary forms), - * and to permit persons to whom the JasPer Software is furnished to do so, - * provided further that the License Conditions below are met. - * - * License Conditions - * ****************** - * - * A. Redistributions of source code must retain the above copyright notice, - * and this list of conditions, and the following disclaimer. - * - * B. Redistributions in binary form must reproduce the above copyright - * notice, and this list of conditions, and the following disclaimer in - * the documentation and/or other materials provided with the distribution. - * - * C. Neither the name of Image Power, Inc. nor any other contributor - * (including, but not limited to, the University of British Columbia and - * Michael David Adams) may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * D. User agrees that it shall not commence any action against Image Power, - * Inc., the University of British Columbia, Michael David Adams, or any - * other contributors (collectively "Licensors") for infringement of any - * intellectual property rights ("IPR") held by the User in respect of any - * technology that User owns or has a right to license or sublicense and - * which is an element required in order to claim compliance with ISO/IEC - * 15444-1 (i.e., JPEG-2000 Part 1). "IPR" means all intellectual property - * rights worldwide arising under statutory or common law, and whether - * or not perfected, including, without limitation, all (i) patents and - * patent applications owned or licensable by User; (ii) rights associated - * with works of authorship including copyrights, copyright applications, - * copyright registrations, mask work rights, mask work applications, - * mask work registrations; (iii) rights relating to the protection of - * trade secrets and confidential information; (iv) any right analogous - * to those set forth in subsections (i), (ii), or (iii) and any other - * proprietary rights relating to intangible property (other than trademark, - * trade dress, or service mark rights); and (v) divisions, continuations, - * renewals, reissues and extensions of the foregoing (as and to the extent - * applicable) now existing, hereafter filed, issued or acquired. - * - * E. If User commences an infringement action against any Licensor(s) then - * such Licensor(s) shall have the right to terminate User's license and - * all sublicenses that have been granted hereunder by User to other parties. - * - * F. This software is for use only in hardware or software products that - * are compliant with ISO/IEC 15444-1 (i.e., JPEG-2000 Part 1). No license - * or right to this Software is granted for products that do not comply - * with ISO/IEC 15444-1. The JPEG-2000 Part 1 standard can be purchased - * from the ISO. - * - * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. - * NO USE OF THE JASPER SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER - * THIS DISCLAIMER. THE JASPER SOFTWARE IS PROVIDED BY THE LICENSORS AND - * CONTRIBUTORS UNDER THIS LICENSE ON AN ``AS-IS'' BASIS, WITHOUT WARRANTY - * OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, - * WARRANTIES THAT THE JASPER SOFTWARE IS FREE OF DEFECTS, IS MERCHANTABLE, - * IS FIT FOR A PARTICULAR PURPOSE OR IS NON-INFRINGING. THOSE INTENDING - * TO USE THE JASPER SOFTWARE OR MODIFICATIONS THEREOF FOR USE IN HARDWARE - * OR SOFTWARE PRODUCTS ARE ADVISED THAT THEIR USE MAY INFRINGE EXISTING - * PATENTS, COPYRIGHTS, TRADEMARKS, OR OTHER INTELLECTUAL PROPERTY RIGHTS. - * THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE JASPER SOFTWARE - * IS WITH THE USER. SHOULD ANY PART OF THE JASPER SOFTWARE PROVE DEFECTIVE - * IN ANY RESPECT, THE USER (AND NOT THE INITIAL DEVELOPERS, THE UNIVERSITY - * OF BRITISH COLUMBIA, IMAGE POWER, INC., MICHAEL DAVID ADAMS, OR ANY - * OTHER CONTRIBUTOR) SHALL ASSUME THE COST OF ANY NECESSARY SERVICING, - * REPAIR OR CORRECTION. UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, - * WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL THE - * INITIAL DEVELOPER, THE UNIVERSITY OF BRITISH COLUMBIA, IMAGE POWER, INC., - * MICHAEL DAVID ADAMS, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF THE - * JASPER SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO - * THE USER OR ANY OTHER PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR - * CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, - * DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR - * MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF - * SUCH PARTY HAD BEEN INFORMED, OR OUGHT TO HAVE KNOWN, OF THE POSSIBILITY - * OF SUCH DAMAGES. THE JASPER SOFTWARE AND UNDERLYING TECHNOLOGY ARE NOT - * FAULT-TOLERANT AND ARE NOT DESIGNED, MANUFACTURED OR INTENDED FOR USE OR - * RESALE AS ON-LINE CONTROL EQUIPMENT IN HAZARDOUS ENVIRONMENTS REQUIRING - * FAIL-SAFE PERFORMANCE, SUCH AS IN THE OPERATION OF NUCLEAR FACILITIES, - * AIRCRAFT NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL, DIRECT - * LIFE SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH THE FAILURE OF THE - * JASPER SOFTWARE OR UNDERLYING TECHNOLOGY OR PRODUCT COULD LEAD DIRECTLY - * TO DEATH, PERSONAL INJURY, OR SEVERE PHYSICAL OR ENVIRONMENTAL DAMAGE - * ("HIGH RISK ACTIVITIES"). LICENSOR SPECIFICALLY DISCLAIMS ANY EXPRESS - * OR IMPLIED WARRANTY OF FITNESS FOR HIGH RISK ACTIVITIES. USER WILL NOT - * KNOWINGLY USE, DISTRIBUTE OR RESELL THE JASPER SOFTWARE OR UNDERLYING - * TECHNOLOGY OR PRODUCTS FOR HIGH RISK ACTIVITIES AND WILL ENSURE THAT ITS - * CUSTOMERS AND END-USERS OF ITS PRODUCTS ARE PROVIDED WITH A COPY OF THE - * NOTICE SPECIFIED IN THIS SECTION. - * - * __END_OF_JASPER_LICENSE__ - */ - -/* - * Primitive Types - * - * $Id$ - */ - -#ifndef JAS_TYPES_H -#define JAS_TYPES_H - -#if defined(HAVE_STDLIB_H) -#include <stdlib.h> -#endif -#if defined(HAVE_STDDEF_H) -#include <stddef.h> -#endif -#if defined(HAVE_SYS_TYPES_H) -#include <sys/types.h> -#endif - -#if defined(HAVE_STDBOOL_H) -/* - * The C language implementation does correctly provide the standard header - * file "stdbool.h". - */ -#include <stdbool.h> -#else - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * The C language implementation does not provide the standard header file - * "stdbool.h" as required by ISO/IEC 9899:1999. Try to compensate for this - * braindamage below. - */ -#if !defined(bool) -#define bool int -#endif -#if !defined(true) -#define true 1 -#endif -#if !defined(false) -#define false 0 -#endif - -#ifdef __cplusplus -} -#endif - -/* pm_config.h defines the FAST integer types if possible (typically by - including <inttypes.h>. If not, the following try to take care - of it. -*/ -/**********/ -#if !defined(INT_FAST8_MAX) -typedef signed char int_fast8_t; -#define INT_FAST8_MIN (-127) -#define INT_FAST8_MAX 128 -#endif -/**********/ -#if !defined(UINT_FAST8_MAX) -typedef unsigned char uint_fast8_t; -#define UINT_FAST8_MAX 255 -#endif -/**********/ -#if !defined(INT_FAST16_MAX) -typedef short int_fast16_t; -#define INT_FAST16_MIN SHRT_MIN -#define INT_FAST16_MAX SHRT_MAX -#endif -/**********/ -#if !defined(UINT_FAST16_MAX) -typedef unsigned short uint_fast16_t; -#define UINT_FAST16_MAX USHRT_MAX -#endif -/**********/ -#if !defined(INT_FAST32_MAX) -typedef int int_fast32_t; -#define INT_FAST32_MIN INT_MIN -#define INT_FAST32_MAX INT_MAX -#endif -/**********/ -#if !defined(UINT_FAST32_MAX) -typedef unsigned int uint_fast32_t; -#define UINT_FAST32_MAX UINT_MAX -#endif -/**********/ -#if !defined(INT_FAST64_MAX) -typedef int int_fast64_t; -#define INT_FAST64_MIN LLONG_MIN -#define INT_FAST64_MAX LLONG_MAX -#endif -/**********/ -#if !defined(UINT_FAST64_MAX) -typedef unsigned int uint_fast64_t; -#define UINT_FAST64_MAX ULLONG_MAX -#endif -/**********/ -#endif - -/* The below macro is intended to be used for type casts. By using this - macro, type casts can be easily located in the source code with - tools like "grep". */ -#define JAS_CAST(t, e) \ - ((t) (e)) - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/converter/other/pamtosvg/pxl-outline.c b/converter/other/pamtosvg/pxl-outline.c index ecfeb229..20b088c7 100644 --- a/converter/other/pamtosvg/pxl-outline.c +++ b/converter/other/pamtosvg/pxl-outline.c @@ -268,7 +268,7 @@ find_one_centerline(bitmap_type const bitmap, */ { pm_pixelcoord pos; - pos.col = col; pos.row = bitmap.height - row - 1; + pos.col = originalCol; pos.row = bitmap.height - originalRow - 1; LOG2(" (%d,%d)", pos.col, pos.row); append_outline_pixel(&outline, pos); } diff --git a/converter/other/pnmtopalm/palmtopnm.c b/converter/other/pnmtopalm/palmtopnm.c index 82d1f6fb..ee43be7a 100644 --- a/converter/other/pnmtopalm/palmtopnm.c +++ b/converter/other/pnmtopalm/palmtopnm.c @@ -819,15 +819,16 @@ readPackBitsRow16(FILE * const ifP, unsigned int k; unsigned short inval; pm_readlittleshortu(ifP, &inval); - for (k = 0; (k < runlength) && (j + k + 1 < bytesPerRow); k += 2) { - memcpy(palmrow + j + k, &inval, 2); + if (j + runlength <= bytesPerRow) { + for (k = 0; k < runlength; k += 2) + memcpy(palmrow + j + k, &inval, 2); } j += runlength; } else { /* We just read the stream of shorts as a stream of chars */ unsigned int const nonrunlength = (incount + 1) * 2; unsigned int k; - for (k = 0; (k < nonrunlength) && (j + k < bytesPerRow); ++k) { + for (k = 0; (k < nonrunlength) && (j + k <= bytesPerRow); ++k) { unsigned char inval; pm_readcharu(ifP, &inval); palmrow[j + k] = inval; @@ -859,13 +860,13 @@ readPackBitsRow(FILE * const ifP, unsigned int const runlength = -incount + 1; unsigned char inval; pm_readcharu(ifP, &inval); - if (j + runlength < bytesPerRow) + if (j + runlength <= bytesPerRow) memset(palmrow + j, inval, runlength); j += runlength; } else { unsigned int const nonrunlength = incount + 1; unsigned int k; - for (k = 0; k < nonrunlength && j + k < bytesPerRow; ++k) { + for (k = 0; k < nonrunlength && j + k <= bytesPerRow; ++k) { unsigned char inval; pm_readcharu(ifP, &inval); palmrow[j + k] = inval; diff --git a/converter/other/pnmtopalm/pnmtopalm.c b/converter/other/pnmtopalm/pnmtopalm.c index f5f6e44a..d5f79619 100644 --- a/converter/other/pnmtopalm/pnmtopalm.c +++ b/converter/other/pnmtopalm/pnmtopalm.c @@ -688,15 +688,32 @@ destroyBuffer(struct seqBuffer * const bufferP) { static void addByteToBuffer(struct seqBuffer * const bufferP, unsigned char const newByte) { +/*----------------------------------------------------------------------------- + Append one byte to buffer, expanding with realloc() whenever necessary. + + Buffer is initially 4096 bytes. It is doubled with each expansion. + A combination of large image size (maximum 65535 x 65535), high + resolution (each pixel can occupy more than one byte) and poor + compression can lead to an arithmetic overflow. + Abort with error if an arithmetic overflow is detected during doubling. +-----------------------------------------------------------------------------*/ assert(bufferP->allocatedSize >= bufferP->occupiedSize); if (bufferP->allocatedSize == bufferP->occupiedSize) { - bufferP->allocatedSize *= 2; - REALLOCARRAY(bufferP->buffer, bufferP->allocatedSize); + unsigned int const newSize = bufferP->allocatedSize * 2; + + if (newSize <= bufferP->allocatedSize) + pm_error("Image too large. Arithmetic overflow trying to " + "expand buffer beyond %u bytes.", + bufferP->allocatedSize); + + REALLOCARRAY(bufferP->buffer, newSize); if (bufferP->buffer == NULL) pm_error("Couldn't (re)allocate %u bytes of memory " - "for buffer.", bufferP->allocatedSize); + "for buffer.", newSize); + + bufferP->allocatedSize = newSize; } bufferP->buffer[bufferP->occupiedSize++] = newByte; } diff --git a/converter/other/pnmtorle.c b/converter/other/pnmtorle.c index 8c6dc589..b7834e89 100644 --- a/converter/other/pnmtorle.c +++ b/converter/other/pnmtorle.c @@ -208,7 +208,6 @@ main(argc, argv) char **argv; { char *pnmname = NULL, *outname = NULL; - static char filename[BUFSIZ]; int oflag, c; pnm_init(&argc, argv); @@ -235,12 +234,10 @@ main(argc, argv) * Open the file. */ if (pnmname == NULL) { - strcpy(filename, "stdin"); fp = stdin; } else { - strcpy(filename, pnmname); - fp = pm_openr(filename); + fp = pm_openr(pnmname); } hdr.rle_file = rle_open_f( hdr.cmd, outname, "wb" ); diff --git a/converter/pbm/escp2topbm.c b/converter/pbm/escp2topbm.c index 049ed23c..28296da9 100644 --- a/converter/pbm/escp2topbm.c +++ b/converter/pbm/escp2topbm.c @@ -48,6 +48,8 @@ dec_epson_rle(unsigned const int k, } dpos += i; } + if(dpos > k) + pm_error("Corrupt compressed block"); return pos; /* return number of treated input bytes */ } @@ -96,6 +98,7 @@ main(int argc, /* filter out raster data */ height = 0; /* initial value */ + width = 0; /* initial value */ pos = 0; /* initial value */ opos = 0; /* initial value */ @@ -104,9 +107,16 @@ main(int argc, if (input[pos] == '\x1b' && input[pos+1] == '.') { unsigned int const k = input[pos+5] * ((input[pos+7] * 256 + input[pos+6] + 7) / 8); + unsigned int const margin = 256; + if(input[pos+5] == 0) + pm_error("Abnormal height value in escape sequence"); height += input[pos+5]; - width = input[pos+7] * 256 + input[pos+6]; - REALLOCARRAY(output, opos + k); + if(width == 0) /* initialize */ + width = input[pos+7] * 256 + input[pos+6]; + else if(width != input[pos+7] * 256 + input[pos+6]) + pm_error("Abnormal width value in escape sequence"); + + REALLOCARRAY(output, opos + k + margin); if (output == NULL) pm_error("Cannot allocate memory"); diff --git a/converter/pbm/pbmtoatk.c b/converter/pbm/pbmtoatk.c index de7adf63..9399f602 100644 --- a/converter/pbm/pbmtoatk.c +++ b/converter/pbm/pbmtoatk.c @@ -125,7 +125,6 @@ main(int argc, char *argv[]) { register bit *bP; int rows, cols, format, row; int col; - char name[100], *cp; unsigned char curbyte, newbyte; int curcount, gather; @@ -136,15 +135,8 @@ main(int argc, char *argv[]) { else if (argc-1 == 1) { ifd = pm_openr( argv[1] ); - strcpy(name, argv[1]); - if (STREQ( name, "-")) - strcpy(name, "noname"); - - if ((cp = strchr(name, '.')) != 0) - *cp = '\0'; } else { ifd = stdin; - strcpy( name, "noname" ); } pbm_readpbminit(ifd, &cols, &rows, &format); diff --git a/converter/pbm/pbmtoepson.c b/converter/pbm/pbmtoepson.c index d26734d4..1d1b1608 100644 --- a/converter/pbm/pbmtoepson.c +++ b/converter/pbm/pbmtoepson.c @@ -68,7 +68,7 @@ parseCommandLine(int argc, MALLOCARRAY_NOFAIL(option_def, 100); option_def_index = 0; /* incremented by OPTENT3 */ - OPTENT3(0, "protocol", OPT_UINT, &protocol, + OPTENT3(0, "protocol", OPT_STRING, &protocol, &protocolSpec, 0); OPTENT3(0, "dpi", OPT_UINT, &cmdlineP->dpi, &dpiSpec, 0); diff --git a/converter/pbm/pbmtoescp2.c b/converter/pbm/pbmtoescp2.c index 787f7027..9992fec9 100644 --- a/converter/pbm/pbmtoescp2.c +++ b/converter/pbm/pbmtoescp2.c @@ -164,6 +164,11 @@ main(int argc, char* argv[]) { for (idx = 0; idx < 24 && row+idx < rows; ++idx) pbm_readpbmrow_packed(ifP,bytes+idx*pbm_packed_bytes(cols), cols,format); + /* Add delimiter to end of rows, using inverse of final + data byte to prevent match. */ + *(bytes+idx*pbm_packed_bytes(cols)) = + ~ *(bytes+idx*pbm_packed_bytes(cols)-1); + /* Write raster data. */ if (cmdline.compress != 0) { /* compressed */ diff --git a/converter/pbm/pbmtog3.c b/converter/pbm/pbmtog3.c index 0b536390..77ea545a 100644 --- a/converter/pbm/pbmtog3.c +++ b/converter/pbm/pbmtog3.c @@ -436,7 +436,7 @@ main(int argc, MALLOCARRAY_NOFAIL(bitrow, pbm_packed_bytes(cols) + sizeof(wordint)); - MALLOCARRAY_NOFAIL(milepost, readcols + 1); + MALLOCARRAY_NOFAIL(milepost, readcols + 2); initOutStream(cmdline.reversebits); puteol(); diff --git a/converter/pbm/pbmtogo.c b/converter/pbm/pbmtogo.c index 36b145c4..18f3ab6c 100644 --- a/converter/pbm/pbmtogo.c +++ b/converter/pbm/pbmtogo.c @@ -102,7 +102,7 @@ main( argc, argv ) padright = rucols - cols; for (i = 0; i < BUFSIZE; ++i ) - buffer[i] = 0; + buffer[i] = oldscanline[i] = 0; putinit(); /* Start donwloading screen raster */ @@ -151,7 +151,7 @@ main( argc, argv ) { olditem = buffer[nbyte++]; ucount++; - } while ((olditem != buffer[nbyte]) + } while (nbyte < bytesperrow && (olditem != buffer[nbyte]) && (ucount < MIN(bytesperrow, MAX_REPEAT))); if ((ucount != MAX_REPEAT) && (nbyte != bytesperrow)) { @@ -182,7 +182,7 @@ main( argc, argv ) { olditem = buffer[nbyte++]; ecount++; - } while ((olditem == buffer[nbyte]) + } while (nbyte < bytesperrow && (olditem == buffer[nbyte]) && (ecount < MIN(bytesperrow, MAX_REPEAT))); if (ecount > 1) { diff --git a/converter/pbm/pbmtomacp.c b/converter/pbm/pbmtomacp.c index ad0b22b1..9dc700e6 100644 --- a/converter/pbm/pbmtomacp.c +++ b/converter/pbm/pbmtomacp.c @@ -20,6 +20,8 @@ #define EQUAL 1 #define UNEQUAL 0 +#define MIN3(a,b,c) (MIN((MIN((a),(b))),(c))) + static void fillbits ARGS(( bit **bits, bit **bitsr, int top, int left, int bottom, int right )); static void writemacp ARGS(( bit **bits )); static int packit ARGS(( bit *pb, bit *bits )); @@ -102,23 +104,18 @@ char *argv[]; left = 0; if( rflg ) - { if( right - left >= MAX_COLS ) - right = left + MAX_COLS - 1; - } + right = MIN3( right, cols - 1, left + MAX_COLS - 1 ); else - right = ( left + MAX_COLS > cols ) ? ( cols - 1 ) : ( left + MAX_COLS - 1 ); + right = MIN( cols - 1, left + MAX_COLS - 1 ); if( !tflg ) top = 0; if( bflg ) - { if( bottom - top >= MAX_LINES ) - bottom = top + MAX_LINES - 1; - } + bottom = MIN3( bottom, rows - 1, top + MAX_LINES - 1); else - bottom = ( top + MAX_LINES > rows ) ? - ( rows - 1 ) : ( top + MAX_LINES - 1 ); - + bottom = MIN( rows - 1, top + MAX_LINES - 1 ); + if( right <= left || left < 0 || right - left + 1 > MAX_COLS ) pm_error("error in right (= %d) and/or left (=%d)",right,left ); if( bottom <= top || top < 0 || bottom - top + 1 > MAX_LINES ) @@ -220,7 +217,7 @@ packit( pb, bits ) save = *srcb++; charcount--; newcount = 1; - while( (*srcb == save) && charcount ) { + while( charcount && (*srcb == save) ) { srcb++; newcount++; charcount--; diff --git a/converter/pbm/pbmtomatrixorbital.c b/converter/pbm/pbmtomatrixorbital.c index 79347978..96e1406a 100644 --- a/converter/pbm/pbmtomatrixorbital.c +++ b/converter/pbm/pbmtomatrixorbital.c @@ -60,7 +60,7 @@ main(int argc, char * argv[]) { pbm_init(&argc, argv); - if (argc-1 > 0) + if (argc-1 > 1) pm_error("Too many arguments (%d). The only valid argument is an " "input file name.", argc-1); else if (argc-1 == 1) diff --git a/converter/pbm/pbmtomgr.c b/converter/pbm/pbmtomgr.c index 7a6e7fc1..acf689e1 100644 --- a/converter/pbm/pbmtomgr.c +++ b/converter/pbm/pbmtomgr.c @@ -40,6 +40,10 @@ main( argc, argv ) ifp = stdin; pbm_readpbminit( ifp, &cols, &rows, &format ); + if (cols > 4095) + pm_error("Image width too large: %u (max: 4095)", cols); + if (rows > 4095) + pm_error("Image heigth too large: %u (max: 4095)", cols); bitrow = pbm_allocrow( cols ); /* Round cols up to the nearest multiple of 8. */ diff --git a/converter/pbm/pbmtopi3.c b/converter/pbm/pbmtopi3.c index 06023d7a..8d178f61 100644 --- a/converter/pbm/pbmtopi3.c +++ b/converter/pbm/pbmtopi3.c @@ -14,6 +14,7 @@ #include <stdio.h> #include "pbm.h" +#include "pm_c_util.h" static void putinit ARGS(( void )); static void putbit ARGS(( bit b )); @@ -28,8 +29,9 @@ main( argc, argv ) FILE* ifp; bit* bitrow; register bit* bP; - int rows, cols, format, padright, row, col; - + int inrows, incols, format, padright, row, col; + int const outcols = 640; + int const outrows = 400; pbm_init( &argc, argv ); @@ -41,27 +43,26 @@ main( argc, argv ) else ifp = stdin; - pbm_readpbminit( ifp, &cols, &rows, &format ); - if (cols > 640) - cols = 640; - if (rows > 400) - rows = 400; - bitrow = pbm_allocrow( cols ); - + pbm_readpbminit( ifp, &incols, &inrows, &format ); + bitrow = pbm_allocrow( MAX(incols, outcols) ); + /* Compute padding to round cols up to 640 */ - padright = 640 - cols; + if(incols < outcols) + padright = outcols - incols; + else + padright = 0; putinit( ); - for ( row = 0; row < rows; ++row ) + for ( row = 0; row < MIN(inrows, outrows); ++row ) { - pbm_readpbmrow( ifp, bitrow, cols, format ); - for ( col = 0, bP = bitrow; col < cols; ++col, ++bP ) + pbm_readpbmrow( ifp, bitrow, incols, format ); + for ( col = 0, bP = bitrow; col < MIN(incols, outcols); ++col, ++bP ) putbit( *bP ); for ( col = 0; col < padright; ++col ) putbit( 0 ); } - while (row++ < 400) - for ( col = 0; col < 640; ++col) + while (row++ < outrows) + for ( col = 0; col < outcols; ++col) putbit( 0 ); pm_close( ifp ); diff --git a/converter/pbm/pbmtopk.c b/converter/pbm/pbmtopk.c index b84818b1..08aff49a 100644 --- a/converter/pbm/pbmtopk.c +++ b/converter/pbm/pbmtopk.c @@ -854,11 +854,17 @@ main(int argc, char *argv[]) { initialize_pk() ; if (--argc < 1) pm_usage(usage) ; - strcpy(pkname, *++argv) ; + ++argv; + if(strlen(*argv) + 4 > NAMELENGTH) + pm_error("pkname is too long"); + strcpy(pkname, *argv) ; pbmtopk_add_suffix(pkname, ".pk") ; - if (--argc < 1) pm_usage(usage) ; - strcpy(tfmname, *++argv) ; + if (--argc < 1) pm_usage(usage); + ++argv; + if(strlen(*argv) + 4 > NAMELENGTH) + pm_error("tfmname is too long"); + strcpy(tfmname, *argv) ; pbmtopk_add_suffix(tfmname, ".tfm") ; if (--argc < 1) pm_usage(usage) ; diff --git a/converter/pbm/pbmtoppa/cutswath.c b/converter/pbm/pbmtoppa/cutswath.c index 0d44ce45..d3f15c03 100644 --- a/converter/pbm/pbmtoppa/cutswath.c +++ b/converter/pbm/pbmtoppa/cutswath.c @@ -39,13 +39,15 @@ cut_pbm_swath(pbm_stat* pbm,ppa_stat* prn,int maxlines,ppa_sweep_data* sweep_dat int shift; ppa_nozzle_data nozzles[2]; + ppa = NULL; + /* shift = 6 if DPI==300 */ /* shift = 12 if DPI==600 */ shift = ( prn->DPI == 300 ? 6:12 ) ; /* safeguard against the user freeing these */ - sweep_data->image_data=NULL; - sweep_data->nozzle_data=NULL; + sweep_data->image_data = NULL; + sweep_data->nozzle_data = NULL; /* read the data from the input file */ width8 = (pbm->width + 7) / 8; @@ -66,7 +68,7 @@ cut_pbm_swath(pbm_stat* pbm,ppa_stat* prn,int maxlines,ppa_sweep_data* sweep_dat if(!pbm_readline(pbm,data)) { fprintf(stderr,"cutswath(): A-could not read top margin\n"); - free(data); + free (data); data=NULL; return 0; } @@ -77,10 +79,10 @@ cut_pbm_swath(pbm_stat* pbm,ppa_stat* prn,int maxlines,ppa_sweep_data* sweep_dat if(!pbm_readline(pbm,data)) { fprintf(stderr,"cutswath(): could not clear bottom margin\n"); - free(data); + free (data); data=NULL; return 0; } - free(data); + free (data); data=NULL; return 1; } @@ -95,7 +97,7 @@ cut_pbm_swath(pbm_stat* pbm,ppa_stat* prn,int maxlines,ppa_sweep_data* sweep_dat if(!pbm_readline(pbm,data+width8*numlines)) { fprintf(stderr,"cutswath(): B-could not read next line\n"); - free(data); + free (data); data=NULL; return 0; } if(!got_nonblank) @@ -130,7 +132,7 @@ cut_pbm_swath(pbm_stat* pbm,ppa_stat* prn,int maxlines,ppa_sweep_data* sweep_dat { fprintf (stderr, "Ack! newleft=%d, newright=%d, left=%d, right=%d\n", newleft, newright, left, right); - free (data); + free (data); data=NULL; return 0; } @@ -177,13 +179,13 @@ cut_pbm_swath(pbm_stat* pbm,ppa_stat* prn,int maxlines,ppa_sweep_data* sweep_dat if(!pbm_readline(pbm,data)) { fprintf(stderr,"cutswath(): could not clear bottom margin\n"); - free(data); + free (data); data=NULL; return 0; } - free(data); + free (data); data=NULL; return 1; } - free(data); + free (data); data=NULL; return 0; /* error, since didn't get to lower margin, yet blank */ } @@ -197,7 +199,7 @@ cut_pbm_swath(pbm_stat* pbm,ppa_stat* prn,int maxlines,ppa_sweep_data* sweep_dat if(!pbm_readline(pbm,data+width8*numlines)) { fprintf(stderr,"cutswath(): C-could not read next line\n"); - free(data); + free (data); data=NULL; return 0; } numlines++; @@ -225,7 +227,7 @@ cut_pbm_swath(pbm_stat* pbm,ppa_stat* prn,int maxlines,ppa_sweep_data* sweep_dat if ((ppa = malloc ((p_width8+2*shift) * numlines)) == NULL) { fprintf(stderr,"cutswath(): could not malloc ppa storage\n"); - free (data); + free (data); data=NULL; return 0; } @@ -292,7 +294,7 @@ cut_pbm_swath(pbm_stat* pbm,ppa_stat* prn,int maxlines,ppa_sweep_data* sweep_dat } /* done with data */ - free(data); + free (data); data=NULL; /* place 0's in the last 12 columns */ memset (place, 0, numlines/2 * shift); diff --git a/converter/pbm/pbmtoppa/pbm.c b/converter/pbm/pbmtoppa/pbm.c index 5c9798f2..2f8a42b1 100644 --- a/converter/pbm/pbmtoppa/pbm.c +++ b/converter/pbm/pbmtoppa/pbm.c @@ -91,6 +91,7 @@ int pbm_readline(pbm_stat* pbm,unsigned char* data) pbm->current_line++; pbm->unread = 0; free (pbm->revdata); + pbm->revdata = NULL; return 1; } diff --git a/converter/pbm/pbmtoppa/pbmtoppa.c b/converter/pbm/pbmtoppa/pbmtoppa.c index 85a98529..f43c08a8 100644 --- a/converter/pbm/pbmtoppa/pbmtoppa.c +++ b/converter/pbm/pbmtoppa/pbmtoppa.c @@ -63,9 +63,14 @@ print_pbm(FILE * const in) { ppa_init_page(&printer); ppa_load_page(&printer); - sweeps[0].direction = right_to_left; + sweeps[0].direction = right_to_left; + sweeps[0].image_data = NULL; + sweeps[0].nozzle_data = NULL; sweeps[0].next=&sweeps[1]; - sweeps[1].direction = left_to_right; + + sweeps[1].direction = left_to_right; + sweeps[1].image_data = NULL; + sweeps[1].nozzle_data = NULL; sweeps[1].next=&sweeps[0]; current_sweep=0; @@ -88,6 +93,8 @@ print_pbm(FILE * const in) { ppa_print_sweep(&printer, &sweeps[previous_sweep]); free(sweeps[previous_sweep].image_data); free(sweeps[previous_sweep].nozzle_data); + sweeps[previous_sweep].image_data = NULL; + sweeps[previous_sweep].nozzle_data = NULL; } previous_sweep=current_sweep; current_sweep= current_sweep==0 ? 1 : 0; @@ -106,6 +113,10 @@ print_pbm(FILE * const in) { free(sweeps[0].nozzle_data); free(sweeps[1].image_data); free(sweeps[1].nozzle_data); + sweeps[0].image_data = NULL; + sweeps[0].nozzle_data = NULL; + sweeps[1].image_data = NULL; + sweeps[1].nozzle_data = NULL; ppa_eject_page(&printer); diff --git a/converter/pbm/pbmtoppa/ppa.c b/converter/pbm/pbmtoppa/ppa.c index 8363d927..aa30d684 100644 --- a/converter/pbm/pbmtoppa/ppa.c +++ b/converter/pbm/pbmtoppa/ppa.c @@ -389,7 +389,9 @@ static void __inline__ place_2bytes(int x,unsigned char* y) static void __inline__ place_4bytes(int x,unsigned char* y) { place_2bytes(x>>16,y); place_2bytes(x,y+2); } -#define do_compress_data (1) +#define do_compress_data (1) /* Compress. */ +/* The no-compression case has not been well tested 2015.05.31 */ + void ppa_print_sweep(ppa_stat* prn,ppa_sweep_data* data) { unsigned char* pc, *tpc; @@ -403,11 +405,9 @@ void ppa_print_sweep(ppa_stat* prn,ppa_sweep_data* data) int nozzle_data_size; int MF; /* Multiplicative Factor -- quick hack */ - pc=data->image_data; - if(do_compress_data) { - if(!(pc=malloc((datasize/64+1)*65))) + if( !( pc = malloc( datasize * 2 + 1 )) ) /* Worst case + margin */ { fprintf(stderr,"ppa_print_sweep(): could not malloc storage for compressed data\n"); exit(-1); @@ -416,12 +416,13 @@ void ppa_print_sweep(ppa_stat* prn,ppa_sweep_data* data) } /* send image data 16k at a time */ - for(i=0, tpc=pc; i<datasize; tpc+=16384, i+=16384) + for(i=0, tpc= do_compress_data ? pc : data->image_data; + i<datasize; tpc+=16384, i+=16384) vlink_put(prn->fptr, 0, datasize-i > 16384 ? 16384 : datasize-i, tpc); /* memory leak fix courtesy of John McKown */ if (do_compress_data) - free (pc); + free (pc); /* construct sweep packet */ switch(prn->version) diff --git a/converter/pbm/pktopbm.c b/converter/pbm/pktopbm.c index 32ed4fde..af49e9c7 100644 --- a/converter/pbm/pktopbm.c +++ b/converter/pbm/pktopbm.c @@ -214,7 +214,10 @@ main(int argc, char *argv[]) { if (--argc < 1) pm_usage(usage) ; - strcpy(pkname, *++argv) ; + ++argv; + if(strlen(*argv) + 4 > NAMELENGTH) + pm_error("pkname is too long"); + strcpy(pkname, *argv) ; pktopbm_add_suffix(pkname, ".pk") ; car = 0 ; diff --git a/converter/pgm/sbigtopgm.c b/converter/pgm/sbigtopgm.c index bb3cb6fe..e57e26e8 100644 --- a/converter/pgm/sbigtopgm.c +++ b/converter/pgm/sbigtopgm.c @@ -61,7 +61,7 @@ int main(argc, argv) register int col; int maxval; int comp, rows, cols; - char header[SBIG_HEADER_LENGTH]; + char header[SBIG_HEADER_LENGTH+1]; char *hdr; static char camera[80] = "ST-?"; @@ -82,6 +82,7 @@ int main(argc, argv) if (fread(header, SBIG_HEADER_LENGTH, 1, ifp) < 1) { pm_error("error reading SBIG file header"); } + header[SBIG_HEADER_LENGTH] = '\0'; /* Walk through the header and parse relevant parameters. */ @@ -122,12 +123,13 @@ int main(argc, argv) pm_error("malformed SBIG file header at character %d", hdr - header); } *cp = 0; - if (strncmp(hdr, "ST-", 3) == 0) { + if (strncmp(hdr, "ST-", 3) == 0) || + (hdr == &hdr[0] && strstr(hdr,"Image") != NULL)) { char *ep = strchr(hdr + 3, ' '); if (ep != NULL) { *ep = 0; - strcpy(camera, hdr); + STRSCPY(camera, hdr); *ep = ' '; } } diff --git a/converter/ppm/ppmtorgb3.c b/converter/ppm/ppmtorgb3.c index 21d3346a..b1ac8087 100644 --- a/converter/ppm/ppmtorgb3.c +++ b/converter/ppm/ppmtorgb3.c @@ -1,4 +1,4 @@ -/* ppmtorgb3.c - separate a portable pixmap into three portable graymaps +/* ppmtorgb3.c - separate a PPM image into 3 PGM images. ** ** Copyright (C) 1991 by Jef Poskanzer. ** @@ -11,89 +11,134 @@ */ #include <string.h> +#include "pm_c_util.h" +#include "mallocvar.h" +#include "nstring.h" #include "ppm.h" #include "pgm.h" -int -main( argc, argv ) - int argc; - char* argv[]; + + +struct Cmdline { + const char * inputFileName; +}; + + + +static const char * +strippedOfExtension(const char * const arg) { + + char * buffer; + + MALLOCARRAY(buffer, strlen(arg) + 1); + + strcpy(buffer, arg); + { - FILE* ifp; - FILE* redfile; - FILE* grnfile; - FILE* blufile; - const char* basename; - char filename[100]; - char* cp; - pixel* pixelrow; - register pixel* pP; - gray* grayrow; - register gray* gP; - int rows, cols, format, row; - register int col; + char * const dotPos = strrchr(buffer, '.'); + if (dotPos) + *dotPos = '\0'; + } + return buffer; +} + + + +static void +openComponentOut(const char * const suffix, + const char * const baseName, + FILE ** const fpP) { + + const char * fileName; + + asprintfN(&fileName, "%s.%s", baseName, suffix); + + *fpP = pm_openw(fileName); + + strfree(fileName); +} + + + +int +main(int argc, const char ** argv) { + + FILE * ifP; + FILE * redfP; + FILE * grnfP; + FILE * blufP; + pixel * pixelrow; + gray * grayrow; + int rows, cols; + int format; + unsigned int row; pixval maxval; + struct Cmdline cmdline; + const char * baseFileName; + + pm_proginit(&argc, argv); + if (argc-1 > 1) + pm_error("Too many arguments (%u). The only possible argument " + "is the input file name", argc-1); - ppm_init( &argc, argv ); + if (argc-1 < 1) + cmdline.inputFileName = "-"; + else + cmdline.inputFileName = argv[1]; - if ( argc > 2 ) - pm_usage( "[ppmfile]" ); + ifP = pm_openr(cmdline.inputFileName); - if ( argc == 2 ) - { - ifp = pm_openr( argv[1] ); - basename = argv[1]; - cp = strrchr( basename, '.' ); - if ( cp != NULL ) - *cp = '\0'; - } + if (streq(cmdline.inputFileName, "-")) + asprintfN(&baseFileName, "noname"); else - { - ifp = stdin; - basename = "noname"; - } - - ppm_readppminit( ifp, &cols, &rows, &maxval, &format ); - pixelrow = ppm_allocrow( cols ); - (void) strcpy( filename, basename ); - (void) strcat( filename, ".red" ); - redfile = pm_openw( filename ); - pgm_writepgminit( redfile, cols, rows, (gray) maxval, 0 ); - (void) strcpy( filename, basename ); - (void) strcat( filename, ".grn" ); - grnfile = pm_openw( filename ); - pgm_writepgminit( grnfile, cols, rows, (gray) maxval, 0 ); - (void) strcpy( filename, basename ); - (void) strcat( filename, ".blu" ); - blufile = pm_openw( filename ); - pgm_writepgminit( blufile, cols, rows, (gray) maxval, 0 ); - grayrow = pgm_allocrow( cols ); - - for ( row = 0; row < rows; ++row ) - { - ppm_readppmrow( ifp, pixelrow, cols, maxval, format ); - - for ( col = 0, pP = pixelrow, gP = grayrow; col < cols; - ++col, ++pP, ++gP ) - *gP = (gray) PPM_GETR( *pP ); - pgm_writepgmrow( redfile, grayrow, cols, maxval, 0 ); - - for ( col = 0, pP = pixelrow, gP = grayrow; col < cols; - ++col, ++pP, ++gP ) - *gP = (gray) PPM_GETG( *pP ); - pgm_writepgmrow( grnfile, grayrow, cols, maxval, 0 ); - - for ( col = 0, pP = pixelrow, gP = grayrow; col < cols; - ++col, ++pP, ++gP ) - *gP = (gray) PPM_GETB( *pP ); - pgm_writepgmrow( blufile, grayrow, cols, maxval, 0 ); - } - - pm_close( ifp ); - pm_close( redfile ); - pm_close( blufile ); - pm_close( grnfile ); - - exit( 0 ); + baseFileName = strippedOfExtension(cmdline.inputFileName); + + ppm_readppminit(ifP, &cols, &rows, &maxval, &format); + + pixelrow = ppm_allocrow(cols); + + openComponentOut("red", baseFileName, &redfP); + openComponentOut("grn", baseFileName, &grnfP); + openComponentOut("blu", baseFileName, &blufP); + + pgm_writepgminit(redfP, cols, rows, maxval, 0); + pgm_writepgminit(grnfP, cols, rows, maxval, 0); + pgm_writepgminit(blufP, cols, rows, maxval, 0); + + grayrow = pgm_allocrow(cols); + + for (row = 0; row < rows; ++row) { + unsigned int col; + + ppm_readppmrow(ifP, pixelrow, cols, maxval, format); + + for (col = 0; col < cols; ++col) + grayrow[col] = PPM_GETR(pixelrow[col]); + + pgm_writepgmrow(redfP, grayrow, cols, maxval, 0); + + for (col = 0; col < cols; ++col) + grayrow[col] = PPM_GETG(pixelrow[col]); + + pgm_writepgmrow(grnfP, grayrow, cols, maxval, 0); + + for (col = 0; col < cols; ++col) + grayrow[col] = PPM_GETB(pixelrow[col]); + + pgm_writepgmrow(blufP, grayrow, cols, maxval, 0); } + + pgm_freerow(grayrow); + ppm_freerow(pixelrow); + strfree(baseFileName); + pm_close(ifP); + pm_close(blufP); + pm_close(grnfP); + pm_close(redfP); + + return 0; +} + + + diff --git a/converter/ppm/ppmtoyuvsplit.c b/converter/ppm/ppmtoyuvsplit.c index 2dddebfc..133161c1 100644 --- a/converter/ppm/ppmtoyuvsplit.c +++ b/converter/ppm/ppmtoyuvsplit.c @@ -35,8 +35,40 @@ #endif #include <string.h> +#include "nstring.h" #include "ppm.h" + + +struct FileNameSet { + const char * u; + const char * v; + const char * y; +}; + + + +static void +makeOutputFileName(const char * const baseName, + struct FileNameSet * const fnameP) { + + asprintfN(&fnameP->u, "%s.U", baseName); + asprintfN(&fnameP->v, "%s.V", baseName); + asprintfN(&fnameP->y, "%s.Y", baseName); +} + + + +static void +termFileNameSet(struct FileNameSet const fname) { + + strfree(fname.u); + strfree(fname.v); + strfree(fname.y); +} + + + int main(argc, argv) char **argv; @@ -49,8 +81,8 @@ char **argv; pixval maxval; myLONG u,v,y0,y1,y2,y3,u0,u1,u2,u3,v0,v1,v2,v3; unsigned char *y1buf,*y2buf,*ubuf,*vbuf; - char ufname[256],vfname[256],yfname[256]; - + struct FileNameSet fname; + /* Output file names - .U, .V, .Y */ ppm_init(&argc, argv); @@ -59,17 +91,13 @@ char **argv; if (argc == 3) ifp = pm_openr(argv[2]); else ifp = stdin; - strcpy(ufname,argv[1]); - strcpy(vfname,argv[1]); - strcpy(yfname,argv[1]); + makeOutputFileName(argv[1], &fname); - strcat(ufname,".U"); - strcat(vfname,".V"); - strcat(yfname,".Y"); + uf = pm_openw(fname.u); + vf = pm_openw(fname.v); + yf = pm_openw(fname.y); - uf = fopen(ufname,"wb"); - vf = fopen(vfname,"wb"); - yf = fopen(yfname,"wb"); + termFileNameSet(fname); if(!(uf && vf && yf)) { perror("error opening output files"); diff --git a/doc/HISTORY b/doc/HISTORY index bd7538b3..dc406771 100644 --- a/doc/HISTORY +++ b/doc/HISTORY @@ -4,6 +4,102 @@ Netpbm. CHANGE HISTORY -------------- +15.06.28 BJH Release 10.35.96 + + palmtopnm: Fix distorted output with PackBits compressed input. + Always broken (Ability to convert PackBits input was new in + Netpbm 10.27 (March 2005). + + pnmtopalm: Fix arithmetic overflow with ridiculously large + image. Introduced after Netpbm 10.26 (January 2005) but before + Netpbm 10.35 (August 2006). + + pbmtoepson: fix -protocol option - never works and sometimes + crashes program. Always broken (-protocol was new in Netpbm + 10.23 (July 2004). + + pbmtoppa: fix buffer overruns, double-free crashes. Always + broken (pbmtoppa was new in Netpbm 9.1 (March 2000). + + pbmtomatrixorbital: fix bug: fails if you specify the input + file name argument. Always broken. (pbmtomatrixorbital was + new in Netpbm 10.18 (Setpember 2003). + + sbigtopgm: fix detection of camera type. Always broken + (sbigtopgm was new in Netpbm 8.3 (March 2000)). + + pbmtogo: Fix bug: garbage first row. Broken at least since + November 1989. + + pbmtogo: Fix bug: buffer overrun with certain input. Broken + at least since November 1989. + + pbmtoescp2: Fix bug: overrun on certain input. Always broken + (pbmtoescp2 was new in Netpbm 10.18 (September 2003)). + + escp2topbm: Fix buffer overrun on certain input. Always broken + (escp2topbm was new in Netpbm 10.18 (September 2003)). + + libnetpbm: pm_stripeq: fix bug: wild pointer access when + comparator is shorter than comparand. Doesn't affect function, + but could cause crash or privacy exposure. Affects reading of a + PAM file by any program. Introduced in one of Netpbm 10.27 + (March 2005) through 10.35 (August 2006). + + pbmtog3: Fix buffer overrun. Introduced in Netpbm 10.23 + (July 2004). + + cameratopam: Fix arithmetic underflow in JPEG processing; + unknown effect. + + sbigtopgm: fix buffer overrun with invalid input image. Always + present (sbigtopgm was new in Netpbm 8.3 (March 2000)). + + pnmtorle: Fix buffer overrun with long file name. Always + present. (pnmtorle was new to Netpbm in Netpbm 9.0 (April + 2000)). + + pbmtopk: Fix buffer overrun with long file name. Always + present. (pbmtopk was new in Netpbm 1 (March 1991)). + + pktopbm: Fix buffer overrun with long file name. Always + present. (pbmtopk was new in Netpbm 1 (March 1991)). + + ppmtoyuvsplit: Fix buffer overrun with long file name. Always + present. (New in Netpbm 1 (March 1991)). + + pbmtopi3: Fix bug: wrong output when input is higher or wider + than 640 pixels. Always broken (pbmtopi3 was new in September + 1991). + + pbmtomgr: Fix incorrect output when input is too large (must be + at most 4095 pixels high or wide). + + pbmtomacp: fix wild pointer dereference with -b larger than + image height. Always broken. (pbmtomacp was new in X.V11R3 + (March 1988). + + ppmtorgb3: Fix buffer overflow with long input file name. + Always present. (ppmtorgb3 was new in X.V11R4 (November 1989). + + pbmtoatk: Fix crash with very long input file name argument. + Always broken (pbmtoatk was new in 1991). + + pnmgamma -srgbtobt709, -bt709tosrgb: fix bug; incorrect output + nearly always. Always broken (These options were new in + Netpbm 10.32 (February 2006)). + + pamtosvg: fix use of unset variable; probably results in a + crash. Always present (pamtosvg was new in Netpbm 10.33 (March + 2006). + + Install: make backward compatibility link ppmtotga -> pamtotga . + + Install: mention in instructions that it doesn't build on + modern Macs. + + Make clean: remove .deb file + 14.12.25 BJH Release 10.35.95 Fix bogus message from ppmXXX programs when the input is not diff --git a/doc/INSTALL b/doc/INSTALL index 78cf1ebf..0b75607e 100644 --- a/doc/INSTALL +++ b/doc/INSTALL @@ -246,3 +246,24 @@ DOCUMENTATION Documentation is not packaged with the program source code. See the file doc/USERDOC for information on installing documentation. + + +COMMON PROBLEMS +--------------- + +Apple Mac: unknown machine mode 'V8QI' +-------------------------------------- + +Netpbm 10.35 does not work on modern Macs. These newer systems have a +different compiler than what 10.35 was designed for, and it reports itself as +the GNU Compiler but doesn't provide some of the facilities the GNU Compiler +does. Because Netpbm 10.35 was the Super Stable release series by the time +the newer Macs were found to be incompatible and this is a very complex area, +we cannot fix it in 10.35. + +Netpbm 10.51 and later work. + +You can work around the problem by adding the option '-mno-sse' to the +compile, which you can do like this: + + $ make CFLAGS=-mno-sse diff --git a/editor/pnmgamma.c b/editor/pnmgamma.c index e13075ff..efdfe039 100644 --- a/editor/pnmgamma.c +++ b/editor/pnmgamma.c @@ -509,7 +509,7 @@ buildBt709ToSrgbGamma(xelval table[], else radiance = pow((normalized + 0.099) / 1.099, gamma709); - if (radiance < linearCutoffSrgb) + if (radiance < linearCutoffSrgb * normalizer) srgb = radiance * linearExpansionSrgb; else srgb = 1.055 * pow(normalized, oneOverGammaSrgb) - 0.055; @@ -563,7 +563,7 @@ buildSrgbToBt709Gamma(xelval table[], else radiance = pow((normalized + 0.099) / 1.099, gammaSrgb); - if (radiance < linearCutoff709) + if (radiance < linearCutoff709 * normalizer) bt709 = radiance * linearExpansion709; else bt709 = 1.055 * pow(normalized, oneOverGamma709) - 0.055; diff --git a/lib/util/nstring.c b/lib/util/nstring.c index 702a3c44..66d636d5 100644 --- a/lib/util/nstring.c +++ b/lib/util/nstring.c @@ -877,7 +877,7 @@ stripeq(const char * const comparand, */ if (px - p != qx - q) equal = 0; - + else while (p <= px) { if (*p != *q) equal = 0; p++; q++; |