Skip to content

Commit 3d11728

Browse files
authored
[sanitizer_common] Fix potential null dereference in dlopen interceptor (#74645)
The test_only_replace_dlopen_main_program flag (introduced in 0be4c6b) will cause internal_strcmp to dereference NULL if DlAddrSelfFName() returns NULL (which happens in very rare cases). This patch adds a null pointer check. Co-authored-by: Thurston Dang <[email protected]>
1 parent cd83180 commit 3d11728

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6327,7 +6327,7 @@ INTERCEPTOR(void*, dlopen, const char *filename, int flag) {
63276327
VPrintf(1, "dlopen interceptor: DladdrSelfFName: %p %s\n",
63286328
(void *)SelfFName, SelfFName);
63296329

6330-
if (internal_strcmp(SelfFName, filename) == 0) {
6330+
if (SelfFName && internal_strcmp(SelfFName, filename) == 0) {
63316331
// It's possible they copied the string from dladdr, so
63326332
// we do a string comparison rather than pointer comparison.
63336333
VPrintf(1, "dlopen interceptor: replacing %s because it matches %s\n",

0 commit comments

Comments
 (0)