summaryrefslogtreecommitdiff
path: root/usr.bin/file/fsmagic.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1999-12-06 00:32:30 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1999-12-06 00:32:30 +0000
commit462fab4c617e05fb8273d4b5d7b937a95e6573ea (patch)
tree40c5565d3e3194b19594722eaa7cfa120ab7657d /usr.bin/file/fsmagic.c
parentef9d64b1fa84974c4f35a8c310958a0696be7f95 (diff)
oflow
Diffstat (limited to 'usr.bin/file/fsmagic.c')
-rw-r--r--usr.bin/file/fsmagic.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/usr.bin/file/fsmagic.c b/usr.bin/file/fsmagic.c
index 706664485a3..b6808a83fdf 100644
--- a/usr.bin/file/fsmagic.c
+++ b/usr.bin/file/fsmagic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fsmagic.c,v 1.4 1998/07/10 15:05:22 mickey Exp $ */
+/* $OpenBSD: fsmagic.c,v 1.5 1999/12/06 00:32:29 deraadt Exp $ */
/*
* fsmagic - magic based on filesystem info - directory, special files, etc.
@@ -53,7 +53,7 @@
#include "file.h"
#ifndef lint
-static char *moduleid = "$OpenBSD: fsmagic.c,v 1.4 1998/07/10 15:05:22 mickey Exp $";
+static char *moduleid = "$OpenBSD: fsmagic.c,v 1.5 1999/12/06 00:32:29 deraadt Exp $";
#endif /* lint */
int
@@ -132,11 +132,13 @@ struct stat *sb;
if ((tmp = strrchr(fn, '/')) == NULL) {
tmp = buf; /* in current directory anyway */
- }
- else {
- strcpy (buf2, fn); /* take directory part */
+ } else if (strlen(fn) + strlen(buf) > sizeof(buf2)-1) {
+ ckfprintf(stdout, "name too long %s", fn);
+ return 1;
+ } else {
+ strcpy (buf2, fn); /* ok; take directory part */
buf2[tmp-fn+1] = '\0';
- strcat (buf2, buf); /* plus (relative) symlink */
+ strcat (buf2, buf); /* ok; plus (relative) symlink */
tmp = buf2;
}
if (stat(tmp, &tstatbuf) < 0) {