summaryrefslogtreecommitdiffstats
path: root/usr.bin/file/apprentice.c
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2003-04-07 19:03:46 +0000
committerderaadt <deraadt@openbsd.org>2003-04-07 19:03:46 +0000
commitf85069a28a9c53394ea38eff33fa53f85f2f9d49 (patch)
tree26f722537fc7e869cd81f1923773a1dd1bf9d793 /usr.bin/file/apprentice.c
parentXr to strlcpy and strlcat more; ok millert (diff)
downloadwireguard-openbsd-f85069a28a9c53394ea38eff33fa53f85f2f9d49.tar.xz
wireguard-openbsd-f85069a28a9c53394ea38eff33fa53f85f2f9d49.zip
string fixes; ian ok
Diffstat (limited to 'usr.bin/file/apprentice.c')
-rw-r--r--usr.bin/file/apprentice.c13
1 files changed, 8 insertions, 5 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)