diff options
author | 2003-04-07 19:03:46 +0000 | |
---|---|---|
committer | 2003-04-07 19:03:46 +0000 | |
commit | f85069a28a9c53394ea38eff33fa53f85f2f9d49 (patch) | |
tree | 26f722537fc7e869cd81f1923773a1dd1bf9d793 | |
parent | Xr to strlcpy and strlcat more; ok millert (diff) | |
download | wireguard-openbsd-f85069a28a9c53394ea38eff33fa53f85f2f9d49.tar.xz wireguard-openbsd-f85069a28a9c53394ea38eff33fa53f85f2f9d49.zip |
string fixes; ian ok
-rw-r--r-- | usr.bin/file/apprentice.c | 13 | ||||
-rw-r--r-- | usr.bin/file/fsmagic.c | 10 |
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) { |