浏览代码

ldso: add null-pointer check

There is a check for (*rpnt == NULL) a few lines above but the "else"
case performing an allocation does only exist if SHARED is not defined.
If SHARED is defined, the allocation is not performed and it may happen
(at least in theory) that *rpnt == NULL when executing

  (*rpnt)->dyn = tpnt;

Add the null-pointer check.

Signed-off-by: Frank Mehnert <frank.mehnert@kernkonzept.com>
Frank Mehnert 1 年之前
父节点
当前提交
8fa5437044
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      ldso/ldso/dl-elf.c

+ 2 - 1
ldso/ldso/dl-elf.c

@@ -900,7 +900,8 @@ struct elf_resolve *_dl_load_elf_shared_library(unsigned int rflags,
 		_dl_memset(*rpnt, 0, sizeof(struct dyn_elf));
 		_dl_memset(*rpnt, 0, sizeof(struct dyn_elf));
 	}
 	}
 #endif
 #endif
-	(*rpnt)->dyn = tpnt;
+	if (*rpnt)
+		(*rpnt)->dyn = tpnt;
 	tpnt->usage_count++;
 	tpnt->usage_count++;
 	if (tpnt->rtld_flags & RTLD_NODELETE)
 	if (tpnt->rtld_flags & RTLD_NODELETE)
 		tpnt->usage_count++;
 		tpnt->usage_count++;