[OpenBIOS] [PATCH] bootinfo_load: recognize EOT as end of bootinfo

Cormac O'Brien i.am.cormac.obrien at gmail.com
Thu Jun 18 06:05:05 CEST 2015


Mac OS 9's CHRP boot info is delimited by an ASCII EOT, so the bootscript
loader will truncate the malloc() size if it encounters one to avoid an
out-of-memory error.

Signed-off-by: Cormac O'Brien <i.am.cormac.obrien at gmail.com>

---
 libopenbios/bootinfo_load.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/libopenbios/bootinfo_load.c b/libopenbios/bootinfo_load.c
index fa9e36b..a3ce00e 100644
--- a/libopenbios/bootinfo_load.c
+++ b/libopenbios/bootinfo_load.c
@@ -161,6 +161,15 @@ bootinfo_init_program(void)
 	feval("load-size");
 	size = POP();
 
+	current = 0;
+	while (current < size) {
+		if (base[current] == 0x04) {
+			size = current;
+			break;
+		}
+		current++;
+	}
+
 	bootscript = malloc(size);
 	if (bootscript == NULL) {
 		DPRINTF("Can't malloc %d bytes\n", size);
-- 
2.4.4




More information about the OpenBIOS mailing list