[PATCH] [elf] Fix possible null-pointer dereference.
Dmitry Chestnyh
d.chestnyh@omp.ru
Thu Mar 31 15:44:11 GMT 2022
This issue was found by SVACE static analyzer.
Dereference can appear at line 203 and there are no
obvious checks of `map->l_name` ptr value.
And seems that we can't be sure that this pointer
isn't NULL.
---
elf/sotruss-lib.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/elf/sotruss-lib.c b/elf/sotruss-lib.c
index a5edd438f9..030c818a3e 100644
--- a/elf/sotruss-lib.c
+++ b/elf/sotruss-lib.c
@@ -200,7 +200,7 @@ la_objopen (struct link_map *map, Lmid_t lmid, uintptr_t *cookie)
from or that list must be empty. In the latter case we trace
only calls from the main binary. */
if (fromlist == NULL)
- result |= map->l_name[0] == '\0' ? LA_FLG_BINDFROM : 0;
+ result |= (map->l_name && map->l_name[0] == '\0') ? LA_FLG_BINDFROM : 0;
else
result |= (match_file (fromlist, full_name, full_name_len,
LA_FLG_BINDFROM)
--
2.25.1
More information about the Libc-alpha
mailing list