DragonFlyBSD Kernel Audit
DF-0063 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/kern/link_elf.c b/sys/kern/link_elf.c
--- a/sys/kern/link_elf.c
+++ b/sys/kern/link_elf.c
@@ -809,7 +809,12 @@
     hash = elf_hash(name);
     symnum = ef->buckets[hash % ef->nbuckets];
 
+    int chain_limit = ef->nchains;
     while (symnum != STN_UNDEF) {
+	if (chain_limit-- <= 0) {
+	    kprintf("link_elf_lookup_symbol: cyclic chain detected\n");
+	    return ENOENT;
+	}
 	if (symnum >= ef->nchains) {
 	    kprintf("link_elf_lookup_symbol: corrupt symbol table\n");
 	    return ENOENT;