use bounded string op as much as possible
This commit is contained in:
parent
5402d14cf4
commit
49a751869e
|
@ -1,11 +1,11 @@
|
|||
/* $NetBSD: main.c,v 1.29 2003/06/05 13:15:43 agc Exp $ */
|
||||
/* $NetBSD: main.c,v 1.30 2003/07/14 06:17:54 itojun Exp $ */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char *rcsid = "from FreeBSD Id: main.c,v 1.16 1997/10/08 07:45:43 charnier Exp";
|
||||
#else
|
||||
__RCSID("$NetBSD: main.c,v 1.29 2003/06/05 13:15:43 agc Exp $");
|
||||
__RCSID("$NetBSD: main.c,v 1.30 2003/07/14 06:17:54 itojun Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -102,7 +102,7 @@ main(int argc, char **argv)
|
|||
break;
|
||||
|
||||
case 't':
|
||||
strcpy(FirstPen, optarg);
|
||||
strlcpy(FirstPen, optarg, sizeof(FirstPen));
|
||||
break;
|
||||
|
||||
case 'S':
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/* $NetBSD: main.c,v 1.24 2003/06/05 13:15:44 agc Exp $ */
|
||||
/* $NetBSD: main.c,v 1.25 2003/07/14 06:17:55 itojun Exp $ */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static const char *rcsid = "from FreeBSD Id: main.c,v 1.17 1997/10/08 07:46:23 charnier Exp";
|
||||
#else
|
||||
__RCSID("$NetBSD: main.c,v 1.24 2003/06/05 13:15:44 agc Exp $");
|
||||
__RCSID("$NetBSD: main.c,v 1.25 2003/07/14 06:17:55 itojun Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -142,7 +142,7 @@ main(int argc, char **argv)
|
|||
break;
|
||||
|
||||
case 't':
|
||||
strcpy(PlayPen, optarg);
|
||||
strlcpy(PlayPen, optarg, sizeof(PlayPen));
|
||||
break;
|
||||
|
||||
case 'X':
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/* $NetBSD: pl.c,v 1.26 2003/06/12 13:29:32 agc Exp $ */
|
||||
/* $NetBSD: pl.c,v 1.27 2003/07/14 06:17:55 itojun 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.26 2003/06/12 13:29:32 agc Exp $");
|
||||
__RCSID("$NetBSD: pl.c,v 1.27 2003/07/14 06:17:55 itojun Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -201,7 +201,8 @@ check_list(char *home, package_t *pkg, const char *PkgName)
|
|||
warnx("Warning - block special device `%s' in PLIST", name);
|
||||
break;
|
||||
default:
|
||||
(void) strcpy(buf, CHECKSUM_HEADER);
|
||||
(void) strlcpy(buf, CHECKSUM_HEADER,
|
||||
sizeof(buf));
|
||||
if (MD5File(name, &buf[ChecksumHeaderLen]) != (char *) NULL) {
|
||||
tmp = new_plist_entry();
|
||||
tmp->name = strdup(buf);
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/* $NetBSD: perform.c,v 1.45 2003/03/24 21:44:46 seb Exp $ */
|
||||
/* $NetBSD: perform.c,v 1.46 2003/07/14 06:17:55 itojun Exp $ */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static const char *rcsid = "from FreeBSD Id: perform.c,v 1.23 1997/10/13 15:03:53 jkh Exp";
|
||||
#else
|
||||
__RCSID("$NetBSD: perform.c,v 1.45 2003/03/24 21:44:46 seb Exp $");
|
||||
__RCSID("$NetBSD: perform.c,v 1.46 2003/07/14 06:17:55 itojun Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -54,7 +54,7 @@ pkg_do(char *pkg)
|
|||
|
||||
if (IS_URL(pkg)) {
|
||||
if ((cp = fileGetURL(pkg)) != NULL) {
|
||||
strcpy(fname, cp);
|
||||
strlcpy(fname, cp, sizeof(fname));
|
||||
isTMP = TRUE;
|
||||
}
|
||||
} else if (fexists(pkg) && isfile(pkg)) {
|
||||
|
@ -68,7 +68,7 @@ pkg_do(char *pkg)
|
|||
len = strlen(fname);
|
||||
(void) snprintf(&fname[len], sizeof(fname) - len, "/%s", pkg);
|
||||
} else {
|
||||
strcpy(fname, pkg);
|
||||
strlcpy(fname, pkg, sizeof(fname));
|
||||
}
|
||||
cp = fname;
|
||||
} else {
|
||||
|
@ -89,7 +89,7 @@ pkg_do(char *pkg)
|
|||
char *cp2;
|
||||
|
||||
if ((cp2 = fileGetURL(cp)) != NULL) {
|
||||
strcpy(fname, cp2);
|
||||
strlcpy(fname, cp2, sizeof(fname));
|
||||
isTMP = TRUE;
|
||||
}
|
||||
strcpy(PlayPen, cp2);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/* $NetBSD: ftpio.c,v 1.51 2003/06/23 16:46:57 tacha Exp $ */
|
||||
/* $NetBSD: ftpio.c,v 1.52 2003/07/14 06:17:56 itojun Exp $ */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: ftpio.c,v 1.51 2003/06/23 16:46:57 tacha Exp $");
|
||||
__RCSID("$NetBSD: ftpio.c,v 1.52 2003/07/14 06:17:56 itojun Exp $");
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -548,7 +548,7 @@ expandURL(char *expandedurl, const char *wildcardurl)
|
|||
char best[FILENAME_MAX];
|
||||
int tfd;
|
||||
|
||||
strcpy(tmpname, "/var/tmp/pkg.XXXXXX");
|
||||
strlcpy(tmpname, "/var/tmp/pkg.XXXXXX", sizeof(tmpname));
|
||||
tfd=mkstemp(tmpname);
|
||||
if (tfd == -1) {
|
||||
warnx("Cannot generate temp file for ftp(1)'s nlist output");
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/* $NetBSD: pen.c,v 1.26 2003/04/10 23:38:16 grant Exp $ */
|
||||
/* $NetBSD: pen.c,v 1.27 2003/07/14 06:17:56 itojun Exp $ */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static const char *rcsid = "from FreeBSD Id: pen.c,v 1.25 1997/10/08 07:48:12 charnier Exp";
|
||||
#else
|
||||
__RCSID("$NetBSD: pen.c,v 1.26 2003/04/10 23:38:16 grant Exp $");
|
||||
__RCSID("$NetBSD: pen.c,v 1.27 2003/07/14 06:17:56 itojun Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -65,11 +65,11 @@ void
|
|||
restore_dirs(char *c, char *p)
|
||||
{
|
||||
CurrentSet = 0; /* prevent from deleting */
|
||||
strcpy(Current, c);
|
||||
strlcpy(Current, c, sizeof(Current));
|
||||
CurrentSet = 1; /* rm -fr Current is safe now */
|
||||
free(c);
|
||||
|
||||
strcpy(Previous, p);
|
||||
strlcpy(Previous, p, sizeof(Previous));
|
||||
free(p);
|
||||
}
|
||||
#endif
|
||||
|
@ -96,11 +96,11 @@ find_play_pen(char *pen, size_t pensize, size_t sz)
|
|||
else if ((cp = getenv("TMPDIR")) != NULL && stat(cp, &sb) != FAIL && (min_free(cp) >= sz))
|
||||
(void) snprintf(pen, pensize, "%s/instmp.XXXXXX", cp);
|
||||
else if (stat("/var/tmp", &sb) != FAIL && min_free("/var/tmp") >= sz)
|
||||
strcpy(pen, "/var/tmp/instmp.XXXXXX");
|
||||
strlcpy(pen, "/var/tmp/instmp.XXXXXX", pensize);
|
||||
else if (stat("/tmp", &sb) != FAIL && min_free("/tmp") >= sz)
|
||||
strcpy(pen, "/tmp/instmp.XXXXXX");
|
||||
strlcpy(pen, "/tmp/instmp.XXXXXX", pensize);
|
||||
else if (stat("/usr/tmp", &sb) != FAIL && min_free("/usr/tmp") >= sz)
|
||||
strcpy(pen, "/usr/tmp/instmp.XXXXXX");
|
||||
strlcpy(pen, "/usr/tmp/instmp.XXXXXX", pensize);
|
||||
else {
|
||||
cleanup(0);
|
||||
errx(2,
|
||||
|
@ -153,7 +153,7 @@ make_playpen(char *pen, size_t pensize, size_t sz)
|
|||
"with more space and\ntry the command again", pen);
|
||||
}
|
||||
if (Current[0])
|
||||
strcpy(Previous, Current);
|
||||
strlcpy(Previous, Current, sizeof(Previous));
|
||||
else if (!getcwd(Previous, FILENAME_MAX)) {
|
||||
cleanup(0);
|
||||
err(EXIT_FAILURE, "fatal error during execution: getcwd");
|
||||
|
@ -162,7 +162,7 @@ make_playpen(char *pen, size_t pensize, size_t sz)
|
|||
cleanup(0);
|
||||
errx(2, "can't chdir to '%s'", pen);
|
||||
}
|
||||
CurrentSet = 0; strcpy(Current, pen); CurrentSet = 1;
|
||||
CurrentSet = 0; strlcpy(Current, pen, sizeof(Current)); CurrentSet = 1;
|
||||
|
||||
return Previous;
|
||||
}
|
||||
|
@ -187,10 +187,10 @@ leave_playpen(char *save)
|
|||
}
|
||||
if (vsystem("rm -rf %s", Current))
|
||||
warnx("couldn't remove temporary dir '%s'", Current);
|
||||
strcpy(Current, Previous);
|
||||
strlcpy(Current, Previous, sizeof(Current));
|
||||
}
|
||||
if (save)
|
||||
strcpy(Previous, save);
|
||||
strlcpy(Previous, save, sizeof(Previous));
|
||||
else
|
||||
Previous[0] = '\0';
|
||||
signal(SIGINT, oldsig);
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/* $NetBSD: plist.c,v 1.38 2003/04/14 23:42:21 grant Exp $ */
|
||||
/* $NetBSD: plist.c,v 1.39 2003/07/14 06:17:56 itojun Exp $ */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static const char *rcsid = "from FreeBSD Id: plist.c,v 1.24 1997/10/08 07:48:15 charnier Exp";
|
||||
#else
|
||||
__RCSID("$NetBSD: plist.c,v 1.38 2003/04/14 23:42:21 grant Exp $");
|
||||
__RCSID("$NetBSD: plist.c,v 1.39 2003/07/14 06:17:56 itojun Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -235,7 +235,7 @@ plist_cmd(char *s, char **arg)
|
|||
char *cp;
|
||||
char *sp;
|
||||
|
||||
(void) strcpy(cmd, s);
|
||||
(void) strlcpy(cmd, s, sizeof(cmd));
|
||||
str_lowercase(cmd);
|
||||
for (cp = cmd, sp = s; *cp; cp++, sp++) {
|
||||
if (isspace((unsigned char) *cp)) {
|
||||
|
|
Loading…
Reference in New Issue