summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorratchov <ratchov@openbsd.org>2016-01-09 10:06:57 +0000
committerratchov <ratchov@openbsd.org>2016-01-09 10:06:57 +0000
commitc0625b96e7efe0591be0e19df04d5d3e18c20f2a (patch)
treec8157f3fcb87dd0527cd5221393dddba468517ae
parentdo not install filter_api.3 until the names are changed, to avoid namespace (diff)
downloadwireguard-openbsd-c0625b96e7efe0591be0e19df04d5d3e18c20f2a.tar.xz
wireguard-openbsd-c0625b96e7efe0591be0e19df04d5d3e18c20f2a.zip
Check in advance that the socket path is a directory and report the
error if it isn't. Fixes ugly/delayed error messages in this case.
-rw-r--r--usr.bin/sndiod/sndiod.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/usr.bin/sndiod/sndiod.c b/usr.bin/sndiod/sndiod.c
index f513e1cb973..2d0f1cafdd2 100644
--- a/usr.bin/sndiod/sndiod.c
+++ b/usr.bin/sndiod/sndiod.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sndiod.c,v 1.29 2016/01/09 08:57:34 ratchov Exp $ */
+/* $OpenBSD: sndiod.c,v 1.30 2016/01/09 10:06:57 ratchov Exp $ */
/*
* Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org>
*
@@ -281,6 +281,8 @@ getbasepath(char *base, size_t size)
umask(omask);
if (stat(base, &sb) < 0)
err(1, "stat(\"%s\")", base);
+ if (!S_ISDIR(sb.st_mode))
+ errx(1, "%s is not a directory", base);
if (sb.st_uid != uid || (sb.st_mode & mask) != 0)
errx(1, "%s has wrong permissions", base);
}