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