Skip to content

Commit

Permalink
dtoolutil: Fix UB when musl's dlinfo(RTLD_DI_LINKMAP) fails
Browse files Browse the repository at this point in the history
  • Loading branch information
CFSworks committed May 29, 2019
1 parent adaf9ee commit f21830d
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions dtool/src/dtoolutil/executionEnvironment.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -610,16 +610,16 @@ read_args() {
#else
void *self = dlopen(NULL, RTLD_NOW | RTLD_NOLOAD);
#endif
dlinfo(self, RTLD_DI_LINKMAP, &map);

while (map != nullptr) {
const char *tail = strrchr(map->l_name, '/');
const char *head = strchr(map->l_name, '/');
if (tail && head && (strcmp(tail, "/libp3dtool.so." PANDA_ABI_VERSION_STR) == 0
|| strcmp(tail, "/libp3dtool.so") == 0)) {
_dtool_name = head;
if (dlinfo(self, RTLD_DI_LINKMAP, &map)) {
while (map != nullptr) {
const char *tail = strrchr(map->l_name, '/');
const char *head = strchr(map->l_name, '/');
if (tail && head && (strcmp(tail, "/libp3dtool.so." PANDA_ABI_VERSION_STR) == 0
|| strcmp(tail, "/libp3dtool.so") == 0)) {
_dtool_name = head;
}
map = map->l_next;
}
map = map->l_next;
}
}
#endif
Expand Down

0 comments on commit f21830d

Please sign in to comment.