diff options
Diffstat (limited to 'sys/cam/cam.c')
| -rw-r--r-- | sys/cam/cam.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/sys/cam/cam.c b/sys/cam/cam.c index 946d4ec590a6..9fef3b6114d9 100644 --- a/sys/cam/cam.c +++ b/sys/cam/cam.c @@ -240,24 +240,29 @@ cam_strmatch(const u_int8_t *str, const u_int8_t *pattern, int str_len) ok = 0; sc = *str++; str_len--; + pattern++; if ((negate_range = (*pattern == '^')) != 0) pattern++; - while (((pc = *pattern) != ']') && *pattern != '\0') { - pattern++; + while ((*pattern != ']') && *pattern != '\0') { if (*pattern == '-') { if (pattern[1] == '\0') /* Bad pattern */ return (1); if (sc >= pc && sc <= pattern[1]) ok = 1; - pattern += 2; - } else if (pc == sc) + pattern++; + } else if (*pattern == sc) ok = 1; + pc = *pattern; + pattern++; } if (ok == negate_range) return (1); + pattern++; } else if (*pattern == '?') { - /* NB: || *str == ' ' of the old code is a bug and was removed */ - /* if you add it back, keep this the last if before the naked else */ + /* + * NB: || *str == ' ' of the old code is a bug and was + * removed. If you add it back, keep this the last if + * before the naked else */ pattern++; str++; str_len--; @@ -269,6 +274,17 @@ cam_strmatch(const u_int8_t *str, const u_int8_t *pattern, int str_len) str_len--; } } + + /* '*' is allowed to match nothing, so gobble it */ + while (*pattern == '*') + pattern++; + + if ( *pattern != '\0') { + /* Pattern not fully consumed. Not a match */ + return (1); + } + + /* Eat trailing spaces, which get added by SAT */ while (str_len > 0 && *str == ' ') { str++; str_len--; |
