summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortobias <tobias@openbsd.org>2015-11-15 22:11:18 +0000
committertobias <tobias@openbsd.org>2015-11-15 22:11:18 +0000
commit34cca5481efe22676a2dfb6b66824ee8f84f29e6 (patch)
tree9b0c7c260a7e39b47d4bfa0cc63d7ac224374d2c
parentupdate NAME; ok nicm schwarze (diff)
downloadwireguard-openbsd-34cca5481efe22676a2dfb6b66824ee8f84f29e6.tar.xz
wireguard-openbsd-34cca5481efe22676a2dfb6b66824ee8f84f29e6.zip
When validating a char by calling strchr() with a string of allowed chars,
check for '\0' first, because strchr() would return non-NULL. ok nicm
-rw-r--r--usr.bin/file/magic-load.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/usr.bin/file/magic-load.c b/usr.bin/file/magic-load.c
index d45f30b6bd6..4a62f10226f 100644
--- a/usr.bin/file/magic-load.c
+++ b/usr.bin/file/magic-load.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: magic-load.c,v 1.18 2015/10/05 20:05:52 nicm Exp $ */
+/* $OpenBSD: magic-load.c,v 1.19 2015/11/15 22:11:18 tobias Exp $ */
/*
* Copyright (c) 2015 Nicholas Marriott <nicm@openbsd.org>
@@ -871,7 +871,7 @@ magic_parse_value(struct magic_line *ml, char **line)
} else if ((*line)[0] == '>' && (*line)[1] == '=') {
ml->test_operator = ']';
(*line) += 2;
- } else if (strchr("=<>&^", **line) != NULL) {
+ } else if (**line != '\0' && strchr("=<>&^", **line) != NULL) {
ml->test_operator = **line;
(*line)++;
}
@@ -964,7 +964,7 @@ magic_adjust_strength(struct magic *m, u_int at, struct magic_line *ml,
*cp = '\0';
cp = s;
- if (strchr("+-*/", *s) == NULL) {
+ if (*s == '\0' || strchr("+-*/", *s) == NULL) {
magic_warnm(m, at, "invalid strength operator: %s", s);
return;
}