From 0661d03ebaab6cf1eff156a4dd203299d0385ae9 Mon Sep 17 00:00:00 2001 From: Martin Jansen Date: Fri, 28 Dec 2012 15:20:19 +0100 Subject: [PATCH] There is no need to use memchr() for comparisons in these places. --- ext/filter/logical_filters.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ext/filter/logical_filters.c b/ext/filter/logical_filters.c index 52d948b188..fededcf715 100644 --- a/ext/filter/logical_filters.c +++ b/ext/filter/logical_filters.c @@ -799,12 +799,12 @@ void php_filter_validate_mac(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ tokens = 3; length = 4; separator = '.'; - } else if (17 == input_len && memchr(input + 2, '-', 1)) { + } else if (17 == input_len && input[2] == '-') { /* IEEE 802 format: Six hexadecimal digits separated by hyphens. */ tokens = 6; length = 2; separator = '-'; - } else if (17 == input_len && memchr(input + 2, ':', 1)) { + } else if (17 == input_len && input[2] == ':') { /* IEEE 802 format: Six hexadecimal digits separated by colons. */ tokens = 6; length = 2; @@ -820,7 +820,7 @@ void php_filter_validate_mac(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ for (i = 0; i < tokens; i++) { offset = i * (length + 1); - if (i < tokens - 1 && !memchr(input + offset + length, separator, 1)) { + if (i < tokens - 1 && input[offset + length] != separator) { /* The current token did not end with e.g. a "." */ RETURN_VALIDATION_FAILED } -- 2.40.0