summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>1997-10-25 06:58:50 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>1997-10-25 06:58:50 +0000
commit1fab589e562a0cffdd8b55dc7ef57b31d71ce949 (patch)
treef36aef22a54ee0e79f969c0addaad6bf72a625b2
parent1c3ac5f3f704f3ff3c13505f9824d787dc82b83a (diff)
new bootargs, store argv at specified location
-rw-r--r--sys/stand/boot/bootarg.c28
-rw-r--r--sys/stand/boot/bootarg.h4
2 files changed, 20 insertions, 12 deletions
diff --git a/sys/stand/boot/bootarg.c b/sys/stand/boot/bootarg.c
index e74368cb4fa..642f1c8b317 100644
--- a/sys/stand/boot/bootarg.c
+++ b/sys/stand/boot/bootarg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bootarg.c,v 1.2 1997/10/22 23:48:40 mickey Exp $ */
+/* $OpenBSD: bootarg.c,v 1.3 1997/10/25 06:58:48 mickey Exp $ */
/*
* Copyright (c) 1997 Michael Shalayeff
@@ -52,20 +52,29 @@ addbootarg(t, l, p)
list = q;
}
-void *
-makebootargs(lenp)
+void
+makebootargs(v, lenp)
+ caddr_t v;
size_t *lenp;
{
- bootarg_t *p;
- u_char *r, *q;
+ register bootarg_t *p;
+ register u_char *q;
+ register size_t l;
/* get total size */
- *lenp = 0;
+ l = sizeof(*p);
for (p = list; p != NULL; p = p->ba_next)
- *lenp += p->ba_size;
- r = alloc(*lenp += sizeof(*p));
+ l += p->ba_size;
+ if (*lenp < l) {
+#ifdef DEBUG
+ printf("makebootargs: too much args\n");
+#endif
+ l = *lenp;
+ }
+ *lenp = l;
/* copy them out */
- for (p = list, q = r; p != NULL; q += p->ba_size, p = p->ba_next) {
+ for (p = list, q = v; p != NULL && ((q + p->ba_size) - (u_char*)v) < l;
+ q += p->ba_size, p = p->ba_next) {
#ifdef DEBUG
printf("%d,%d ", p->ba_type, p->ba_size);
#endif
@@ -73,6 +82,5 @@ makebootargs(lenp)
}
p = (bootarg_t *)q;
p->ba_type = BOOTARG_END;
- return r;
}
diff --git a/sys/stand/boot/bootarg.h b/sys/stand/boot/bootarg.h
index b7461c8fd2f..1f1d5b05df8 100644
--- a/sys/stand/boot/bootarg.h
+++ b/sys/stand/boot/bootarg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bootarg.h,v 1.2 1997/10/24 19:01:03 mickey Exp $ */
+/* $OpenBSD: bootarg.h,v 1.3 1997/10/25 06:58:49 mickey Exp $ */
/*
* Copyright (c) 1996 Michael Shalayeff
@@ -49,5 +49,5 @@ extern bootarg_t *bootargp;
#ifdef _STANDALONE
void addbootarg __P((int, size_t, void *));
-void *makebootargs __P((size_t *));
+void makebootargs __P((caddr_t, size_t *));
#endif /* _STANDALONE */