summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Stoeckmann <tobias@cvs.openbsd.org>2015-11-15 22:11:19 +0000
committerTobias Stoeckmann <tobias@cvs.openbsd.org>2015-11-15 22:11:19 +0000
commit04164bdcb675e288bde0d3c8eeb6c3d48b246e45 (patch)
tree83e2e3b8d4d74ecce03f8aec939d3ebe2fe490b9
parenta04cd6bee53c97bd0e78e6f63197bb6c2b4ba6b5 (diff)
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;
}