Module Name: src Committed By: maxv Date: Sun Jun 5 14:13:57 UTC 2016
Modified Files: src/sys/arch/i386/stand/lib: bootinfo.c bootinfo.h exec.c Log Message: Don't use a magic value. Define a limit, and enforce it. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/i386/stand/lib/bootinfo.c cvs rdiff -u -r1.10 -r1.11 src/sys/arch/i386/stand/lib/bootinfo.h cvs rdiff -u -r1.60 -r1.61 src/sys/arch/i386/stand/lib/exec.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/i386/stand/lib/bootinfo.c diff -u src/sys/arch/i386/stand/lib/bootinfo.c:1.5 src/sys/arch/i386/stand/lib/bootinfo.c:1.6 --- src/sys/arch/i386/stand/lib/bootinfo.c:1.5 Sun Dec 14 18:46:33 2008 +++ src/sys/arch/i386/stand/lib/bootinfo.c Sun Jun 5 14:13:57 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: bootinfo.c,v 1.5 2008/12/14 18:46:33 christos Exp $ */ +/* $NetBSD: bootinfo.c,v 1.6 2016/06/05 14:13:57 maxv Exp $ */ /* * Copyright (c) 1997 @@ -40,6 +40,11 @@ bi_add(struct btinfo_common *what, int t what->len = size; what->type = type; - if (bootinfo) - bootinfo->entry[bootinfo->nentries++] = vtophys(what); + if (bootinfo == NULL) { + return; + } + if (bootinfo->nentries >= BTINFO_MAX) { + panic("bootinfo too big"); + } + bootinfo->entry[bootinfo->nentries++] = vtophys(what); } Index: src/sys/arch/i386/stand/lib/bootinfo.h diff -u src/sys/arch/i386/stand/lib/bootinfo.h:1.10 src/sys/arch/i386/stand/lib/bootinfo.h:1.11 --- src/sys/arch/i386/stand/lib/bootinfo.h:1.10 Mon Nov 18 03:52:45 2013 +++ src/sys/arch/i386/stand/lib/bootinfo.h Sun Jun 5 14:13:57 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: bootinfo.h,v 1.10 2013/11/18 03:52:45 jakllsch Exp $ */ +/* $NetBSD: bootinfo.h,v 1.11 2016/06/05 14:13:57 maxv Exp $ */ /* * Copyright (c) 1997 @@ -35,6 +35,8 @@ struct bootinfo { extern struct bootinfo *bootinfo; +#define BTINFO_MAX 32 + #define BI_ALLOC(max) (bootinfo = alloc(sizeof(struct bootinfo) \ + ((max) - 1) * sizeof(uint32_t))) \ ->nentries = 0 Index: src/sys/arch/i386/stand/lib/exec.c diff -u src/sys/arch/i386/stand/lib/exec.c:1.60 src/sys/arch/i386/stand/lib/exec.c:1.61 --- src/sys/arch/i386/stand/lib/exec.c:1.60 Sun Jun 5 14:06:31 2016 +++ src/sys/arch/i386/stand/lib/exec.c Sun Jun 5 14:13:57 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: exec.c,v 1.60 2016/06/05 14:06:31 maxv Exp $ */ +/* $NetBSD: exec.c,v 1.61 2016/06/05 14:13:57 maxv Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -356,7 +356,7 @@ exec_netbsd(const char *file, physaddr_t file ? file : "NULL", loadaddr); #endif - BI_ALLOC(32); /* ??? */ + BI_ALLOC(BTINFO_MAX); BI_ADD(&btinfo_console, BTINFO_CONSOLE, sizeof(struct btinfo_console));