summaryrefslogtreecommitdiff
path: root/sbin/disklabel
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/disklabel
parente2f0d51cf4e08e47c64eefc6043e0126ec941016 (diff)
strcpy, sprintf death; mpech ok
Diffstat (limited to 'sbin/disklabel')
-rw-r--r--sbin/disklabel/disklabel.c31
-rw-r--r--sbin/disklabel/editor.c10
2 files changed, 22 insertions, 19 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;