Skip to content

Commit 55c2ea1

Browse files
author
aavit
committed
Fixes: the png_handle_cHRM crash bug in bundled libpng 1.5.4
The PNG Development Group explains that libpng 1.5.4 (only) introduced a divide-by-zero bug in png_handle_cHRM(), which could lead to crashes (denial of service) for certain malformed PNGs. Ref. http://www.libpng.org/pub/png/libpng.html Task-number: QTBUG-22168
1 parent fa71729 commit 55c2ea1

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/3rdparty/libpng/pngrutil.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,12 +1037,14 @@ png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
10371037
*/
10381038
png_uint_32 w = y_red + y_green + y_blue;
10391039

1040-
png_ptr->rgb_to_gray_red_coeff = (png_uint_16)(((png_uint_32)y_red *
1041-
32768)/w);
1042-
png_ptr->rgb_to_gray_green_coeff = (png_uint_16)(((png_uint_32)y_green
1043-
* 32768)/w);
1044-
png_ptr->rgb_to_gray_blue_coeff = (png_uint_16)(((png_uint_32)y_blue *
1045-
32768)/w);
1040+
if (w != 0) {
1041+
png_ptr->rgb_to_gray_red_coeff = (png_uint_16)(((png_uint_32)y_red *
1042+
32768)/w);
1043+
png_ptr->rgb_to_gray_green_coeff = (png_uint_16)(((png_uint_32)y_green
1044+
* 32768)/w);
1045+
png_ptr->rgb_to_gray_blue_coeff = (png_uint_16)(((png_uint_32)y_blue *
1046+
32768)/w);
1047+
}
10461048
}
10471049
}
10481050
#endif

0 commit comments

Comments
 (0)