[php-src] PR #15231: imageloadfont: Fix font loading in opposite endianness format
| From: | thg2k | Date: | Sun, 04 Aug 2024 16:41:26 +0000 |
| Subject: | [php-src] PR #15231: imageloadfont: Fix font loading in opposite endianness format | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-27653@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/15231
Author: thg2k
The ability to load fonts of the opposite endianness used to work until php 7.4.0 due to commit
88b603768f8e5074ad5cbdccc1e0779089fac9d0. The same commit introduced a vulnerability due to a
missing overflow check that was fixed later in commit d50532be91f054ef9beb1afca2ea94f4a70f7c4d, but
the feature remains broken due to the early overflow check.
Furthermore, the initial implementation was missing the conversion (
FLIPWORD macro) for
the offset field, thus only fonts with zero offset (starting character) could be loaded correctly.
Note that the missed conversion of the offset endianness is not exploitable as there is no way to
craft a font that passes the overflow checks before and after the endianness swapping.
This patch fixes the functionality in a secure way, by guessing the endianness based on the number
of characters (typically 256), and then performing the overflow check.