From d0ca7c29dc0da5d08fc78f662f320f41b3600c08 Mon Sep 17 00:00:00 2001 From: Peter Wemm Date: Sun, 8 Sep 2002 02:17:44 +0000 Subject: [PATCH] Do not blow up when we walk off the end of the brands list. Found by: kris, jake --- sys/kern/imgact_elf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index 66659fd6aac..01e1bd26cd4 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -188,6 +188,7 @@ __elfN(get_brandinfo)(const Elf_Ehdr *hdr, const char *interp) static int __elfN(check_header)(const Elf_Ehdr *hdr) { + Elf_Brandinfo *bi; int i; if (!IS_ELF(*hdr) || @@ -201,7 +202,8 @@ __elfN(check_header)(const Elf_Ehdr *hdr) */ for (i = 0; i < MAX_BRANDS; i++) { - if (elf_brand_list[i]->machine == hdr->e_machine) + bi = elf_brand_list[i]; + if (bi != NULL && bi->machine == hdr->e_machine) break; } if (i == MAX_BRANDS)