[php-src] PR #16782: Simplify WBMP imagecreatefromstring() detection

From: Date: Wed, 13 Nov 2024 14:46:11 +0000
Subject: [php-src] PR #16782: Simplify WBMP imagecreatefromstring() detection
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-29622@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/16782 Author: cmb69 According to the WBMP specification[1], the first field (type) of a WBMP is a multi-byte integer, but only type 0 is supported. Thus there is no need to read a multi-byte integer. The second field (fix header) is a single byte; reading a multi-byte integer is not really wrong, since the fix header field is laid out in a way which allows it to be treated as such, but the check whether the MBI is greater than or equal to zero is pretty useless, because negative values could only be returned if overflow occurs (MBIs are unsigned). So the only useful assumption we can make is that the first byte is zero; we let gdImageCreateFromWBMPCtx() figure out the rest. [1] <https://www.wapforum.org/what/technical/SPEC-WAESpec-19990524.pdf> section 6 --- At first I wanted to use [src.wbmp](https://github.com/php/php-src/blob/master/ext/gd/tests/src.wbmp) for the test but it failed due to https://github.com/php/php-src/blob/b948332779efbee744ce56df2ddac3010cd35f45/ext/gd/gd.c#L1386-L1389 src.wbmp is only 9 bytes. We could fix this, but I don't think it's worth it, because such small WBMPs likely don't exist in practice (and even larger WBMPs likely are no longer relevant).

« previous php.git-pulls (#29622) next »