Bug #79615 [NEW]: Wrong GIF header written in GD GIFEncode
| From: | sageptr at gmail dot com | Date: | Wed, 20 May 2020 13:31:46 +0000 |
| Subject: | Bug #79615 [NEW]: Wrong GIF header written in GD GIFEncode | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-227092@lists.php.net to get a copy of this message | ||
From: sageptr at gmail dot com
Operating system:
PHP version: Irrelevant
Package: GD related
Bug Type: Bug
Bug description:Wrong GIF header written in GD GIFEncode
Description:
------------
In file
https://github.com/php/php-src/blob/master/ext/gd/libgd/gd_gif_out.c#L336,
line 336:
B |= (Resolution - 1) << 5;
Should be:
B |= (Resolution - 1) << 4;
This bug was fixed in the original libgd:
https://github.com/libgd/libgd/commit/db10f301fff50d8f65ebbbedb57b79433c2dc8a3
But still presents in PHP version of GD
Test script:
---------------
<?php
$im = imagecreate(3, 3); // 3x3, 9 colors, 4 bits per pixel
for ($x = 0; $x < 3; $x++)
for ($y = 0; $y < 3; $y++)
imagesetpixel($im, $x, $y, imagecolorallocate($im, $x, $y, 0));
ob_start();
imagegif($im);
echo decbin(ord(ob_get_clean()[0xA]));
Expected result:
----------------
Should output "10110011" (1 011 0 011, as Resolution bits and
BitsPerPixel bits should match)
Actual result:
--------------
Outputs "11100011" (1 110 0 011, Resolutions bits are shifted 1 bit
left)
--
Edit bug report at https://bugs.php.net/bug.php?id=79615&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=79615&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=79615&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=79615&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=79615&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=79615&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=79615&r=support
Expected behavior: https://bugs.php.net/fix.php?id=79615&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=79615&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=79615&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=79615&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79615&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=79615&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=79615&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=79615&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=79615&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=79615&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=79615&r=mysqlcfg