xref: /PHP-8.0/ext/gd/tests/bug81739.phpt (revision d50532be)
1--TEST--
2Bug #81739 (OOB read due to insufficient validation in imageloadfont())
3--SKIPIF--
4<?php
5if (!extension_loaded("gd")) die("skip gd extension not available");
6?>
7--FILE--
8<?php
9$s = fopen(__DIR__ . "/font.font", "w");
10// header without character data
11fwrite($s, "\x01\x00\x00\x00\x20\x00\x00\x00\x08\x00\x00\x00\x08\x00\x00\x00");
12fclose($s);
13var_dump(imageloadfont(__DIR__ . "/font.font"));
14?>
15--CLEAN--
16<?php
17@unlink(__DIR__ . "/font.font");
18?>
19--EXPECTF--
20Warning: imageloadfont(): %croduct of memory allocation multiplication would exceed INT_MAX, failing operation gracefully
21 in %s on line %d
22
23Warning: imageloadfont(): Error reading font, invalid font header in %s on line %d
24bool(false)