aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2012-10-08 20:11:40 +0200
committerAndreas Schneider <asn@cryptomilk.org>2012-10-09 11:09:34 +0200
commitec56d1d4537cdc165abd6aaeb32ed43197fc63e0 (patch)
tree5b1590544aa23319b67615cc0ad9c1c8607c887b
parent87036839f93dc7211acee98033f15bdbc20631da (diff)
downloadlibssh-ec56d1d4537cdc165abd6aaeb32ed43197fc63e0.tar.gz
libssh-ec56d1d4537cdc165abd6aaeb32ed43197fc63e0.tar.xz
libssh-ec56d1d4537cdc165abd6aaeb32ed43197fc63e0.zip
match: Don't dereference 's' directly.
Found by Coverity.
-rw-r--r--src/match.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/match.c b/src/match.c
index 98adf67e..53620bdd 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 == '*') {