Skip to content

Commit

Permalink
gd imageloadfont, verify error while reading header
Browse files Browse the repository at this point in the history
when reading the header verify we get an error when the header is
invalid.

Signed-off-by: BlackEagle <ike.devolder@gmail.com>
  • Loading branch information
BlackIkeEagle authored and petk committed Feb 19, 2019
1 parent 5bbf0c6 commit a8336fb
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ext/gd/tests/imageloadfont_end_of_file_while_reading_header.phpt
Expand Up @@ -10,11 +10,19 @@ if (!extension_loaded('gd')) die("skip gd extension not available\n");
--FILE--
<?php
$filename = dirname(__FILE__) . '/font.gdf';

// End of file while reading header
$bin = "\x41\x41\x41\x41\x00\x00\x00\x00\x00\x00";
$fp = fopen($filename, 'wb');
fwrite($fp, $bin);
fclose($fp);
$font = imageloadfont($filename);

// Error while reading header
$bin = "\xe0\x00\x00\x00\x20\x00\x00\x00\x06\x00\x00\x00\x0a\x00\x00";
$fp = fopen($filename, 'wb');
fwrite($fp, $bin);
fclose($fp);
$font = imageloadfont($filename);
?>
--CLEAN--
Expand All @@ -23,3 +31,5 @@ unlink(__DIR__.'/font.gdf');
?>
--EXPECTF--
Warning: imageloadfont(): End of file while reading header in %s on line %d

Warning: imageloadfont(): End of file while reading header in %s on line %d

0 comments on commit a8336fb

Please sign in to comment.