php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79615 Wrong GIF header written in GD GIFEncode
Submitted: 2020-05-20 13:31 UTC Modified: 2020-05-20 14:07 UTC
From: sageptr at gmail dot com Assigned: cmb (profile)
Status: Closed Package: GD related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2020-05-20 13:31 UTC] 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)

Patches

gd_gif_out.c.patch (last revision 2020-05-20 13:32 UTC by sageptr at gmail dot com)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-05-20 13:32 UTC] sageptr at gmail dot com
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
 [2020-05-20 14:07 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 [2020-05-22 07:23 UTC] cmb@php.net
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=d4bd6fb491ccaf70006d6f671755126b47a71bcb
Log: Fix #79615: Wrong GIF header written in GD GIFEncode
 [2020-05-22 07:23 UTC] cmb@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 15:01:29 2024 UTC