summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnil Madhavapeddy <avsm@cvs.openbsd.org>2003-04-03 19:42:54 +0000
committerAnil Madhavapeddy <avsm@cvs.openbsd.org>2003-04-03 19:42:54 +0000
commitfa9d34f98a333f85c810c3af15e943250405a2a2 (patch)
tree9d9635b1108d00f6add4a71a759930d7122e4d13
parent7d1bac92416230d9ee85e1a890ead0683d0948f6 (diff)
some strcpy/strcat -> strlcpy/strlcat conversions
ok hin@, ho@, millert@
-rw-r--r--usr.sbin/pkg_install/add/extract.c12
-rw-r--r--usr.sbin/pkg_install/add/main.c6
-rw-r--r--usr.sbin/pkg_install/add/perform.c18
3 files changed, 18 insertions, 18 deletions
diff --git a/usr.sbin/pkg_install/add/extract.c b/usr.sbin/pkg_install/add/extract.c
index f51fe8bc50b..43c1d50de66 100644
--- a/usr.sbin/pkg_install/add/extract.c
+++ b/usr.sbin/pkg_install/add/extract.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: extract.c,v 1.12 2001/04/08 16:45:46 espie Exp $ */
+/* $OpenBSD: extract.c,v 1.13 2003/04/03 19:42:53 avsm Exp $ */
#ifndef lint
-static const char *rcsid = "$OpenBSD: extract.c,v 1.12 2001/04/08 16:45:46 espie Exp $";
+static const char *rcsid = "$OpenBSD: extract.c,v 1.13 2003/04/03 19:42:53 avsm Exp $";
#endif
/*
@@ -35,14 +35,14 @@ static const char *rcsid = "$OpenBSD: extract.c,v 1.12 2001/04/08 16:45:46 espie
#define PUSHOUT(todir) /* push out string */ \
if (where_count > sizeof(STARTSTRING)-1) { \
- strcat(where_args, "|tar xpf - -C "); \
- strcat(where_args, todir); \
+ strlcat(where_args, "|tar xpf - -C ", maxargs); \
+ strlcat(where_args, todir, maxargs); \
if (system(where_args)) { \
cleanup(0); \
errx(2, "can not invoke %lu byte tar pipeline: %s", \
(u_long)strlen(where_args), where_args); \
} \
- strcpy(where_args, STARTSTRING); \
+ strlcpy(where_args, STARTSTRING, maxargs); \
where_count = sizeof(STARTSTRING)-1; \
} \
if (perm_count) { \
@@ -114,7 +114,7 @@ extract_plist(char *home, package_t *pkg)
cleanup(0);
errx(2, "can't get argument list space");
}
- strcpy(where_args, STARTSTRING);
+ strlcpy(where_args, STARTSTRING, maxargs);
where_count = sizeof(STARTSTRING)-1;
perm_args[0] = 0;
diff --git a/usr.sbin/pkg_install/add/main.c b/usr.sbin/pkg_install/add/main.c
index b2f1178d740..f1a28b82024 100644
--- a/usr.sbin/pkg_install/add/main.c
+++ b/usr.sbin/pkg_install/add/main.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: main.c,v 1.15 2002/09/08 22:01:50 tdeval Exp $ */
+/* $OpenBSD: main.c,v 1.16 2003/04/03 19:42:53 avsm Exp $ */
#ifndef lint
-static char *rcsid = "$OpenBSD: main.c,v 1.15 2002/09/08 22:01:50 tdeval Exp $";
+static char *rcsid = "$OpenBSD: main.c,v 1.16 2003/04/03 19:42:53 avsm Exp $";
#endif
/*
@@ -85,7 +85,7 @@ main(int argc, char **argv)
break;
case 't':
- strcpy(FirstPen, optarg);
+ strlcpy(FirstPen, optarg, sizeof(FirstPen));
break;
case 'S':
diff --git a/usr.sbin/pkg_install/add/perform.c b/usr.sbin/pkg_install/add/perform.c
index 99937e8b3f9..93ee1c96280 100644
--- a/usr.sbin/pkg_install/add/perform.c
+++ b/usr.sbin/pkg_install/add/perform.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: perform.c,v 1.22 2001/11/26 05:04:33 deraadt Exp $ */
+/* $OpenBSD: perform.c,v 1.23 2003/04/03 19:42:53 avsm Exp $ */
#ifndef lint
-static const char *rcsid = "$OpenBSD: perform.c,v 1.22 2001/11/26 05:04:33 deraadt Exp $";
+static const char *rcsid = "$OpenBSD: perform.c,v 1.23 2003/04/03 19:42:53 avsm Exp $";
#endif
/*
@@ -90,7 +90,7 @@ pkg_do(char *pkg)
code = 0;
zapLogDir = 0;
LogDir[0] = '\0';
- strcpy(playpen, FirstPen);
+ strlcpy(playpen, FirstPen, sizeof(playpen));
dbdir = (tmp = getenv(PKG_DBDIR)) ? tmp : DEF_LOG_DIR;
snprintf(solve_deps, sizeof solve_deps, "pkg%s dependencies solve %s",
@@ -127,7 +127,7 @@ pkg_do(char *pkg)
return 1;
}
where_to = Home;
- strcpy(pkg_fullname, pkg);
+ strlcpy(pkg_fullname, pkg, sizeof(pkg_fullname));
system(solve_deps);
cfile = fopen(CONTENTS_FNAME, "r");
if (!cfile) {
@@ -139,7 +139,7 @@ pkg_do(char *pkg)
read_plist(&Plist, cfile);
fclose(cfile);
} else {
- strlcpy(pkg_fullname, ensure_tgz(pkg), sizeof pkg_fullname);
+ strlcpy(pkg_fullname, ensure_tgz(pkg), sizeof(pkg_fullname));
if (strcmp(pkg, "-")) {
if (!ispkgpattern(pkg_fullname)
&& stat(pkg_fullname, &sb) == FAIL) {
@@ -244,7 +244,7 @@ pkg_do(char *pkg)
char *s;
if ((s=strrchr(PkgName, '-')) != NULL){
- strcpy(buf, PkgName);
+ strlcpy(buf, PkgName, sizeof(buf));
/* try to find a better version number */
if (!isdigit(s[1])) {
char *t;
@@ -254,7 +254,7 @@ pkg_do(char *pkg)
break;
}
}
- strcpy(buf+(s-PkgName+1), isdigit(s[1]) ? "[0-9]*" : "*");
+ strlcpy(buf+(s-PkgName+1), isdigit(s[1]) ? "[0-9]*" : "*", sizeof(buf)-(s-PkgName+1));
if (findmatchingname(dbdir, buf, check_if_installed, installed)) {
pwarnx("other version '%s' already installed", installed);
@@ -512,8 +512,8 @@ pkg_do(char *pkg)
/* this shouldn't happen... X-) */
}
}
- strcat(contents, "/");
- strcat(contents, REQUIRED_BY_FNAME);
+ strlcat(contents, "/", sizeof(contents));
+ strlcat(contents, REQUIRED_BY_FNAME, sizeof(contents));
cfile = fopen(contents, "a");
if (!cfile)