summaryrefslogtreecommitdiffstats
path: root/gnu/usr.bin/dc
diff options
context:
space:
mode:
authorsteve <steve@FreeBSD.org>1996-11-03 03:31:33 +0000
committersteve <steve@FreeBSD.org>1996-11-03 03:31:33 +0000
commit01addb2f214a309e6c43ef36e4dc052842d02191 (patch)
treee844409cbaeb67115579b5d217765e6e2b4399eb /gnu/usr.bin/dc
parente0d5709e9072c365ddf81df4c993a04ac14519ab (diff)
downloadFreeBSD-src-01addb2f214a309e6c43ef36e4dc052842d02191.zip
FreeBSD-src-01addb2f214a309e6c43ef36e4dc052842d02191.tar.gz
Don't allow filenames specified on the commandline
to be directories.
Diffstat (limited to 'gnu/usr.bin/dc')
-rw-r--r--gnu/usr.bin/dc/dc.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/gnu/usr.bin/dc/dc.c b/gnu/usr.bin/dc/dc.c
index a413253..4e62246 100644
--- a/gnu/usr.bin/dc/dc.c
+++ b/gnu/usr.bin/dc/dc.c
@@ -19,6 +19,7 @@
* Inc.; 675 Mass Ave. Cambridge, MA 02139, USA.
*/
+#include <sys/stat.h>
#include <stdio.h>
#include "decimal.h" /* definitions for our decimal arithmetic package */
@@ -508,10 +509,16 @@ fetch()
}
else if (file_count)
{
- open_file = fopen (*next_file++, "r");
+ struct stat stat_buf;
file_count--;
+ if (stat(*next_file, &stat_buf) == 0) && !S_ISDIR(stat_buf.st_mode))
+ {
+ open_file = fopen (*next_file++, "r");
if (!open_file)
perror_with_name (*(next_file - 1));
+ }
+ else
+ next_file++;
}
else break;
}
OpenPOWER on IntegriCloud