Bug #79615 [PATCH]: Wrong GIF header written in GD GIFEncode
Edit report at https://bugs.php.net/bug.php?id=79615&edit=1
ID: 79615
Patch added by: sageptr@gmail.com
Reported by: sageptr at gmail dot com
Summary: Wrong GIF header written in GD GIFEncode
Status: Open
Type: Bug
Package: GD related
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
The following patch has been added/updated:
Patch Name: gd_gif_out.c.patch
Revision: 1589981521
URL: https://bugs.php.net/patch-display.php?bug=79615&patch=gd_gif_out.c.patch&revision=1589981521
Previous Comments:
------------------------------------------------------------------------
[2020-05-20 13:31:46] sageptr at gmail dot com
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 this bug report at https://bugs.php.net/bug.php?id=79615&edit=1
Thread (3 messages)