[libpng15] Ported libpng-1.6.3beta06/contrib/pngminus/pnm2png.c changes

to use unsigned long, not png_uint_32 arguments to sscanf().
This commit is contained in:
Glenn Randers-Pehrson 2013-05-12 12:09:48 -05:00
parent 1087026c09
commit a3bece6bb7
3 changed files with 41 additions and 19 deletions

View File

@ -1,5 +1,5 @@
Libpng 1.5.16beta06 - May 10, 2013
Libpng 1.5.16beta06 - May 12, 2013
This is not intended to be a public release. It will be replaced
within a few weeks by a public version or by another test version.
@ -55,11 +55,13 @@ Version 1.5.16beta05 [May 9, 2013]
Initialize dimension values so if sscanf fails at least we have known
invalid values.
Version 1.5.16beta06 [May 10, 2013]
Version 1.5.16beta06 [May 12, 2013]
Allow contrib/pnminus/pnm2png.c to compile without WRITE_INVERT and WRITE_PACK
supported (writes error message that it can't read P1 or P4 PBM files).
Revised contrib/pngminim/*/makefile to separate CPPFLAGS and CPFLAGS, and
to generate pnglibconf.h with the right zlib header files.
Ported contrib/pngminus/pnm2png.c changes back from libpng-1.6.3beta06,
to use unsigned long, not png_uint_32 arguments to sscanf().
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit

View File

@ -4099,11 +4099,13 @@ Version 1.5.16beta05 [May 9, 2013]
Initialize dimension values so if sscanf fails at least we have known
invalid values.
Version 1.5.16beta06 [May 10, 2013]
Version 1.5.16beta06 [May 12, 2013]
Allow contrib/pnminus/pnm2png.c to compile without WRITE_INVERT and WRITE_PACK
supported (writes error message that it can't read P1 or P4 PBM files).
Revised contrib/pngminim/*/makefile to separate CPPFLAGS and CPFLAGS, and
to generate pnglibconf.h with the right zlib header files.
Ported contrib/pngminus/pnm2png.c changes back from libpng-1.6.3beta06,
to use unsigned long, not png_uint_32 arguments to sscanf().
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit

View File

@ -18,6 +18,7 @@
#include <mem.h>
#include <fcntl.h>
#endif
#include <zlib.h>
#ifndef BOOL
#define BOOL unsigned char
@ -197,9 +198,12 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
char height_token[16];
char maxval_token[16];
int color_type;
png_uint_32 width = 0, alpha_width = 0;
png_uint_32 height = 0, alpha_height = 0;
png_uint_32 maxval = 0;
unsigned long ul_width=0, ul_alpha_width=0;
unsigned long ul_height=0, ul_alpha_height=0;
unsigned long ul_maxval=0;
png_uint_32 width, alpha_width;
png_uint_32 height, alpha_height;
png_uint_32 maxval;
int bit_depth = 0;
int channels;
int alpha_depth = 0;
@ -225,9 +229,11 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
raw = (type_token[1] == '4');
color_type = PNG_COLOR_TYPE_GRAY;
get_token(pnm_file, width_token);
sscanf (width_token, "%lu", &width);
sscanf (width_token, "%lu", &ul_width);
width = (png_uint_32) ul_width;
get_token(pnm_file, height_token);
sscanf (height_token, "%lu", &height);
sscanf (height_token, "%lu", &ul_height);
height = (png_uint_32) ul_height;
bit_depth = 1;
packed_bitmap = TRUE;
#else
@ -240,11 +246,15 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
raw = (type_token[1] == '5');
color_type = PNG_COLOR_TYPE_GRAY;
get_token(pnm_file, width_token);
sscanf (width_token, "%lu", &width);
sscanf (width_token, "%lu", &ul_width);
width = (png_uint_32) ul_width;
get_token(pnm_file, height_token);
sscanf (height_token, "%lu", &height);
sscanf (height_token, "%lu", &ul_height);
height = (png_uint_32) ul_height;
get_token(pnm_file, maxval_token);
sscanf (maxval_token, "%lu", &maxval);
sscanf (maxval_token, "%lu", &ul_maxval);
maxval = (png_uint_32) ul_maxval;
if (maxval <= 1)
bit_depth = 1;
else if (maxval <= 3)
@ -261,11 +271,14 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
raw = (type_token[1] == '6');
color_type = PNG_COLOR_TYPE_RGB;
get_token(pnm_file, width_token);
sscanf (width_token, "%lu", &width);
sscanf (width_token, "%lu", &ul_width);
width = (png_uint_32) ul_width;
get_token(pnm_file, height_token);
sscanf (height_token, "%lu", &height);
sscanf (height_token, "%lu", &ul_height);
height = (png_uint_32) ul_height;
get_token(pnm_file, maxval_token);
sscanf (maxval_token, "%lu", &maxval);
sscanf (maxval_token, "%lu", &ul_maxval);
maxval = (png_uint_32) ul_maxval;
if (maxval <= 1)
bit_depth = 1;
else if (maxval <= 3)
@ -300,15 +313,18 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
{
alpha_raw = (type_token[1] == '5');
get_token(alpha_file, width_token);
sscanf (width_token, "%lu", &alpha_width);
sscanf (width_token, "%lu", &ul_alpha_width);
alpha_width=(png_uint_32) ul_alpha_width;
if (alpha_width != width)
return FALSE;
get_token(alpha_file, height_token);
sscanf (height_token, "%lu", &alpha_height);
sscanf (height_token, "%lu", &ul_alpha_height);
alpha_height = (png_uint_32) ul_alpha_height;
if (alpha_height != height)
return FALSE;
get_token(alpha_file, maxval_token);
sscanf (maxval_token, "%lu", &maxval);
sscanf (maxval_token, "%lu", &ul_maxval);
maxval = (png_uint_32) ul_maxval;
if (maxval <= 1)
alpha_depth = 1;
else if (maxval <= 3)
@ -460,7 +476,7 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
/* write out the entire image data in one call */
png_write_image (png_ptr, row_pointers);
/* write the additional chunks to the PNG file (not really needed) */
/* write the additional chuncks to the PNG file (not really needed) */
png_write_end (png_ptr, info_ptr);
/* clean up after the write, and free any memory allocated */
@ -558,6 +574,7 @@ png_uint_32 get_value (FILE *pnm_file, int depth)
{
static png_uint_32 mask = 0;
png_byte token[16];
unsigned long ul_ret_value;
png_uint_32 ret_value;
int i = 0;
@ -566,7 +583,8 @@ png_uint_32 get_value (FILE *pnm_file, int depth)
mask = (mask << 1) | 0x01;
get_token (pnm_file, (char *) token);
sscanf ((const char *) token, "%lu", &ret_value);
sscanf ((const char *) token, "%lu", &ul_ret_value);
ret_value = (png_uint_32) ul_ret_value;
ret_value &= mask;