From 2b49b95cfa930cec0092188bf1d78a82133a6489 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Sat, 5 Sep 2020 22:41:31 +0000 Subject: [PATCH] rtld: do not process absent dynamic. If object has no dynamic phdr, do not try to dereference NULL. This means that we cannot process any relocation, and that there cannot be symbols defined, but it is up to static linker to produce meaningful objects. PR: 249121 Reported by: wsh@riski.sh Sponsored by: The FreeBSD Foundation MFC after: 1 week --- libexec/rtld-elf/rtld.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 48de9506154..758725a2432 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -1089,7 +1089,10 @@ digest_dynamic1(Obj_Entry *obj, int early, const Elf_Dyn **dyn_rpath, *dyn_runpath = NULL; obj->bind_now = false; - for (dynp = obj->dynamic; dynp->d_tag != DT_NULL; dynp++) { + dynp = obj->dynamic; + if (dynp == NULL) + return; + for (; dynp->d_tag != DT_NULL; dynp++) { switch (dynp->d_tag) { case DT_REL: