summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlum <lum@openbsd.org>2014-03-14 10:02:52 +0000
committerlum <lum@openbsd.org>2014-03-14 10:02:52 +0000
commit859bb9301371fccb8f5b032f58ac6bc2f3188c8d (patch)
tree20250ad488cd99f23ef038db56475962e8a2b9a8
parentbetter wording; (diff)
downloadwireguard-openbsd-859bb9301371fccb8f5b032f58ac6bc2f3188c8d.tar.xz
wireguard-openbsd-859bb9301371fccb8f5b032f58ac6bc2f3188c8d.zip
Check if buffer is to be saved as a directory.
ok florian@
-rw-r--r--usr.bin/mg/file.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/usr.bin/mg/file.c b/usr.bin/mg/file.c
index eb5639fbe85..8e0fa6a3130 100644
--- a/usr.bin/mg/file.c
+++ b/usr.bin/mg/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.90 2013/12/23 14:58:16 lum Exp $ */
+/* $OpenBSD: file.c,v 1.91 2014/03/14 10:02:52 lum Exp $ */
/* This file is in the public domain. */
@@ -506,6 +506,11 @@ filewrite(int f, int n)
/* Check if file exists; write checks done later */
if (stat(adjfname, &statbuf) == 0) {
+ if (S_ISDIR(statbuf.st_mode)) {
+ dobeep();
+ ewprintf("%s is a directory", adjfname);
+ return (FALSE);
+ }
snprintf(tmp, sizeof(tmp), "File `%s' exists; overwrite",
adjfname);
if ((s = eyorn(tmp)) != TRUE)