[php-src] master: Merge branch 'PHP-8.6'
| From: | Daniel Scherzer | Date: | Wed, 30 Sep 2026 01:00:56 +0000 |
| Subject: | [php-src] master: Merge branch 'PHP-8.6' | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-141751@lists.php.net to get a copy of this message | ||
Author: Daniel Scherzer (DanielEScherzer)
Date: 2026-09-29T18:00:09-07:00
Commit: https://github.com/php/php-src/commit/c04004b18f487fb8256ec2520de49095ee1d2668
Raw diff: https://github.com/php/php-src/commit/c04004b18f487fb8256ec2520de49095ee1d2668.diff
Merge branch 'PHP-8.6'
* PHP-8.6:
NEWS
ext/gd: fix undefined behavior with GIFs with problematic LZW compression data
Changed paths:
A ext/gd/tests/gif-oob.phpt
Diff:
diff --git a/ext/gd/tests/gif-oob.phpt b/ext/gd/tests/gif-oob.phpt
new file mode 100644
index 000000000000..73fd0427c8e8
--- /dev/null
+++ b/ext/gd/tests/gif-oob.phpt
@@ -0,0 +1,63 @@
+--TEST--
+GIF OOB array access when using code size of 12
+--EXTENSIONS--
+gd
+--FILE--
+<?php
+
+$fileHeaderParts = [
+ "signature" => "GIF",
+ "version" => "89a",
+];
+$fileHeader = implode("", $fileHeaderParts);
+
+$logicalScreenDescriptorParts = [
+ // little-endian format
+ "width" => "\x04\x00",
+ "height" => "\x04\x00",
+ // packed data: global color table flag (most significant bit),
+ // color resolution (3 bits, only meaningful if global color table is enabled
+ // and we don't enable it here)
+ // sort flag (one bit, again only meaningful if global color table is enabled)
+ // size of global color table (3 bits)
+ "packed_info" => "\x00",
+ "background_color_index" => "\x00",
+ "pixel_aspect_ratio" => "\x00",
+];
+$logicalScreenDescriptor = implode("", $logicalScreenDescriptorParts);
+
+$startImage = ",";
+
+$imgDescParts = [
+ // little-ending format
+ "left" => "\x00\x00",
+ "top" => "\x00\x00",
+ "width" => "\x04\x00",
+ "height" => "\x04\x00",
+ // more packed data: local color table flag, interlace flag, sort flag,
+ // 2 bits reserved for future use, then 3 bits for size of local color
+ // table, which we don't have
+ "packed_info" => "\x00",
+];
+$imgDesc = implode("", $imgDescParts);
+
+$imgDataParts = [
+ "lzw_min_code_size" => "\x0c", // 12
+ "sub_block_num_bytes" => "\x05",
+ // Data in the block: 3 12-bit codes, and then 4 trailing 0 bits
+ "sub_block_bytes" => "\xff\x5f\x00\x06\x40",
+ // end of data
+ "end" => "\x00"
+];
+$imgData = implode("", $imgDataParts);
+
+$trailer = ";";
+
+$source = $fileHeader . $logicalScreenDescriptor . $startImage . $imgDesc . $imgData . $trailer;
+$img = imagecreatefromstring($source);
+var_dump($img);
+
+?>
+--EXPECTF--
+object(GdImage)#%d (0) {
+}