mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[libpng14] Avoid out-of-bounds memory access in png_user_version_check().
Simplified and future-proofed png_user_version_check().
This commit is contained in:
26
pngread.c
26
pngread.c
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngread.c - read a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.4.13 [%RDATE%]
|
||||
* Last changed in libpng 1.4.13 [February 6, 2014]
|
||||
* Copyright (c) 1998-2014 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.)
|
||||
@@ -53,8 +53,6 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int i;
|
||||
|
||||
png_debug(1, "in png_create_read_struct");
|
||||
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
@@ -99,14 +97,20 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
|
||||
png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn);
|
||||
|
||||
if (user_png_ver)
|
||||
{
|
||||
i = 0;
|
||||
do
|
||||
{
|
||||
if (user_png_ver[i] != png_libpng_ver[i])
|
||||
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
|
||||
} while (png_libpng_ver[i++]);
|
||||
if (user_png_ver != NULL)
|
||||
{
|
||||
int i = -1;
|
||||
int found_dots = 0;
|
||||
|
||||
do
|
||||
{
|
||||
i++;
|
||||
if (user_png_ver[i] != PNG_LIBPNG_VER_STRING[i])
|
||||
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
|
||||
if (user_png_ver[i] == '.')
|
||||
found_dots++;
|
||||
} while (found_dots < 2 && user_png_ver[i] != 0 &&
|
||||
PNG_LIBPNG_VER_STRING[i] != 0);
|
||||
}
|
||||
else
|
||||
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
|
||||
|
||||
Reference in New Issue
Block a user