mirror of
				https://git.code.sf.net/p/libpng/code.git
				synced 2025-07-10 18:04:09 +02:00 
			
		
		
		
	[libpng16] Check for EOF in contrib/pngminus/pnm2png.c (Paul Stewart).
This commit is contained in:
		
							parent
							
								
									ec89c54e42
								
							
						
					
					
						commit
						34df4eb5ad
					
				
							
								
								
									
										1
									
								
								ANNOUNCE
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								ANNOUNCE
									
									
									
									
									
								
							@ -51,6 +51,7 @@ Version 1.6.3beta05 [May 7, 2013]
 | 
				
			|||||||
    the windowBits setting in the zlib header.
 | 
					    the windowBits setting in the zlib header.
 | 
				
			||||||
  Zlib-1.2.8 and earlier don't allow us to decrease the windowBits, so
 | 
					  Zlib-1.2.8 and earlier don't allow us to decrease the windowBits, so
 | 
				
			||||||
    undid the improvement in beta04.
 | 
					    undid the improvement in beta04.
 | 
				
			||||||
 | 
					  Check for EOF in contrib/pngminus/pnm2png.c (Paul Stewart).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
 | 
					Send comments/corrections/commendations to png-mng-implement at lists.sf.net
 | 
				
			||||||
(subscription required; visit
 | 
					(subscription required; visit
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										1
									
								
								CHANGES
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								CHANGES
									
									
									
									
									
								
							@ -4534,6 +4534,7 @@ Version 1.6.3beta05 [May 7, 2013]
 | 
				
			|||||||
    the windowBits setting in the zlib header.
 | 
					    the windowBits setting in the zlib header.
 | 
				
			||||||
  Zlib-1.2.8 and earlier don't allow us to decrease the windowBits, so
 | 
					  Zlib-1.2.8 and earlier don't allow us to decrease the windowBits, so
 | 
				
			||||||
    undid the improvement in beta04.
 | 
					    undid the improvement in beta04.
 | 
				
			||||||
 | 
					  Check for EOF in contrib/pngminus/pnm2png.c (Paul Stewart).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
 | 
					Send comments/corrections/commendations to png-mng-implement at lists.sf.net
 | 
				
			||||||
(subscription required; visit
 | 
					(subscription required; visit
 | 
				
			||||||
 | 
				
			|||||||
@ -18,6 +18,7 @@
 | 
				
			|||||||
#include <mem.h>
 | 
					#include <mem.h>
 | 
				
			||||||
#include <fcntl.h>
 | 
					#include <fcntl.h>
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					#include <zlib.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef BOOL
 | 
					#ifndef BOOL
 | 
				
			||||||
#define BOOL unsigned char
 | 
					#define BOOL unsigned char
 | 
				
			||||||
@ -197,6 +198,9 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
 | 
				
			|||||||
  char          height_token[16];
 | 
					  char          height_token[16];
 | 
				
			||||||
  char          maxval_token[16];
 | 
					  char          maxval_token[16];
 | 
				
			||||||
  int           color_type;
 | 
					  int           color_type;
 | 
				
			||||||
 | 
					  unsigned long   ul_width, ul_alpha_width;
 | 
				
			||||||
 | 
					  unsigned long   ul_height, ul_alpha_height;
 | 
				
			||||||
 | 
					  unsigned long   ul_maxval;
 | 
				
			||||||
  png_uint_32   width, alpha_width;
 | 
					  png_uint_32   width, alpha_width;
 | 
				
			||||||
  png_uint_32   height, alpha_height;
 | 
					  png_uint_32   height, alpha_height;
 | 
				
			||||||
  png_uint_32   maxval;
 | 
					  png_uint_32   maxval;
 | 
				
			||||||
@ -227,11 +231,15 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
 | 
				
			|||||||
    raw = (type_token[1] == '5');
 | 
					    raw = (type_token[1] == '5');
 | 
				
			||||||
    color_type = PNG_COLOR_TYPE_GRAY;
 | 
					    color_type = PNG_COLOR_TYPE_GRAY;
 | 
				
			||||||
    get_token(pnm_file, width_token);
 | 
					    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);
 | 
					    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);
 | 
					    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)
 | 
					    if (maxval <= 1)
 | 
				
			||||||
      bit_depth = 1;
 | 
					      bit_depth = 1;
 | 
				
			||||||
    else if (maxval <= 3)
 | 
					    else if (maxval <= 3)
 | 
				
			||||||
@ -248,11 +256,14 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
 | 
				
			|||||||
    raw = (type_token[1] == '6');
 | 
					    raw = (type_token[1] == '6');
 | 
				
			||||||
    color_type = PNG_COLOR_TYPE_RGB;
 | 
					    color_type = PNG_COLOR_TYPE_RGB;
 | 
				
			||||||
    get_token(pnm_file, width_token);
 | 
					    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);
 | 
					    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);
 | 
					    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)
 | 
					    if (maxval <= 1)
 | 
				
			||||||
      bit_depth = 1;
 | 
					      bit_depth = 1;
 | 
				
			||||||
    else if (maxval <= 3)
 | 
					    else if (maxval <= 3)
 | 
				
			||||||
@ -287,15 +298,18 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
      alpha_raw = (type_token[1] == '5');
 | 
					      alpha_raw = (type_token[1] == '5');
 | 
				
			||||||
      get_token(alpha_file, width_token);
 | 
					      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)
 | 
					      if (alpha_width != width)
 | 
				
			||||||
        return FALSE;
 | 
					        return FALSE;
 | 
				
			||||||
      get_token(alpha_file, height_token);
 | 
					      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)
 | 
					      if (alpha_height != height)
 | 
				
			||||||
        return FALSE;
 | 
					        return FALSE;
 | 
				
			||||||
      get_token(alpha_file, maxval_token);
 | 
					      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)
 | 
					      if (maxval <= 1)
 | 
				
			||||||
        alpha_depth = 1;
 | 
					        alpha_depth = 1;
 | 
				
			||||||
      else if (maxval <= 3)
 | 
					      else if (maxval <= 3)
 | 
				
			||||||
@ -446,19 +460,24 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
 | 
				
			|||||||
void get_token(FILE *pnm_file, char *token)
 | 
					void get_token(FILE *pnm_file, char *token)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  int i = 0;
 | 
					  int i = 0;
 | 
				
			||||||
 | 
					  int ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* remove white-space */
 | 
					  /* remove white-space */
 | 
				
			||||||
  do
 | 
					  do
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    token[i] = (unsigned char) fgetc (pnm_file);
 | 
					    ret = fgetc(pnm_file);
 | 
				
			||||||
 | 
					    if (ret == EOF) break;
 | 
				
			||||||
 | 
					    token[i] = (unsigned char) ret;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  while ((token[i] == '\n') || (token[i] == '\r') || (token[i] == ' '));
 | 
					  while ((token[i] == '\n') || (token[i] == '\r') || (token[i] == ' '));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* read string */
 | 
					  /* read string */
 | 
				
			||||||
  do
 | 
					  do
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
 | 
					    ret = fgetc(pnm_file);
 | 
				
			||||||
 | 
					    if (ret == EOF) break;
 | 
				
			||||||
    i++;
 | 
					    i++;
 | 
				
			||||||
    token[i] = (unsigned char) fgetc (pnm_file);
 | 
					    token[i] = (unsigned char) ret;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  while ((token[i] != '\n') && (token[i] != '\r') && (token[i] != ' '));
 | 
					  while ((token[i] != '\n') && (token[i] != '\r') && (token[i] != ' '));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -510,6 +529,7 @@ png_uint_32 get_value (FILE *pnm_file, int depth)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  static png_uint_32 mask = 0;
 | 
					  static png_uint_32 mask = 0;
 | 
				
			||||||
  png_byte token[16];
 | 
					  png_byte token[16];
 | 
				
			||||||
 | 
					  unsigned long ul_ret_value;
 | 
				
			||||||
  png_uint_32 ret_value;
 | 
					  png_uint_32 ret_value;
 | 
				
			||||||
  int i = 0;
 | 
					  int i = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -518,7 +538,8 @@ png_uint_32 get_value (FILE *pnm_file, int depth)
 | 
				
			|||||||
      mask = (mask << 1) | 0x01;
 | 
					      mask = (mask << 1) | 0x01;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  get_token (pnm_file, (char *) token);
 | 
					  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;
 | 
					  ret_value &= mask;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user