From: Scott MacVicar Date: Wed, 10 Dec 2008 13:32:02 +0000 (+0000) Subject: MFH Fix segfault and potential security issue in imagerotate(). X-Git-Tag: php-5.3.0beta1~463 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fdb9b62cef6eebf0e941b17f60bef30364c7fcdb;p=php MFH Fix segfault and potential security issue in imagerotate(). --- diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c index d00c697016..a2677c11dd 100644 --- a/ext/gd/libgd/gd.c +++ b/ext/gd/libgd/gd.c @@ -3136,7 +3136,7 @@ gdImagePtr gdImageRotate (gdImagePtr src, double dAngle, int clrBack, int ignore return NULL; } - if (!gdImageTrueColor(src) && clrBack>=gdImageColorsTotal(src)) { + if (!gdImageTrueColor(src) && (clrBack < 0 || clrBack>=gdImageColorsTotal(src))) { return NULL; } diff --git a/ext/gd/tests/imagerotate_overflow.phpt b/ext/gd/tests/imagerotate_overflow.phpt new file mode 100644 index 0000000000..ade61d8f80 --- /dev/null +++ b/ext/gd/tests/imagerotate_overflow.phpt @@ -0,0 +1,32 @@ +--TEST-- +imagerotate() overflow with negative numbers +--SKIPIF-- + +--FILE-- + +--EXPECT-- +bool(false)