Fix signedness confusion in php_filter_validate_domain()

As is, there is the possibility that integer underflow occurs, making
`_php_filter_validate_domain()` succeed for very long domain names.

Cf. <https://pwning.systems/posts/php_filter_var_shenanigans/>.
This commit is contained in:
Christoph M. Becker 2022-03-28 11:26:17 +02:00
parent aa352c2c54
commit 771dbdb319
No known key found for this signature in database
GPG key ID: D66C9593118BCCB6
2 changed files with 4 additions and 1 deletions

3
NEWS
View file

@ -8,6 +8,9 @@ PHP NEWS
(Tim Düsterhus)
. Fixed bug GH-8160 (ZTS support on Alpine is broken). (Michael Voříšek)
- Filter:
. Fixed signedness confusion in php_filter_validate_domain(). (cmb)
- Intl:
. Fixed bug GH-8142 (Compilation error on cygwin). (David Carlier)

View file

@ -496,7 +496,7 @@ void php_filter_validate_regexp(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
}
}
static int _php_filter_validate_domain(char * domain, int len, zend_long flags) /* {{{ */
static int _php_filter_validate_domain(char * domain, size_t len, zend_long flags) /* {{{ */
{
char *e, *s, *t;
size_t l;