com php-src: Merge branch 'PHP-5.6' into PHP-7.0: NEWS ext/gd/libgd/gd_webp.c
| From: | Christoph Michael Becker | Date: | Fri, 16 Sep 2016 09:41:42 +0000 |
| Subject: | com php-src: Merge branch 'PHP-5.6' into PHP-7.0: NEWS ext/gd/libgd/gd_webp.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-94564@lists.php.net to get a copy of this message | ||
Commit: c18263e0e0769faee96a5d0ee04b750c442783c6
Author: Christoph M. Becker <cmbecker69@gmx.de> Fri, 16 Sep 2016 11:40:36 +0200
Parents: d2d77c028d78add62cde08cf294f9ffb62a5005b 46df0642618eabc5b5b7df490d1ae23bda00a745
Branches: PHP-7.0 PHP-7.1 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=c18263e0e0769faee96a5d0ee04b750c442783c6
Log:
Merge branch 'PHP-5.6' into PHP-7.0
Changed paths:
MM NEWS
MM ext/gd/libgd/gd_webp.c
Diff:
diff --cc NEWS
index 76cad3e,ef6cb57..42d30ab
--- a/NEWS
+++ b/NEWS
@@@ -22,10 -22,12 +22,12 @@@ PH
(cmb)
. Fixed bug #50194 (imagettftext broken on transparent background w/o
alphablending). (cmb)
+ . Fixed bug #73003 (Integer Overflow in gdImageWebpCtx of gd_webp.c). (trylab,
+ cmb)
- Mbstring:
- . Fixed bug #72994 (mbc_to_code() out of bounds read). (Laruence, cmb)
- . Fixed bug #66964 (mb_convert_variables() cannot detect recursion). (Yasuo)
+ . Fixed bug #66797 (mb_substr only takes 32-bit signed integer). (cmb)
+ . Fixed bug #66964 (mb_convert_variables() cannot detect recursion) (Yasuo)
. Fixed bug #72992 (mbstring.internal_encoding doesn't inherit default_charset).
(Yasuo)
diff --cc ext/gd/libgd/gd_webp.c
index da0cc9d,985187e...0ce27e0
--- a/ext/gd/libgd/gd_webp.c
+++ b/ext/gd/libgd/gd_webp.c
@@@ -99,61 -105,6 +99,69 @@@ gdImagePtr gdImageCreateFromWebpCtx (gd
return im;
}
+void gdImageWebpCtx (gdImagePtr im, gdIOCtx * outfile, int quantization)
+{
+ uint8_t *argb;
+ int x, y;
+ uint8_t *p;
+ uint8_t *out;
+ size_t out_size;
+
+ if (im == NULL) {
+ return;
+ }
+
+ if (!gdImageTrueColor(im)) {
+ zend_error(E_ERROR, "Paletter image not supported by webp");
+ return;
+ }
+
+ if (quantization == -1) {
+ quantization = 80;
+ }
+
++ if (overflow2(gdImageSX(im), 4)) {
++ return;
++ }
++
++ if (overflow2(gdImageSX(im) * 4, gdImageSY(im))) {
++ return;
++ }
++
+ argb = (uint8_t *)gdMalloc(gdImageSX(im) * 4 * gdImageSY(im));
+ if (!argb) {
+ return;
+ }
+ p = argb;
+ for (y = 0; y < gdImageSY(im); y++) {
+ for (x = 0; x < gdImageSX(im); x++) {
+ register int c;
+ register char a;
+ c = im->tpixels[y][x];
+ a = gdTrueColorGetAlpha(c);
+ if (a == 127) {
+ a = 0;
+ } else {
+ a = 255 - ((a << 1) + (a >> 6));
+ }
+ *(p++) = gdTrueColorGetRed(c);
+ *(p++) = gdTrueColorGetGreen(c);
+ *(p++) = gdTrueColorGetBlue(c);
+ *(p++) = a;
+ }
+ }
+ out_size = WebPEncodeRGBA(argb, gdImageSX(im), gdImageSY(im), gdImageSX(im) * 4, quantization,
&out);
+ if (out_size == 0) {
+ zend_error(E_ERROR, "gd-webp encoding failed");
+ goto freeargb;
+ }
+ gdPutBuf(out, out_size, outfile);
+ free(out);
+
+freeargb:
+ gdFree(argb);
+}
+
void gdImageWebpEx (gdImagePtr im, FILE * outFile, int quantization)
{
gdIOCtx *out = gdNewFileCtx(outFile);