提交 167b5e4c 编写于 作者: R Robert C. Seacord 提交者: Glenn Randers-Pehrson

[libpng16] Safely convert num_bytes to a png_byte in png_set_sig_bytes()

上级 a8242fe6
......@@ -55,6 +55,8 @@ Version 1.6.19beta02 [August 18, 2015]
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
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
(subscription required; visit
......
......@@ -5335,6 +5335,8 @@ Version 1.6.19beta02 [August 18, 2015]
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
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
(subscription required; visit
......
......@@ -26,15 +26,17 @@ typedef png_libpng_version_1_6_19beta02 Your_png_h_is_not_version_1_6_19beta02;
void PNGAPI
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");
if (png_ptr == NULL)
return;
if (num_bytes > 8)
if (nb > 8)
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册