From 9d8461b2012adb25ba0b10deff31dc766f6ea8f2 Mon Sep 17 00:00:00 2001 From: giraffedata Date: Fri, 10 Dec 2010 18:19:40 +0000 Subject: Release 10.35.78 git-svn-id: http://svn.code.sf.net/p/netpbm/code/super_stable@1375 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- Makefile.version | 2 +- converter/bmp.h | 8 ++++---- converter/other/bmptopnm.c | 17 +++++++++++------ converter/other/pnmtopng.c | 2 +- converter/ppm/ilbmtoppm.c | 17 ++++++++++------- doc/HISTORY | 13 +++++++++++-- 6 files changed, 38 insertions(+), 21 deletions(-) diff --git a/Makefile.version b/Makefile.version index d7dfdb3e..0aa3df04 100644 --- a/Makefile.version +++ b/Makefile.version @@ -1,3 +1,3 @@ NETPBM_MAJOR_RELEASE = 10 NETPBM_MINOR_RELEASE = 35 -NETPBM_POINT_RELEASE = 77 +NETPBM_POINT_RELEASE = 78 diff --git a/converter/bmp.h b/converter/bmp.h index b22be82f..8b2aa302 100644 --- a/converter/bmp.h +++ b/converter/bmp.h @@ -126,7 +126,7 @@ BMPleninfoheader(enum bmpClass const class) { static __inline__ unsigned int BMPlencolormap(enum bmpClass const class, unsigned int const bitcount, - int const cmapsize) { + unsigned int const cmapsize) { unsigned int lenrgb; unsigned int lencolormap; @@ -141,7 +141,7 @@ BMPlencolormap(enum bmpClass const class, case C_OS2: lenrgb = 3; break; } - if (cmapsize < 0) + if (!cmapsize) lencolormap = (1 << bitcount) * lenrgb; else lencolormap = cmapsize * lenrgb; @@ -216,7 +216,7 @@ BMPoffbits(enum bmpClass const class, static __inline__ unsigned int BMPlenfileGen(enum bmpClass const class, unsigned int const bitcount, - int const cmapsize, + unsigned int const cmapsize, unsigned int const x, unsigned int const y, unsigned int const imageSize, @@ -244,7 +244,7 @@ BMPlenfileGen(enum bmpClass const class, static __inline__ unsigned int BMPlenfile(enum bmpClass const class, unsigned int const bitcount, - int const cmapsize, + unsigned int const cmapsize, unsigned int const x, unsigned int const y) { /*---------------------------------------------------------------------------- diff --git a/converter/other/bmptopnm.c b/converter/other/bmptopnm.c index 4d29e4d3..e1bd1403 100644 --- a/converter/other/bmptopnm.c +++ b/converter/other/bmptopnm.c @@ -84,8 +84,11 @@ struct bmpInfoHeader { described by the "mask" values in the header, rather than fixed formats. */ - int cmapsize; - /* Size in bytes of the colormap (palette) in the BMP file */ + unsigned int cmapsize; + /* Size in bytes of the colormap (palette) in the BMP file. + + Zero means there is no colormap. + */ unsigned int imageSize; /* Size in bytes of the image data. We only reference this when the image is compressed. */ @@ -320,6 +323,8 @@ readWindowsBasic40ByteInfoHeader(FILE * const ifP, headerP->cols = GetLong(ifP); { long const cy = GetLong(ifP); + if (cy == 0) + pm_error("Invalid BMP file: says height is zero"); if (cy < 0) { headerP->rowOrder = TOPDOWN; headerP->rows = - cy; @@ -360,7 +365,7 @@ readWindowsBasic40ByteInfoHeader(FILE * const ifP, GetLong(ifP); /* YpixelsPerMeter */ colorsused = GetLong(ifP); /* ColorsUsed */ /* See comments in bmp.h for info about the definition of the following - word and its relationship to the color map size (*pcmapsize). + word and its relationship to the color map size (headerP->cmapsize). */ colorsimportant = GetLong(ifP); /* ColorsImportant */ @@ -584,7 +589,7 @@ static void BMPreadcolormap(FILE * const ifP, int const class, xel ** const colormapP, - int const cmapsize, + unsigned int const cmapsize, unsigned int * const bytesReadP) { /*---------------------------------------------------------------------------- Read the color map from the present position in the input BMP file @@ -599,7 +604,7 @@ BMPreadcolormap(FILE * const ifP, 'class' is the class of BMP image - Windows or OS/2. -----------------------------------------------------------------------------*/ - int i; + unsigned int i; xel * colormap; unsigned int bytesRead; @@ -1139,7 +1144,7 @@ reportHeader(struct bmpInfoHeader const header, header.compression == COMP_JPEG ? "JPEG (not supported)" : header.compression == COMP_PNG ? "PNG (not supported)" : "???"); - pm_message(" Colors in color map: %d", header.cmapsize); + pm_message(" Colors in color map: %u", header.cmapsize); } diff --git a/converter/other/pnmtopng.c b/converter/other/pnmtopng.c index ce1fe4f6..065f5195 100644 --- a/converter/other/pnmtopng.c +++ b/converter/other/pnmtopng.c @@ -72,7 +72,7 @@ #if PNG_LIBPNG_VER >= 10400 #error Your PNG library () is incompatible with this Netpbm source code. #error You need either an older PNG library (older than 1.4) -#error newer Netpbm source code (at least 10.48) +#error newer Netpbm source code (at least 10.47.04) #endif diff --git a/converter/ppm/ilbmtoppm.c b/converter/ppm/ilbmtoppm.c index c88cdfb2..5001741a 100644 --- a/converter/ppm/ilbmtoppm.c +++ b/converter/ppm/ilbmtoppm.c @@ -94,7 +94,6 @@ static short wrotemask = 0; static IFF_ID typeid; /* ID_ILBM, ID_RGBN, ID_RGB8 */ static pixel *transpColor = NULL; /* transparent color */ -static short transpIndex = -1; static char *transpName = NULL; static bool debug = FALSE; @@ -776,15 +775,19 @@ check_cmap(bmhd, cmap) if( bmhd ) { if( bmhd->masking == mskHasTransparentColor || bmhd->masking == mskLasso ) { - transpIndex = bmhd->transparentColor; + unsigned short const transpIdx = bmhd->transparentColor; if( !transpName ) { MALLOCVAR_NOFAIL(transpColor); - if( transpIndex >= cmap->ncolors ) { - pm_message("using default transparent color (black)"); - PPM_ASSIGN(*transpColor, 0, 0, 0); + if (HAS_COLORMAP(cmap)) { + if( transpIdx >= cmap->ncolors ) { + pm_message("using default transparent color (black)"); + PPM_ASSIGN(*transpColor, 0, 0, 0); + } else + *transpColor = cmap->color[transpIdx]; + } else { + /* The color index is just a direct gray level */ + PPM_ASSIGN(*transpColor, transpIdx, transpIdx, transpIdx); } - else - *transpColor = cmap->color[transpIndex]; } } diff --git a/doc/HISTORY b/doc/HISTORY index 1f288d54..cf488d5e 100644 --- a/doc/HISTORY +++ b/doc/HISTORY @@ -4,6 +4,17 @@ Netpbm. CHANGE HISTORY -------------- +10.12.10 BJH Release 10.35.78 + + bmptopnm: Don't crash on invalid zero value of image height in + the BMP header of a compressed file. Always broken. + + bmptopnm: don't crash on large invalid value of 'colorsused' in + the BMP header. + + ilbmtoppm: Don't crash on image that has a transparent color + index, but no color map. + 10.09.18 BJH Release 10.35.77 ppmtompeg: fix crash with free of unallocated memory. @@ -12,8 +23,6 @@ CHANGE HISTORY Build: don't use or bzero(). -10.07.10 BJH Release 10.35.76 - Pnmtopng: -libversion doesn't report level of linked libz. It was a modularity violation and caused build failures on Mac OS X, because Pnmtopng per se doesn't know about libz -- -- cgit 1.4.1