summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2006-12-31 22:47:13 +0000
committerIlia Alshanetsky <iliaa@php.net>2006-12-31 22:47:13 +0000
commit6e0af2f4d5e50c08aea349c8bc544314ebfb8421 (patch)
tree041d5f2540ba355e2fadf9f29c73189e7581c105
parentba645539131468b9c5fdc47762f4a4bc744bfbf5 (diff)
downloadphp-git-6e0af2f4d5e50c08aea349c8bc544314ebfb8421.tar.gz
Simplify code and change strchr() to memchr()
-rw-r--r--ext/filter/logical_filters.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/ext/filter/logical_filters.c b/ext/filter/logical_filters.c
index c3dfd00db5..888ffc14c2 100644
--- a/ext/filter/logical_filters.c
+++ b/ext/filter/logical_filters.c
@@ -593,15 +593,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
@@ -617,7 +614,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
}
@@ -647,7 +644,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
}