Skip to content

Commit

Permalink
Fix signedness confusion in php_filter_validate_domain()
Browse files Browse the repository at this point in the history
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/>.
  • Loading branch information
cmb69 committed Mar 28, 2022
1 parent aa352c2 commit 771dbdb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions NEWS
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion ext/filter/logical_filters.c
Expand Up @@ -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;
Expand Down

0 comments on commit 771dbdb

Please sign in to comment.