summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwiz <wiz@NetBSD.org>2003-10-04 00:50:34 +0000
committerwiz <wiz@NetBSD.org>2003-10-04 00:50:34 +0000
commitc87a7072e85ae63d7e0731daf8d6b63174c19d96 (patch)
treecbce2b3e1710505863f0fa389162f29d4a6514e7
parentc4beb9648d466004a5413cce893a7116cb3324e0 (diff)
Replace strnncpy calls with strlcpy calls. Remove strnncpy.
Ok'ed by agc and hubertf. Verified working with editors/mule package.
-rw-r--r--usr.sbin/pkg_install/create/pl.c8
-rw-r--r--usr.sbin/pkg_install/lib/file.c13
-rw-r--r--usr.sbin/pkg_install/lib/lib.h3
-rw-r--r--usr.sbin/pkg_install/lib/str.c20
4 files changed, 14 insertions, 30 deletions
diff --git a/usr.sbin/pkg_install/create/pl.c b/usr.sbin/pkg_install/create/pl.c
index 6f0993a3cb8..c1042b43f1e 100644
--- a/usr.sbin/pkg_install/create/pl.c
+++ b/usr.sbin/pkg_install/create/pl.c
@@ -1,11 +1,11 @@
-/* $NetBSD: pl.c,v 1.28 2003/09/02 07:34:54 jlam Exp $ */
+/* $NetBSD: pl.c,v 1.29 2003/10/04 00:50:34 wiz Exp $ */
#include <sys/cdefs.h>
#ifndef lint
#if 0
static const char *rcsid = "from FreeBSD Id: pl.c,v 1.11 1997/10/08 07:46:35 charnier Exp";
#else
-__RCSID("$NetBSD: pl.c,v 1.28 2003/09/02 07:34:54 jlam Exp $");
+__RCSID("$NetBSD: pl.c,v 1.29 2003/10/04 00:50:34 wiz Exp $");
#endif
#endif
@@ -53,10 +53,10 @@ CheckSymlink(char *name, char *prefix, size_t prefixcc)
for (slashc = 0, slash = &name[prefixcc + 1]; (slash = strchr(slash, '/')) != (char *) NULL; slash++, slashc++) {
}
for (cc = i = 0; i < slashc; i++) {
- strnncpy(&newtgt[cc], sizeof(newtgt) - cc, "../", 3);
+ strlcpy(&newtgt[cc], "../", sizeof(newtgt) - cc);
cc += 3;
}
- strnncpy(&newtgt[cc], sizeof(newtgt) - cc, &oldtgt[prefixcc + 1], strlen(&oldtgt[prefixcc + 1]));
+ strlcpy(&newtgt[cc], &oldtgt[prefixcc + 1], sizeof(newtgt) - cc);
(void) fprintf(stderr, "Full pathname symlink `%s' is target of `%s' - adjusting to `%s'\n", oldtgt, name, newtgt);
if (unlink(name) != 0) {
warn("can't unlink `%s'", name);
diff --git a/usr.sbin/pkg_install/lib/file.c b/usr.sbin/pkg_install/lib/file.c
index 43b5a7aa5d0..94a40e34f3e 100644
--- a/usr.sbin/pkg_install/lib/file.c
+++ b/usr.sbin/pkg_install/lib/file.c
@@ -1,11 +1,11 @@
-/* $NetBSD: file.c,v 1.67 2003/09/23 14:55:01 wiz Exp $ */
+/* $NetBSD: file.c,v 1.68 2003/10/04 00:50:34 wiz Exp $ */
#include <sys/cdefs.h>
#ifndef lint
#if 0
static const char *rcsid = "from FreeBSD Id: file.c,v 1.29 1997/10/08 07:47:54 charnier Exp";
#else
-__RCSID("$NetBSD: file.c,v 1.67 2003/09/23 14:55:01 wiz Exp $");
+__RCSID("$NetBSD: file.c,v 1.68 2003/10/04 00:50:34 wiz Exp $");
#endif
#endif
@@ -678,12 +678,12 @@ format_cmd(char *buf, size_t size, char *fmt, char *dir, char *name)
}
switch (*fmt) {
case 'F':
- strnncpy(bufp, size - (int) (bufp - buf), name, strlen(name));
+ strlcpy(bufp, name, size - (int) (bufp - buf));
bufp += strlen(bufp);
break;
case 'D':
- strnncpy(bufp, size - (int) (bufp - buf), dir, strlen(dir));
+ strlcpy(bufp, dir, size - (int) (bufp - buf));
bufp += strlen(bufp);
break;
@@ -692,7 +692,8 @@ format_cmd(char *buf, size_t size, char *fmt, char *dir, char *name)
if ((cp = strrchr(scratch, '/')) == (char *) NULL) {
cp = scratch;
}
- strnncpy(bufp, size - (int) (bufp - buf), scratch, (size_t) (cp - scratch));
+ *cp = '\0';
+ strlcpy(bufp, scratch, size - (int) (bufp - buf));
bufp += strlen(bufp);
break;
@@ -703,7 +704,7 @@ format_cmd(char *buf, size_t size, char *fmt, char *dir, char *name)
} else {
cp++;
}
- strnncpy(bufp, size - (int) (bufp - buf), cp, strlen(cp));
+ strlcpy(bufp, cp, size - (int) (bufp - buf));
bufp += strlen(bufp);
break;
diff --git a/usr.sbin/pkg_install/lib/lib.h b/usr.sbin/pkg_install/lib/lib.h
index 7b32aeddb95..bc4e2e1c4e4 100644
--- a/usr.sbin/pkg_install/lib/lib.h
+++ b/usr.sbin/pkg_install/lib/lib.h
@@ -1,4 +1,4 @@
-/* $NetBSD: lib.h,v 1.62 2003/10/03 15:40:27 wiz Exp $ */
+/* $NetBSD: lib.h,v 1.63 2003/10/04 00:50:34 wiz Exp $ */
/* from FreeBSD Id: lib.h,v 1.25 1997/10/08 07:48:03 charnier Exp */
@@ -222,7 +222,6 @@ int pmatch(const char *, const char *);
int findmatchingname(const char *, const char *, matchfn, void *); /* doesn't really belong to "strings" */
char *findbestmatchingname(const char *, const char *); /* neither */
int ispkgpattern(const char *);
-char *strnncpy(char *, size_t, char *, size_t);
void strip_txz(char *, char *, const char *);
/* callback functions for findmatchingname */
diff --git a/usr.sbin/pkg_install/lib/str.c b/usr.sbin/pkg_install/lib/str.c
index 30804991d24..c11a74ce0d5 100644
--- a/usr.sbin/pkg_install/lib/str.c
+++ b/usr.sbin/pkg_install/lib/str.c
@@ -1,11 +1,11 @@
-/* $NetBSD: str.c,v 1.45 2003/09/09 08:22:39 jlam Exp $ */
+/* $NetBSD: str.c,v 1.46 2003/10/04 00:50:34 wiz Exp $ */
#include <sys/cdefs.h>
#ifndef lint
#if 0
static const char *rcsid = "Id: str.c,v 1.5 1997/10/08 07:48:21 charnier Exp";
#else
-__RCSID("$NetBSD: str.c,v 1.45 2003/09/09 08:22:39 jlam Exp $");
+__RCSID("$NetBSD: str.c,v 1.46 2003/10/04 00:50:34 wiz Exp $");
#endif
#endif
@@ -564,22 +564,6 @@ findbestmatchingname(const char *dir, const char *pattern)
}
/*
- * Bounds-checking strncpy()
- */
-char *
-strnncpy(char *to, size_t tosize, char *from, size_t cc)
-{
- size_t len;
-
- if ((len = cc) >= tosize - 1) {
- len = tosize - 1;
- }
- (void) strncpy(to, from, len);
- to[len] = 0;
- return to;
-}
-
-/*
* Strip off any .tgz, .tbz or .t[bg]z suffix from fname,
* and copy into buffer "buf", the suffix is stored in "sfx"
* if "sfx" is not NULL. If no suffix is found, "sfx" is set