From: ken at sonicwizardry dot com Operating system: Linux PHP version: 5.0.0RC2 PHP Bug Type: GD related Bug description: ImageFilter, no bounds check processing image per-pixel: creates a black border
Description: ------------ Running ImageFilter on an image creates a black border around the edge because it references non-existing pixels off of the image (beyond image size). Bounds check/clamp added to convolution loop. Code DIFF is below: File path: ext/gd/libgd/gd.c 3607,3610c3607,3614 < pxl = f(srcback, x-(3>>1)+i, y-(3>>1)+j); < new_r += (float)gdImageRed(srcback, pxl) * filter[j][i]; < new_g += (float)gdImageGreen(srcback, pxl) * filter[j][i]; < new_b += (float)gdImageBlue(srcback, pxl) * filter[j][i]; --- > int ix = x-(3>>1)+i; > int iy = y-(3>>1)+j; > ix = (ix>=src->sx)?src->sx-1 : ((ix<0)?0:ix); > iy = (iy>=src->sy)?src->sy-1 : ((iy<0)?0:iy); > pxl = f(srcback, ix, iy); > new_r += (float)gdImageRed(srcback, pxl) * filter[j][i]; > new_g += (float)gdImageGreen(srcback, pxl) * filter[j][i]; > new_b += (float)gdImageBlue(srcback, pxl) * filter[j][i]; Hope this helps! -Ken Post Jr. -- Edit bug report at http://bugs.php.net/?id=28304&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=28304&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=28304&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=28304&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=28304&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=28304&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=28304&r=needscript Try newer version: http://bugs.php.net/fix.php?id=28304&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=28304&r=support Expected behavior: http://bugs.php.net/fix.php?id=28304&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=28304&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=28304&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=28304&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28304&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=28304&r=dst IIS Stability: http://bugs.php.net/fix.php?id=28304&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=28304&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=28304&r=float
