mirror of
https://github.com/php/php-src.git
synced 2025-01-21 11:13:38 +08:00
ed6dee9a19
We have to ensure that `sscanf()` does indeed read a hex value here, and bail out otherwise.
27 lines
777 B
PHP
27 lines
777 B
PHP
--TEST--
|
|
Bug #77973 (Uninitialized read in gdImageCreateFromXbm)
|
|
--SKIPIF--
|
|
<?php
|
|
if (!extension_loaded('gd')) die("skip gd extension not available");
|
|
if (!function_exists('imagecreatefromxbm')) die("skip imagecreatefromxbm not available");
|
|
?>
|
|
--FILE--
|
|
<?php
|
|
$contents = hex2bin("23646566696e6520776964746820320a23646566696e652068656967687420320a737461746963206368617220626974735b5d203d7b0a7a7a787a7a");
|
|
$filepath = __DIR__ . '/bug77973.xbm';
|
|
file_put_contents($filepath, $contents);
|
|
$im = imagecreatefromxbm($filepath);
|
|
var_dump($im);
|
|
?>
|
|
===DONE===
|
|
--EXPECTF--
|
|
Warning: imagecreatefromxbm(): invalid XBM in %s on line %d
|
|
|
|
Warning: imagecreatefromxbm(): '%s' is not a valid XBM file in %s on line %d
|
|
bool(false)
|
|
===DONE===
|
|
--CLEAN--
|
|
<?php
|
|
unlink(__DIR__ . '/bug77973.xbm');
|
|
?>
|