From 13f12476543c4ada693b4cb474039d5cf3389ed1 Mon Sep 17 00:00:00 2001 From: Glenn Randers-Pehrson Date: Tue, 21 Feb 2012 14:57:59 -0600 Subject: [PATCH] [libpng14] Fixed bug with png_handle_hIST with odd chunk length (Frank Busse). --- pngrutil.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pngrutil.c b/pngrutil.c index 0a8baf877..841eb3d56 100644 --- a/pngrutil.c +++ b/pngrutil.c @@ -1,7 +1,7 @@ /* pngrutil.c - utilities to read a PNG file * - * Last changed in libpng 1.4.10 [February 20, 2012] + * Last changed in libpng 1.4.10 [February 21, 2012] * Copyright (c) 1998-2012 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) @@ -1581,15 +1581,16 @@ png_handle_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) return; } - num = length / 2 ; - if (num != (unsigned int) png_ptr->num_palette || num > - (unsigned int) PNG_MAX_PALETTE_LENGTH) + if (length > 2*PNG_MAX_PALETTE_LENGTH || + length != (unsigned int) (2*png_ptr->num_palette)) { png_warning(png_ptr, "Incorrect hIST chunk length"); png_crc_finish(png_ptr, length); return; } + num = length / 2 ; + for (i = 0; i < num; i++) { png_byte buf[2];