xref: /php-src/ext/gd/tests/gh16232.phpt (revision 54973c93)
1--TEST--
2GH-16232 (Overflow on reading wbmp content)
3--EXTENSIONS--
4gd
5--FILE--
6<?php
7$good_webp = __DIR__ . '/src.wbmp';
8$bad_webp = __DIR__ . "/gh16232.webp";
9copy($good_webp, $bad_webp);
10var_dump(imagecreatefromwbmp($bad_webp));
11$data = file_get_contents($bad_webp);
12$data[3] = chr(-1);
13file_put_contents($bad_webp, $data);
14var_dump(imagecreatefromwbmp($bad_webp));
15$data[3] = chr(1000);
16file_put_contents($bad_webp, $data);
17var_dump(imagecreatefromwbmp($bad_webp));
18unlink($bad_webp);
19--EXPECTF--
20object(GdImage)#1 (0) {
21}
22
23Warning: imagecreatefromwbmp(): "%s" is not a valid WBMP file in %s on line %d
24bool(false)
25
26Warning: imagecreatefromwbmp(): "%s" is not a valid WBMP file in %s on line %d
27bool(false)
28