]> granicus.if.org Git - php/commitdiff
There is no need to use memchr() for comparisons in these places.
authorMartin Jansen <martin@divbyzero.net>
Fri, 28 Dec 2012 14:20:19 +0000 (15:20 +0100)
committerMartin Jansen <martin@divbyzero.net>
Sun, 3 Feb 2013 12:23:53 +0000 (13:23 +0100)
ext/filter/logical_filters.c

index 52d948b1889674966d465fa17966b0b7bad982ba..fededcf715b14c4cd90df137d076b2aacd57929d 100644 (file)
@@ -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
                }