Line 0
Link Here
|
|
|
1 |
LibGD Issue: https://github.com/libgd/libgd/issues/308 |
2 |
Commit: https://github.com/libgd/libgd/commit/40bec0f38f50e8510f5bb71a82f516d46facde03 |
3 |
|
4 |
Fix integer overflow in gdImageWebpCtx |
5 |
|
6 |
Integer overflow can be happened in expression gdImageSX(im) * 4 * |
7 |
gdImageSY(im). It could lead to heap buffer overflow in the following |
8 |
code. This issue has been reported to the PHP Bug Tracking System. The |
9 |
proof-of-concept file will be supplied some days later. This issue was |
10 |
discovered by Ke Liu of Tencent's Xuanwu LAB. |
11 |
--- src/gd_webp.c.orig 2016-07-21 08:06:42 UTC |
12 |
+++ src/gd_webp.c |
13 |
@@ -126,6 +126,14 @@ void gdImageWebpCtx (gdImagePtr im, gdIO |
14 |
quantization = 80; |
15 |
} |
16 |
|
17 |
+ if (overflow2(gdImageSX(im), 4)) { |
18 |
+ return; |
19 |
+ } |
20 |
+ |
21 |
+ if (overflow2(gdImageSX(im) * 4, gdImageSY(im))) { |
22 |
+ return; |
23 |
+ } |
24 |
+ |
25 |
argb = (uint8_t *)gdMalloc(gdImageSX(im) * 4 * gdImageSY(im)); |
26 |
if (!argb) { |
27 |
return; |