summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2002-05-22 08:21:03 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2002-05-22 08:21:03 +0000
commitf4157dcdc59508eeb6d7be5a9a2348bc1de796b2 (patch)
treeaa1086c2b95d7fcd3877479cd899d19157069519 /sbin
parente2f0d51cf4e08e47c64eefc6043e0126ec941016 (diff)
strcpy, sprintf death; mpech ok
Diffstat (limited to 'sbin')
-rw-r--r--sbin/disklabel/disklabel.c31
-rw-r--r--sbin/disklabel/editor.c10
-rw-r--r--sbin/fdisk/user.c4
-rw-r--r--sbin/fsck_ffs/inode.c9
-rw-r--r--sbin/ifconfig/ifconfig.c12
-rw-r--r--sbin/init/init.c13
-rw-r--r--sbin/kbd/kbd_wscons.c42
-rw-r--r--sbin/mount_portal/mount_portal.c6
-rw-r--r--sbin/ncheck_ffs/ncheck_ffs.c13
-rw-r--r--sbin/newlfs/newfs.c6
-rw-r--r--sbin/nfsd/nfsd.c4
-rw-r--r--sbin/savecore/savecore.c11
12 files changed, 85 insertions, 76 deletions
diff --git a/sbin/disklabel/disklabel.c b/sbin/disklabel/disklabel.c
index a914304e1fc..be2f6c2bd52 100644
--- a/sbin/disklabel/disklabel.c
+++ b/sbin/disklabel/disklabel.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disklabel.c,v 1.73 2002/03/24 22:51:54 millert Exp $ */
+/* $OpenBSD: disklabel.c,v 1.74 2002/05/22 08:21:01 deraadt Exp $ */
/*
* Copyright (c) 1987, 1993
@@ -43,7 +43,7 @@ static const char copyright[] =
#endif /* not lint */
#ifndef lint
-static const char rcsid[] = "$OpenBSD: disklabel.c,v 1.73 2002/03/24 22:51:54 millert Exp $";
+static const char rcsid[] = "$OpenBSD: disklabel.c,v 1.74 2002/05/22 08:21:01 deraadt Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -364,19 +364,19 @@ makelabel(type, name, lp)
*/
if (!xxboot && lp->d_boot0) {
if (*lp->d_boot0 != '/')
- (void)sprintf(boot0, "%s%s",
- _PATH_BOOTDIR, lp->d_boot0);
+ (void)snprintf(boot0, sizeof boot0, "%s%s",
+ _PATH_BOOTDIR, lp->d_boot0);
else
- (void)strcpy(boot0, lp->d_boot0);
+ (void)strlcpy(boot0, lp->d_boot0, sizeof boot0);
xxboot = boot0;
}
#if NUMBOOT > 1
if (!bootxx && lp->d_boot1) {
if (*lp->d_boot1 != '/')
- (void)sprintf(boot1, "%s%s",
- _PATH_BOOTDIR, lp->d_boot1);
+ (void)snprintf(boot1, sizeof boot1, "%s%s",
+ _PATH_BOOTDIR, lp->d_boot1);
else
- (void)strcpy(boot1, lp->d_boot1);
+ (void)strlcpy(boot1, lp->d_boot1, sizeof boot1);
bootxx = boot1;
}
#endif
@@ -812,23 +812,23 @@ makebootarea(boot, dp, f)
if (!xxboot) {
(void)sprintf(np, "%s%sboot",
- _PATH_BOOTDIR, dkbasename);
+ _PATH_BOOTDIR, dkbasename);
if (access(np, F_OK) < 0 && dkbasename[0] == 'r')
dkbasename++;
xxboot = np;
(void)sprintf(xxboot, "%s%sboot",
- _PATH_BOOTDIR, dkbasename);
+ _PATH_BOOTDIR, dkbasename);
np += strlen(xxboot) + 1;
}
#if NUMBOOT > 1
if (!bootxx) {
(void)sprintf(np, "%sboot%s",
- _PATH_BOOTDIR, dkbasename);
+ _PATH_BOOTDIR, dkbasename);
if (access(np, F_OK) < 0 && dkbasename[0] == 'r')
dkbasename++;
bootxx = np;
(void)sprintf(bootxx, "%sboot%s",
- _PATH_BOOTDIR, dkbasename);
+ _PATH_BOOTDIR, dkbasename);
np += strlen(bootxx) + 1;
}
#endif
@@ -1208,19 +1208,20 @@ int
editit()
{
pid_t pid, xpid;
- int stat;
+ int stat, len;
extern char *getenv();
char *argp[] = {"sh", "-c", NULL, NULL};
char *ed, *p;
if ((ed = getenv("EDITOR")) == NULL)
ed = _PATH_VI;
- p = (char *)malloc(strlen(ed) + 1 + strlen(tmpfil) + 1);
+ len = strlen(ed) + 1 + strlen(tmpfil) + 1;
+ p = (char *)malloc(len);
if (!p) {
warn("failed to start editor");
return (0);
}
- sprintf(p, "%s %s", ed, tmpfil);
+ snprintf(p, len, "%s %s", ed, tmpfil);
argp[2] = p;
/* Turn off signals. */
diff --git a/sbin/disklabel/editor.c b/sbin/disklabel/editor.c
index 7d4f1ed8177..3bcdb375d83 100644
--- a/sbin/disklabel/editor.c
+++ b/sbin/disklabel/editor.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: editor.c,v 1.79 2002/02/16 21:27:33 millert Exp $ */
+/* $OpenBSD: editor.c,v 1.80 2002/05/22 08:21:01 deraadt Exp $ */
/*
* Copyright (c) 1997-2000 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -28,7 +28,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: editor.c,v 1.79 2002/02/16 21:27:33 millert Exp $";
+static char rcsid[] = "$OpenBSD: editor.c,v 1.80 2002/05/22 08:21:01 deraadt Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -1959,10 +1959,12 @@ mpcopy(to, from)
for (i = 0; i < MAXPARTITIONS; i++) {
if (from[i] != NULL) {
- to[i] = realloc(to[i], strlen(from[i]) + 1);
+ int len = strlen(from[i]) + 1;
+
+ to[i] = realloc(to[i], len);
if (to[i] == NULL)
errx(4, "out of memory");
- (void)strcpy(to[i], from[i]);
+ (void)strlcpy(to[i], from[i], len);
} else if (to[i] != NULL) {
free(to[i]);
to[i] = NULL;
diff --git a/sbin/fdisk/user.c b/sbin/fdisk/user.c
index edd343fd68b..a9e597ce340 100644
--- a/sbin/fdisk/user.c
+++ b/sbin/fdisk/user.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: user.c,v 1.18 2002/01/18 08:38:26 kjell Exp $ */
+/* $OpenBSD: user.c,v 1.19 2002/05/22 08:21:02 deraadt Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
@@ -157,7 +157,7 @@ again:
printf("Invalid command '%s'. Try 'help'.\n", cmd.cmd);
continue;
} else
- strcpy(cmd.cmd, cmd_table[i].cmd);
+ strlcpy(cmd.cmd, cmd_table[i].cmd, sizeof cmd.cmd);
/* Call function */
st = cmd_table[i].fcn(&cmd, disk, &mbr, tt, offset);
diff --git a/sbin/fsck_ffs/inode.c b/sbin/fsck_ffs/inode.c
index 0a51822c76c..0e6f211f6a1 100644
--- a/sbin/fsck_ffs/inode.c
+++ b/sbin/fsck_ffs/inode.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: inode.c,v 1.19 2002/02/16 21:27:34 millert Exp $ */
+/* $OpenBSD: inode.c,v 1.20 2002/05/22 08:21:02 deraadt Exp $ */
/* $NetBSD: inode.c,v 1.23 1996/10/11 20:15:47 thorpej Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)inode.c 8.5 (Berkeley) 2/8/95";
#else
-static char rcsid[] = "$OpenBSD: inode.c,v 1.19 2002/02/16 21:27:34 millert Exp $";
+static char rcsid[] = "$OpenBSD: inode.c,v 1.20 2002/05/22 08:21:02 deraadt Exp $";
#endif
#endif /* not lint */
@@ -188,8 +188,9 @@ iblock(idesc, ilevel, isize)
for (ap = &bp->b_un.b_indir[nif]; ap < aplim; ap++) {
if (*ap == 0)
continue;
- (void)sprintf(buf, "PARTIALLY TRUNCATED INODE I=%u",
- idesc->id_number);
+ (void)snprintf(buf, sizeof buf,
+ "PARTIALLY TRUNCATED INODE I=%u",
+ idesc->id_number);
if (dofix(idesc, buf)) {
*ap = 0;
dirty(bp);
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c
index 1258db3e501..392fc178d57 100644
--- a/sbin/ifconfig/ifconfig.c
+++ b/sbin/ifconfig/ifconfig.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ifconfig.c,v 1.63 2002/04/26 04:40:42 fgsch Exp $ */
+/* $OpenBSD: ifconfig.c,v 1.64 2002/05/22 08:21:02 deraadt Exp $ */
/* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */
/*
@@ -81,7 +81,7 @@ static const char copyright[] =
#if 0
static const char sccsid[] = "@(#)ifconfig.c 8.2 (Berkeley) 2/16/94";
#else
-static const char rcsid[] = "$OpenBSD: ifconfig.c,v 1.63 2002/04/26 04:40:42 fgsch Exp $";
+static const char rcsid[] = "$OpenBSD: ifconfig.c,v 1.64 2002/05/22 08:21:02 deraadt Exp $";
#endif
#endif /* not lint */
@@ -1855,8 +1855,8 @@ in6_alias(creq)
in6_fillscopeid(sin6);
scopeid = sin6->sin6_scope_id;
if (getnameinfo((struct sockaddr *)sin6, sin6->sin6_len,
- hbuf, sizeof(hbuf), NULL, 0, niflag) != 0)
- strcpy(hbuf, "");
+ hbuf, sizeof(hbuf), NULL, 0, niflag) != 0)
+ strlcpy(hbuf, "", sizeof hbuf);
printf("\tinet6 %s", hbuf);
if (flags & IFF_POINTOPOINT) {
@@ -1873,8 +1873,8 @@ in6_alias(creq)
sin6 = (struct sockaddr_in6 *)&ifr6.ifr_addr;
in6_fillscopeid(sin6);
if (getnameinfo((struct sockaddr *)sin6, sin6->sin6_len,
- hbuf, sizeof(hbuf), NULL, 0, niflag) != 0)
- strcpy(hbuf, "");
+ hbuf, sizeof(hbuf), NULL, 0, niflag) != 0)
+ strlcpy(hbuf, "", sizeof hbuf);
printf(" -> %s", hbuf);
}
diff --git a/sbin/init/init.c b/sbin/init/init.c
index af77a83e972..264e5e07571 100644
--- a/sbin/init/init.c
+++ b/sbin/init/init.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: init.c,v 1.25 2002/02/19 19:39:38 millert Exp $ */
+/* $OpenBSD: init.c,v 1.26 2002/05/22 08:21:02 deraadt Exp $ */
/* $NetBSD: init.c,v 1.22 1996/05/15 23:29:33 jtc Exp $ */
/*-
@@ -47,7 +47,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)init.c 8.2 (Berkeley) 4/28/95";
#else
-static char rcsid[] = "$OpenBSD: init.c,v 1.25 2002/02/19 19:39:38 millert Exp $";
+static char rcsid[] = "$OpenBSD: init.c,v 1.26 2002/05/22 08:21:02 deraadt Exp $";
#endif
#endif /* not lint */
@@ -521,8 +521,8 @@ single_user()
#endif
/* Init shell and name */
- strcpy(shell, _PATH_BSHELL);
- strcpy(name, "-sh");
+ strlcpy(shell, _PATH_BSHELL, sizeof shell);
+ strlcpy(name, "-sh", sizeof name);
/*
* If the kernel is in secure mode, downgrade it to insecure mode.
@@ -569,6 +569,7 @@ single_user()
#define SHREQUEST \
"Enter pathname of shell or RETURN for sh: "
+
(void)write(STDERR_FILENO,
SHREQUEST, sizeof(SHREQUEST) - 1);
while ((num = read(STDIN_FILENO, cp, 1)) != -1 &&
@@ -581,7 +582,7 @@ single_user()
char *p;
/* Binary to exec */
- strcpy(shell, altshell);
+ strlcpy(shell, altshell, sizeof shell);
/* argv[0] */
p = strrchr(altshell, '/');
@@ -589,7 +590,7 @@ single_user()
else p++;
name[0] = '-';
- strcpy(&name[1], p);
+ strlcpy(&name[1], p, sizeof name -1);
}
}
#endif /* DEBUGSHELL */
diff --git a/sbin/kbd/kbd_wscons.c b/sbin/kbd/kbd_wscons.c
index 974577b4faf..00f9ed9280c 100644
--- a/sbin/kbd/kbd_wscons.c
+++ b/sbin/kbd/kbd_wscons.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kbd_wscons.c,v 1.6 2002/04/12 02:16:01 deraadt Exp $ */
+/* $OpenBSD: kbd_wscons.c,v 1.7 2002/05/22 08:21:02 deraadt Exp $ */
/*
* Copyright (c) 2001 Mats O Jansson. All rights reserved.
@@ -29,6 +29,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <dev/wscons/wsconsio.h>
@@ -50,7 +51,7 @@
#define SA_AKBD 2
#define SA_ZSKBD 3
#define SA_SUNKBD 4
-
+
struct nlist nl[] = {
{ "_pckbd_keydesctab" },
{ "_ukbd_keydesctab" },
@@ -103,14 +104,14 @@ kbd_show_enc(kd, idx)
printf("tables available for %s keyboard:\nencoding\n\n",
kbtype_tab[idx]);
p = nl[idx].n_value;
- kvm_read(kd, p, &r, sizeof(r));
+ kvm_read(kd, p, &r, sizeof(r));
while (r.name != 0) {
n = &kbdenc_tab[0];
found = 0;
- while(n->value) {
+ while (n->value) {
if (n->value == KB_ENCODING(r.name)) {
printf("%s",n->name);
- found++;
+ found++;
}
n++;
}
@@ -121,7 +122,7 @@ kbd_show_enc(kd, idx)
n = &kbdvar_tab[0];
found = 0;
variant = KB_VARIANT(r.name);
- while(n->value) {
+ while (n->value) {
if ((n->value & KB_VARIANT(r.name)) == n->value) {
printf(".%s",n->name);
variant &= ~n->value;
@@ -134,7 +135,7 @@ kbd_show_enc(kd, idx)
}
printf("\n");
p += sizeof(r);
- kvm_read(kd, p, &r, sizeof(r));
+ kvm_read(kd, p, &r, sizeof(r));
}
printf("\n");
}
@@ -145,7 +146,7 @@ kbd_list()
{
int fd, i, kbtype, ret;
kvm_t *kd;
- char device[sizeof "/dev/wskbd00"];
+ char device[MAXPATHLEN];
char errbuf[_POSIX2_LINE_MAX];
int pc_kbd = 0;
int usb_kbd = 0;
@@ -155,7 +156,7 @@ kbd_list()
/* Go through all keyboards. */
for (i = 0; i < NUM_KBD; i++) {
- (void) sprintf(device, "/dev/wskbd%d", i);
+ (void) snprintf(device, sizeof device, "/dev/wskbd%d", i);
fd = open(device, O_WRONLY);
if (fd < 0)
fd = open(device, O_RDONLY);
@@ -164,7 +165,7 @@ kbd_list()
err(1, "WDKBDIO_GTYPE");
if ((kbtype == WSKBD_TYPE_PC_XT) ||
(kbtype == WSKBD_TYPE_PC_AT))
- pc_kbd++;
+ pc_kbd++;
if (kbtype == WSKBD_TYPE_USB)
usb_kbd++;
if (kbtype == WSKBD_TYPE_ADB)
@@ -183,7 +184,7 @@ kbd_list()
if ((ret = kvm_nlist(kd, nl)) == -1)
errx(1, "kvm_nlist: %s", kvm_geterr(kd));
-
+
if (pc_kbd > 0)
kbd_show_enc(kd, SA_PCKBD);
@@ -200,7 +201,7 @@ kbd_list()
kbd_show_enc(kd, SA_SUNKBD);
kvm_close(kd);
-
+
if (rebuild > 0) {
printf("Unknown encoding or variant. kbd(1) needs to be rebuild.\n");
}
@@ -222,12 +223,12 @@ kbd_set(name, verbose)
c = name;
b = buf;
- while((*c != '.') && (*c != '\0')) {
+ while ((*c != '.') && (*c != '\0')) {
*b++ = *c++;
}
*b = '\0';
n = &kbdenc_tab[0];
- while(n->value) {
+ while (n->value) {
if (strcmp(n->name,buf) == 0) {
map = n->value;
}
@@ -235,16 +236,16 @@ kbd_set(name, verbose)
}
if (map == 0)
errx(1, "unknown encoding %s", buf);
- while(*c == '.') {
+ while (*c == '.') {
b = buf;
c++;
- while((*c != '.') && (*c != '\0')) {
+ while ((*c != '.') && (*c != '\0')) {
*b++ = *c++;
}
*b = '\0';
v = 0;
n = &kbdvar_tab[0];
- while(n->value) {
+ while (n->value) {
if (strcmp(n->name,buf) == 0) {
v = n->value;
}
@@ -258,15 +259,16 @@ kbd_set(name, verbose)
/* Go through all keyboards. */
v = 0;
for (i = 0; i < NUM_KBD; i++) {
- (void) sprintf(device, "/dev/wskbd%d", i);
+ (void) snprintf(device, sizeof device, "/dev/wskbd%d", i);
fd = open(device, O_WRONLY);
if (fd < 0)
fd = open(device, O_RDONLY);
if (fd >= 0) {
if (ioctl(fd, WSKBDIO_SETENCODING, &map) < 0) {
if (errno == EINVAL) {
- fprintf(stderr, "%s: unsupported encoding %s on %s\n",
- __progname, name, device);
+ fprintf(stderr,
+ "%s: unsupported encoding %s on %s\n",
+ __progname, name, device);
} else {
err(1, "WDKBDIO_SETENCODING: %s", device);
}
diff --git a/sbin/mount_portal/mount_portal.c b/sbin/mount_portal/mount_portal.c
index f996fe81cbb..ab7511eceef 100644
--- a/sbin/mount_portal/mount_portal.c
+++ b/sbin/mount_portal/mount_portal.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mount_portal.c,v 1.18 2002/02/16 21:27:36 millert Exp $ */
+/* $OpenBSD: mount_portal.c,v 1.19 2002/05/22 08:21:02 deraadt Exp $ */
/* $NetBSD: mount_portal.c,v 1.8 1996/04/13 01:31:54 jtc Exp $ */
/*
@@ -47,7 +47,7 @@ char copyright[] =
#if 0
static char sccsid[] = "@(#)mount_portal.c 8.6 (Berkeley) 4/26/95";
#else
-static char rcsid[] = "$OpenBSD: mount_portal.c,v 1.18 2002/02/16 21:27:36 millert Exp $";
+static char rcsid[] = "$OpenBSD: mount_portal.c,v 1.19 2002/05/22 08:21:02 deraadt Exp $";
#endif
#endif /* not lint */
@@ -169,7 +169,7 @@ main(argc, argv)
un.sun_family = AF_UNIX;
if (sizeof(_PATH_TMPPORTAL) >= sizeof(un.sun_path))
errx(1, "portal socket name too long");
- (void)strcpy(un.sun_path, _PATH_TMPPORTAL);
+ (void)strlcpy(un.sun_path, _PATH_TMPPORTAL, sizeof un.sun_path);
so = mkstemp(un.sun_path);
if (so < 0)
err(1, "can't create portal socket name: %s", un.sun_path);
diff --git a/sbin/ncheck_ffs/ncheck_ffs.c b/sbin/ncheck_ffs/ncheck_ffs.c
index 9ec14c08258..a6a236b4a74 100644
--- a/sbin/ncheck_ffs/ncheck_ffs.c
+++ b/sbin/ncheck_ffs/ncheck_ffs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ncheck_ffs.c,v 1.10 2002/03/14 06:51:41 mpech Exp $ */
+/* $OpenBSD: ncheck_ffs.c,v 1.11 2002/05/22 08:21:02 deraadt Exp $ */
/*-
* Copyright (c) 1995, 1996 SigmaSoft, Th. Lockert <tholo@sigmasoft.com>
@@ -31,7 +31,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: ncheck_ffs.c,v 1.10 2002/03/14 06:51:41 mpech Exp $";
+static char rcsid[] = "$OpenBSD: ncheck_ffs.c,v 1.11 2002/05/22 08:21:02 deraadt Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -394,15 +394,16 @@ searchdir(ino, blkno, size, filesize, path)
path, dp->d_name, mode == IFDIR ? "/." : "");
}
if (mode == IFDIR) {
+ int len;
+
if (dp->d_name[0] == '.') {
if (dp->d_name[1] == '\0' ||
(dp->d_name[1] == '.' && dp->d_name[2] == '\0'))
continue;
}
- npath = malloc(strlen(path) + strlen(dp->d_name) + 2);
- strcpy(npath, path);
- strcat(npath, "/");
- strcat(npath, dp->d_name);
+ len = strlen(path) + strlen(dp->d_name) + 2;
+ npath = malloc(len);
+ snprintf(npath, len, "%s/%s", path, dp->d_name);
scanonedir(dp->d_ino, npath);
free(npath);
}
diff --git a/sbin/newlfs/newfs.c b/sbin/newlfs/newfs.c
index de530d4448e..eb4c29f0a71 100644
--- a/sbin/newlfs/newfs.c
+++ b/sbin/newlfs/newfs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: newfs.c,v 1.10 2002/03/14 16:44:24 mpech Exp $ */
+/* $OpenBSD: newfs.c,v 1.11 2002/05/22 08:21:02 deraadt Exp $ */
/* $NetBSD: newfs.c,v 1.5 1996/05/16 07:17:50 thorpej Exp $ */
/*-
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)newfs.c 8.5 (Berkeley) 5/24/95";
#else
-static char rcsid[] = "$OpenBSD: newfs.c,v 1.10 2002/03/14 16:44:24 mpech Exp $";
+static char rcsid[] = "$OpenBSD: newfs.c,v 1.11 2002/05/22 08:21:02 deraadt Exp $";
#endif
#endif /* not lint */
@@ -410,7 +410,7 @@ rewritelabel(s, fd, lp)
/*
* Make name for 'c' partition.
*/
- strcpy(specname, s);
+ strlcpy(specname, s, sizeof specname);
cp = specname + strlen(specname) - 1;
if (!isdigit(*cp))
*cp = 'c';
diff --git a/sbin/nfsd/nfsd.c b/sbin/nfsd/nfsd.c
index db151202a95..6fba9ea91ef 100644
--- a/sbin/nfsd/nfsd.c
+++ b/sbin/nfsd/nfsd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfsd.c,v 1.16 2002/02/16 21:27:37 millert Exp $ */
+/* $OpenBSD: nfsd.c,v 1.17 2002/05/22 08:21:02 deraadt Exp $ */
/* $NetBSD: nfsd.c,v 1.19 1996/02/18 23:18:56 mycroft Exp $ */
/*
@@ -290,7 +290,7 @@ main(argc, argv, envp)
(RPCAUTH_MAXSIZ - 3 * NFSX_UNSIGNED)) {
kin.w1 = NFS_KERBW1(kt);
kt.mbz = 0;
- (void)strcpy(inst, "*");
+ (void)strlcpy(inst, "*", sizeof inst);
if (krb_rd_req(&kt, NFS_KERBSRV,
inst, nsd.nsd_haddr, &kauth, "") == RD_AP_OK &&
krb_kntoln(&kauth, lnam) == KSUCCESS &&
diff --git a/sbin/savecore/savecore.c b/sbin/savecore/savecore.c
index b6014ab69d6..95d21d0fe66 100644
--- a/sbin/savecore/savecore.c
+++ b/sbin/savecore/savecore.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: savecore.c,v 1.28 2002/02/16 21:27:37 millert Exp $ */
+/* $OpenBSD: savecore.c,v 1.29 2002/05/22 08:21:02 deraadt Exp $ */
/* $NetBSD: savecore.c,v 1.26 1996/03/18 21:16:05 leo Exp $ */
/*-
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)savecore.c 8.3 (Berkeley) 1/2/94";
#else
-static char rcsid[] = "$OpenBSD: savecore.c,v 1.28 2002/02/16 21:27:37 millert Exp $";
+static char rcsid[] = "$OpenBSD: savecore.c,v 1.29 2002/05/22 08:21:02 deraadt Exp $";
#endif
#endif /* not lint */
@@ -532,15 +532,16 @@ find_dev(dev, type)
DIR *dfd;
struct dirent *dir;
struct stat sb;
- char *dp, devname[MAXPATHLEN + 1];
+ char *dp, devname[MAXPATHLEN];
if ((dfd = opendir(_PATH_DEV)) == NULL) {
syslog(LOG_ERR, "%s: %s", _PATH_DEV, strerror(errno));
exit(1);
}
- (void)strcpy(devname, _PATH_DEV);
+ (void)strlcpy(devname, _PATH_DEV, sizeof devname);
while ((dir = readdir(dfd))) {
- (void)strcpy(devname + sizeof(_PATH_DEV) - 1, dir->d_name);
+ (void)strlcpy(devname + sizeof(_PATH_DEV) - 1, dir->d_name,
+ sizeof devname + sizeof(_PATH_DEV) - 1);
if (lstat(devname, &sb)) {
syslog(LOG_ERR, "%s: %s", devname, strerror(errno));
continue;