diff options
author | Ilia Alshanetsky <iliaa@php.net> | 2006-12-31 22:47:27 +0000 |
---|---|---|
committer | Ilia Alshanetsky <iliaa@php.net> | 2006-12-31 22:47:27 +0000 |
commit | 3e654e4d53b37dc96d0c6dd86b5bb49ec06d2981 (patch) | |
tree | 024643d3fa7500aa23ea9ff1b86baa3c9d2d8dcd | |
parent | 15f16925728dd6e43ab718ceb9e58c0eb60aa132 (diff) | |
download | php-git-3e654e4d53b37dc96d0c6dd86b5bb49ec06d2981.tar.gz |
MFB: Simplify code and change strchr() to memchr()
-rw-r--r-- | ext/filter/logical_filters.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/ext/filter/logical_filters.c b/ext/filter/logical_filters.c index 988337aa29..43756b1449 100644 --- a/ext/filter/logical_filters.c +++ b/ext/filter/logical_filters.c @@ -597,15 +597,12 @@ void php_filter_validate_ip(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ * allow_ipv4 and allow_ipv6 flags flag are used, then the first dot or * colon determine the format */ - char *str = NULL; int ip[4]; int mode; - str = Z_STRVAL_P(value); - - if (strchr(str, ':')) { + if (memchr(Z_STRVAL_P(value), ':', Z_STRLEN_P(value))) { mode = FORMAT_IPV6; - } else if (strchr(str, '.')) { + } else if (memchr(Z_STRVAL_P(value), '.', Z_STRLEN_P(value))) { mode = FORMAT_IPV4; } else { RETURN_VALIDATION_FAILED @@ -621,7 +618,7 @@ void php_filter_validate_ip(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ switch (mode) { case FORMAT_IPV4: - if (!_php_filter_validate_ipv4(str, Z_STRLEN_P(value), ip)) { + if (!_php_filter_validate_ipv4(Z_STRVAL_P(value), Z_STRLEN_P(value), ip)) { RETURN_VALIDATION_FAILED } @@ -651,7 +648,7 @@ void php_filter_validate_ip(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ case FORMAT_IPV6: { int res = 0; - res = _php_filter_validate_ipv6(str, Z_STRLEN_P(value) TSRMLS_CC); + res = _php_filter_validate_ipv6(Z_STRVAL_P(value), Z_STRLEN_P(value) TSRMLS_CC); if (res < 1) { RETURN_VALIDATION_FAILED } |