diff options
author | Mark Lumsden <lum@cvs.openbsd.org> | 2014-03-14 10:02:53 +0000 |
---|---|---|
committer | Mark Lumsden <lum@cvs.openbsd.org> | 2014-03-14 10:02:53 +0000 |
commit | 7a879613fad574bd039d8a58f19782ac9a16f120 (patch) | |
tree | 7fb17a654dc4104db43c73b1002dd97cffc520e6 /usr.bin | |
parent | ea8a1ec72241f4598e1ced7af2c3dad797099a9e (diff) |
Check if buffer is to be saved as a directory.
ok florian@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/mg/file.c | 7 |
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) |