mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[libpng16] Safely convert num_bytes to a png_byte in png_set_sig_bytes()
This commit is contained in:
parent
a8242fe6fb
commit
167b5e4c27
2
ANNOUNCE
2
ANNOUNCE
@ -55,6 +55,8 @@ Version 1.6.19beta02 [August 18, 2015]
|
|||||||
on a 16-bit system. It also adds back various switch default clauses
|
on a 16-bit system. It also adds back various switch default clauses
|
||||||
for GCC; GCC errors out if they are not present (with an appropriately
|
for GCC; GCC errors out if they are not present (with an appropriately
|
||||||
high level of warnings).
|
high level of warnings).
|
||||||
|
Safely convert num_bytes to a png_byte in png_set_sig_bytes() (Robert
|
||||||
|
Seacord).
|
||||||
|
|
||||||
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
|
||||||
|
|||||||
2
CHANGES
2
CHANGES
@ -5335,6 +5335,8 @@ Version 1.6.19beta02 [August 18, 2015]
|
|||||||
on a 16-bit system. It also adds back various switch default clauses
|
on a 16-bit system. It also adds back various switch default clauses
|
||||||
for GCC; GCC errors out if they are not present (with an appropriately
|
for GCC; GCC errors out if they are not present (with an appropriately
|
||||||
high level of warnings).
|
high level of warnings).
|
||||||
|
Safely convert num_bytes to a png_byte in png_set_sig_bytes() (Robert
|
||||||
|
Seacord).
|
||||||
|
|
||||||
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
|
||||||
|
|||||||
6
png.c
6
png.c
@ -26,15 +26,17 @@ typedef png_libpng_version_1_6_19beta02 Your_png_h_is_not_version_1_6_19beta02;
|
|||||||
void PNGAPI
|
void PNGAPI
|
||||||
png_set_sig_bytes(png_structrp png_ptr, int num_bytes)
|
png_set_sig_bytes(png_structrp png_ptr, int num_bytes)
|
||||||
{
|
{
|
||||||
|
unsigned int nb = (unsigned int)num_bytes;
|
||||||
|
|
||||||
png_debug(1, "in png_set_sig_bytes");
|
png_debug(1, "in png_set_sig_bytes");
|
||||||
|
|
||||||
if (png_ptr == NULL)
|
if (png_ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (num_bytes > 8)
|
if (nb > 8)
|
||||||
png_error(png_ptr, "Too many bytes for PNG signature");
|
png_error(png_ptr, "Too many bytes for PNG signature");
|
||||||
|
|
||||||
png_ptr->sig_bytes = (png_byte)((num_bytes < 0 ? 0 : num_bytes) & 0xff);
|
png_ptr->sig_bytes = (png_byte)nb;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Checks whether the supplied bytes match the PNG signature. We allow
|
/* Checks whether the supplied bytes match the PNG signature. We allow
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user