[libpng16] Simplified and future-proofed png_user_version_check().
This commit is contained in:
parent
97dd654ba4
commit
a2fe24d186
1
ANNOUNCE
1
ANNOUNCE
@ -44,6 +44,7 @@ Version 1.6.15beta05 [November 5, 2014]
|
||||
Use png_get_libpng_ver(NULL) instead of PNG_LIBPNG_VER_STRING in
|
||||
example.c, pngtest.c, and applications in the contrib directory.
|
||||
Avoid out-of-bounds memory access in png_user_version_check().
|
||||
Simplified and future-proofed png_user_version_check().
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||
(subscription required; visit
|
||||
|
1
CHANGES
1
CHANGES
@ -5052,6 +5052,7 @@ Version 1.6.15beta05 [November 5, 2014]
|
||||
Use png_get_libpng_ver(NULL) instead of PNG_LIBPNG_VER_STRING in
|
||||
example.c, pngtest.c, and applications in the contrib directory.
|
||||
Avoid out-of-bounds memory access in png_user_version_check().
|
||||
Simplified and future-proofed png_user_version_check().
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||
(subscription required; visit
|
||||
|
22
png.c
22
png.c
@ -165,33 +165,30 @@ png_calculate_crc(png_structrp png_ptr, png_const_bytep ptr, png_size_t length)
|
||||
int
|
||||
png_user_version_check(png_structrp png_ptr, png_const_charp user_png_ver)
|
||||
{
|
||||
/* Libpng versions 1.0.0 and later are binary compatible if the version
|
||||
* string matches through the second '.'; we must recompile any
|
||||
* applications that use any older library version.
|
||||
*/
|
||||
|
||||
if (user_png_ver != NULL)
|
||||
{
|
||||
int i = -1;
|
||||
int found_dots = 0;
|
||||
|
||||
do
|
||||
{
|
||||
i++;
|
||||
if (user_png_ver[i] != png_libpng_ver[i])
|
||||
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
|
||||
} while (png_libpng_ver[i] != 0 && user_png_ver[i] != 0);
|
||||
if (user_png_ver[i] == '.')
|
||||
found_dots++;
|
||||
} while (found_dots < 2 && png_libpng_ver[i] != 0 && user_png_ver[i] != 0);
|
||||
}
|
||||
|
||||
else
|
||||
png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
|
||||
|
||||
if ((png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH) != 0)
|
||||
{
|
||||
/* Libpng 0.90 and later are binary incompatible with libpng 0.89, so
|
||||
* we must recompile any applications that use any older library version.
|
||||
* For versions after libpng 1.0, we will be compatible, so we need
|
||||
* only check the first and third digits (note that when we reach version
|
||||
* 1.10 we will need to check the fourth symbol, namely user_png_ver[3]).
|
||||
*/
|
||||
if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] ||
|
||||
(user_png_ver[0] == '1' && (user_png_ver[2] != png_libpng_ver[2] ||
|
||||
user_png_ver[3] != png_libpng_ver[3])) ||
|
||||
(user_png_ver[0] == '0' && user_png_ver[2] < '9'))
|
||||
{
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
size_t pos = 0;
|
||||
@ -213,7 +210,6 @@ png_user_version_check(png_structrp png_ptr, png_const_charp user_png_ver)
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Success return. */
|
||||
return 1;
|
||||
|
Loading…
Reference in New Issue
Block a user