diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2012-10-08 20:11:40 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2012-10-09 11:09:34 +0200 |
commit | ec56d1d4537cdc165abd6aaeb32ed43197fc63e0 (patch) | |
tree | 5b1590544aa23319b67615cc0ad9c1c8607c887b | |
parent | 87036839f93dc7211acee98033f15bdbc20631da (diff) | |
download | libssh-ec56d1d4537cdc165abd6aaeb32ed43197fc63e0.tar.gz libssh-ec56d1d4537cdc165abd6aaeb32ed43197fc63e0.tar.xz libssh-ec56d1d4537cdc165abd6aaeb32ed43197fc63e0.zip |
match: Don't dereference 's' directly.
Found by Coverity.
-rw-r--r-- | src/match.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/match.c b/src/match.c index 98adf67..53620bd 100644 --- a/src/match.c +++ b/src/match.c @@ -46,10 +46,14 @@ * and * as wildcards), and zero if it does not match. */ static int match_pattern(const char *s, const char *pattern) { + if (s == NULL || pattern == NULL) { + return 0; + } + for (;;) { /* If at end of pattern, accept if also at end of string. */ - if (!*pattern) { - return !*s; + if (*pattern == '\0') { + return (*s == '\0'); } if (*pattern == '*') { |