summaryrefslogtreecommitdiff
path: root/sys/stand/boot
diff options
context:
space:
mode:
Diffstat (limited to 'sys/stand/boot')
-rw-r--r--sys/stand/boot/boot.c15
-rw-r--r--sys/stand/boot/bootarg.c6
-rw-r--r--sys/stand/boot/bootarg.h4
-rw-r--r--sys/stand/boot/cmd.c31
-rw-r--r--sys/stand/boot/cmd.h6
-rw-r--r--sys/stand/boot/vars.c23
6 files changed, 48 insertions, 37 deletions
diff --git a/sys/stand/boot/boot.c b/sys/stand/boot/boot.c
index 844f36f2439..86374e2cdb0 100644
--- a/sys/stand/boot/boot.c
+++ b/sys/stand/boot/boot.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: boot.c,v 1.26 2003/05/19 08:18:25 mickey Exp $ */
+/* $OpenBSD: boot.c,v 1.27 2003/06/01 17:00:26 deraadt Exp $ */
/*
* Copyright (c) 2003 Dale Rahn
@@ -19,8 +19,8 @@
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
@@ -38,10 +38,10 @@
#include <sys/stat.h>
#include <libsa.h>
#include <lib/libsa/loadfile.h>
+#include <lib/libkern/funcs.h>
#include "cmd.h"
-
static const char *const kernels[] = {
"/bsd",
"/obsd",
@@ -66,7 +66,7 @@ boot(bootdev)
printf(">> OpenBSD/" MACHINE " BOOT %s\n", version);
devboot(bootdev, cmd.bootdev);
- strncpy(cmd.image, bootfile, sizeof(cmd.image));
+ strlcpy(cmd.image, bootfile, sizeof(cmd.image));
cmd.boothowto = 0;
cmd.conf = "/etc/boot.conf";
cmd.addr = (void *)DEFAULT_KERNEL_ADDRESS;
@@ -74,7 +74,8 @@ boot(bootdev)
st = read_conf();
if (!bootprompt)
- sprintf(cmd.path, "%s:%s", cmd.bootdev, cmd.image);
+ snprintf(cmd.path, sizeof cmd.path, "%s:%s",
+ cmd.bootdev, cmd.image);
while (1) {
/* no boot.conf, or no boot cmd in there */
@@ -95,7 +96,7 @@ boot(bootdev)
bootfile = kernels[i=0];
} else
bootfile = kernels[i];
- strncpy(cmd.image, bootfile, sizeof(cmd.image));
+ strlcpy(cmd.image, bootfile, sizeof(cmd.image));
printf(" failed(%d). will try %s\n", errno, bootfile);
if (try < 2)
diff --git a/sys/stand/boot/bootarg.c b/sys/stand/boot/bootarg.c
index dd3f96ee081..fba2fbf9def 100644
--- a/sys/stand/boot/bootarg.c
+++ b/sys/stand/boot/bootarg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bootarg.c,v 1.7 2002/03/14 03:16:12 millert Exp $ */
+/* $OpenBSD: bootarg.c,v 1.8 2003/06/01 17:00:27 deraadt Exp $ */
/*
* Copyright (c) 1997,1998 Michael Shalayeff
@@ -18,8 +18,8 @@
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
diff --git a/sys/stand/boot/bootarg.h b/sys/stand/boot/bootarg.h
index 414cf7a8e27..40baf3bd663 100644
--- a/sys/stand/boot/bootarg.h
+++ b/sys/stand/boot/bootarg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bootarg.h,v 1.9 2002/03/14 01:27:13 millert Exp $ */
+/* $OpenBSD: bootarg.h,v 1.10 2003/06/01 17:00:27 deraadt Exp $ */
/*
* Copyright (c) 1996-1999 Michael Shalayeff
@@ -50,7 +50,7 @@ typedef struct _boot_args {
#if defined(_KERNEL) || defined(_STANDALONE)
extern void *bootargv;
-extern int bootargc;
+extern int bootargc;
extern bootarg_t *bootargp;
#endif
diff --git a/sys/stand/boot/cmd.c b/sys/stand/boot/cmd.c
index df2f83ddf08..212ba28a008 100644
--- a/sys/stand/boot/cmd.c
+++ b/sys/stand/boot/cmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd.c,v 1.48 2002/07/14 09:19:17 mdw Exp $ */
+/* $OpenBSD: cmd.c,v 1.49 2003/06/01 17:00:27 deraadt Exp $ */
/*
* Copyright (c) 1997-1999 Michael Shalayeff
@@ -18,8 +18,8 @@
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
@@ -35,6 +35,7 @@
#include <sys/param.h>
#include <libsa.h>
#include <sys/reboot.h>
+#include <lib/libkern/funcs.h>
#include "cmd.h"
#define CTRL(c) ((c)&0x1f)
@@ -122,9 +123,9 @@ read_conf()
cmd.cmd = NULL;
- do
+ do {
eof = read(fd, p, 1);
- while (eof > 0 && *p++ != '\n');
+ } while (eof > 0 && *p++ != '\n');
if (eof < 0)
printf("%s: %s\n", cmd.path, strerror(errno));
@@ -239,12 +240,13 @@ readline(buf, n, to)
break;
if (!cnischar()) {
- strncpy(buf, "boot", 5);
+ strlcpy(buf, "boot", 5);
putchar('\n');
return strlen(buf);
}
} else
- while (!cnischar()) ;
+ while (!cnischar())
+ ;
while (1) {
switch ((ch = getchar())) {
@@ -283,7 +285,7 @@ readline(buf, n, to)
/*
* Search for spaces/tabs after the current word. If found, \0 the
* first one. Then pass a pointer to the first character of the
- * next word, or NULL if there is no next word.
+ * next word, or NULL if there is no next word.
*/
char *
nextword(p)
@@ -407,7 +409,8 @@ Xls()
}
/* no strlen in lib !!! */
- for (p = cmd.path; *p; p++);
+ for (p = cmd.path; *p; p++)
+ ;
*p++ = '/';
*p = '\0';
@@ -439,7 +442,7 @@ ls(name, sb)
lsrwx(sb->st_mode , (sb->st_mode & S_ISTXT? "tT" : "x-"));
printf (" %u,%u\t%lu\t%s\n", sb->st_uid, sb->st_gid,
- (u_long)sb->st_size, name);
+ (u_long)sb->st_size, name);
}
#undef lsrwx
@@ -466,7 +469,8 @@ Xboot()
} else {
if (bootparse(1))
return 0;
- sprintf(cmd.path, "%s:%s", cmd.bootdev, cmd.image);
+ snprintf(cmd.path, sizeof cmd.path, "%s:%s",
+ cmd.bootdev, cmd.image);
}
return 1;
@@ -486,9 +490,10 @@ qualify(name)
if (*p == ':')
break;
if (*p == ':')
- strncpy(cmd.path, name, sizeof(cmd.path));
+ strlcpy(cmd.path, name, sizeof(cmd.path));
else
- sprintf(cmd.path, "%s:%s", cmd.bootdev, name);
+ snprintf(cmd.path, sizeof cmd.path, "%s:%s",
+ cmd.bootdev, name);
return cmd.path;
}
diff --git a/sys/stand/boot/cmd.h b/sys/stand/boot/cmd.h
index cd8c1936b19..d27b4339ca2 100644
--- a/sys/stand/boot/cmd.h
+++ b/sys/stand/boot/cmd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd.h,v 1.11 2002/03/14 01:27:13 millert Exp $ */
+/* $OpenBSD: cmd.h,v 1.12 2003/06/01 17:00:27 deraadt Exp $ */
/*
* Copyright (c) 1997 Michael Shalayeff
@@ -18,8 +18,8 @@
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
diff --git a/sys/stand/boot/vars.c b/sys/stand/boot/vars.c
index 9876b877a4d..127ef05bd1c 100644
--- a/sys/stand/boot/vars.c
+++ b/sys/stand/boot/vars.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vars.c,v 1.7 2002/03/14 01:27:13 millert Exp $ */
+/* $OpenBSD: vars.c,v 1.8 2003/06/01 17:00:27 deraadt Exp $ */
/*
* Copyright (c) 1998-2000 Michael Shalayeff
@@ -35,6 +35,7 @@
#include <sys/param.h>
#include <libsa.h>
#include <sys/reboot.h>
+#include <lib/libkern/funcs.h>
#include "cmd.h"
extern const char version[];
@@ -55,7 +56,7 @@ int Xenv(void);
const struct cmd_table cmd_set[] = {
{"addr", CMDT_VAR, Xaddr},
{"howto", CMDT_VAR, Xhowto},
-#ifdef DEBUG
+#ifdef DEBUG
{"debug", CMDT_VAR, Xdebug},
#endif
{"device", CMDT_VAR, Xdevice},
@@ -109,7 +110,7 @@ Xdevice()
if (cmd.argc != 2)
printf("%s\n", cmd.bootdev);
else
- strncpy(cmd.bootdev, cmd.argv[1], sizeof(cmd.bootdev));
+ strlcpy(cmd.bootdev, cmd.argv[1], sizeof(cmd.bootdev));
return 0;
}
@@ -119,7 +120,7 @@ Ximage()
if (cmd.argc != 2)
printf("%s\n", cmd.image);
else
- strncpy(cmd.image, cmd.argv[1], sizeof(cmd.image));
+ strlcpy(cmd.image, cmd.argv[1], sizeof(cmd.image));
return 0;
}
@@ -232,6 +233,7 @@ bootparse(i)
* terminated by the usual '\0'
*/
char *environ;
+
int
Xenv()
{
@@ -245,20 +247,23 @@ Xenv()
int l;
for (p = environ; p && *p; p = q) {
l = strlen(cmd.argv[1]);
- for (q = p; *q != '='; q++);
+ for (q = p; *q != '='; q++)
+ ;
l = max(l, q - p) + 1;
- for (q = p; *q != '\n'; q++);
+ for (q = p; *q != '\n'; q++)
+ ;
if (*q)
q++;
if (!strncmp(p, cmd.argv[1], l)) {
- while((*p++ = *q++));
+ while((*p++ = *q++))
+ ;
p--;
}
}
if (!p)
p = environ = alloc(4096);
- sprintf(p, "%s=%s\n",
- cmd.argv[1], (cmd.argc==3?cmd.argv[2]:""));
+ snprintf(p, environ + 4096 - p, "%s=%s\n",
+ cmd.argv[1], (cmd.argc==3?cmd.argv[2]:""));
}
return 0;