summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2003-04-07 19:03:47 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2003-04-07 19:03:47 +0000
commiteb7e53349154a31749cc330c70710cc126b37527 (patch)
tree7d39e2ca1a050b432a4c44050cc11b15523f407d
parent79fd96d31a6ecb1301822b8ee9f3256d51ac242d (diff)
string fixes; ian ok
-rw-r--r--usr.bin/file/apprentice.c13
-rw-r--r--usr.bin/file/fsmagic.c10
2 files changed, 14 insertions, 9 deletions
diff --git a/usr.bin/file/apprentice.c b/usr.bin/file/apprentice.c
index b0595d7f15a..b33062c9e7d 100644
--- a/usr.bin/file/apprentice.c
+++ b/usr.bin/file/apprentice.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: apprentice.c,v 1.16 2003/03/11 21:26:26 ian Exp $ */
+/* $OpenBSD: apprentice.c,v 1.17 2003/04/07 19:03:46 deraadt Exp $ */
/*
* apprentice - make one pass through /etc/magic, learning its secrets.
@@ -44,7 +44,7 @@
#include "file.h"
#ifndef lint
-static char *moduleid = "$OpenBSD: apprentice.c,v 1.16 2003/03/11 21:26:26 ian Exp $";
+static char *moduleid = "$OpenBSD: apprentice.c,v 1.17 2003/04/07 19:03:46 deraadt Exp $";
#endif /* lint */
#define EATAB {while (isascii((unsigned char) *l) && \
@@ -71,10 +71,12 @@ int check; /* non-zero? checking-only run. */
{
char *p, *mfn;
int file_err, errs = -1;
+ size_t len;
maxmagic = MAXMAGIS;
magic = (struct magic *) calloc(maxmagic, sizeof(struct magic));
- mfn = malloc(strlen(fn)+1);
+ len = strlen(fn)+1;
+ mfn = malloc(len);
if (magic == NULL || mfn == NULL) {
warn("malloc");
if (check)
@@ -82,8 +84,9 @@ int check; /* non-zero? checking-only run. */
else
exit(1);
}
- fn = strcpy(mfn, fn); /* ok */
-
+ strlcpy(mfn, fn, len);
+ fn = mfn;
+
while (fn) {
p = strchr(fn, ':');
if (p)
diff --git a/usr.bin/file/fsmagic.c b/usr.bin/file/fsmagic.c
index e47ac48b186..daa27443de0 100644
--- a/usr.bin/file/fsmagic.c
+++ b/usr.bin/file/fsmagic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fsmagic.c,v 1.7 2003/03/11 21:26:26 ian Exp $ */
+/* $OpenBSD: fsmagic.c,v 1.8 2003/04/07 19:03:46 deraadt Exp $ */
/*
* fsmagic - magic based on filesystem info - directory, special files, etc.
@@ -61,7 +61,7 @@
#include "file.h"
#ifndef lint
-static char *moduleid = "$OpenBSD: fsmagic.c,v 1.7 2003/03/11 21:26:26 ian Exp $";
+static char *moduleid = "$OpenBSD: fsmagic.c,v 1.8 2003/04/07 19:03:46 deraadt Exp $";
#endif /* lint */
int
@@ -144,9 +144,11 @@ struct stat *sb;
ckfprintf(stdout, "name too long %s", fn);
return 1;
} else {
- strcpy (buf2, fn); /* ok; take directory part */
+ /* ok; take directory part */
+ strlcpy (buf2, fn, sizeof buf2);
buf2[tmp-fn+1] = '\0';
- strcat (buf2, buf); /* ok; plus (relative) symlink */
+ /* ok; plus (relative) symlink */
+ strlcat (buf2, buf, sizeof buf2);
tmp = buf2;
}
if (stat(tmp, &tstatbuf) < 0) {