summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2015-04-24 16:28:00 +0000
committernicm <nicm@openbsd.org>2015-04-24 16:28:00 +0000
commit77f7cfb7d002f7b91042f74c12599e206921ddab (patch)
tree3392d8e2046970d496209e562a86d8e2dd125c89
parentFix a couple of errors in the magic source files. (diff)
downloadwireguard-openbsd-77f7cfb7d002f7b91042f74c12599e206921ddab.tar.xz
wireguard-openbsd-77f7cfb7d002f7b91042f74c12599e206921ddab.zip
If ~/.magic exists but can't be used, fail rather than silently falling
back to /etc/magic.
-rw-r--r--usr.bin/file/file.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/usr.bin/file/file.c b/usr.bin/file/file.c
index d83a1f4515f..8165f6188b4 100644
--- a/usr.bin/file/file.c
+++ b/usr.bin/file/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.27 2015/04/24 16:24:11 nicm Exp $ */
+/* $OpenBSD: file.c,v 1.28 2015/04/24 16:28:00 nicm Exp $ */
/*
* Copyright (c) 2015 Nicholas Marriott <nicm@openbsd.org>
@@ -154,6 +154,10 @@ main(int argc, char **argv)
if (home != NULL) {
xasprintf(&path, "%s/.magic", home);
f = fopen(path, "r");
+ if (f == NULL && errno != ENOENT)
+ err(1, "%s", path);
+ if (f == NULL)
+ free(path);
} else
f = NULL;
if (f == NULL) {