Skip to content

Commit 2ca010c

Browse files
committed
Try a less risky fix
1 parent 8e5b22e commit 2ca010c

File tree

1 file changed

+2
-19
lines changed

1 file changed

+2
-19
lines changed

src/shared/pal/src/thread/process.cpp

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2372,26 +2372,9 @@ CreateProcessModules(
23722372
}
23732373

23742374
// Does the offset in the module correspond to a valid MachO header?
2375-
bool isMachO = false;
2376-
int fd = open(moduleName, O_RDONLY);
2377-
if (fd != -1)
2378-
{
2379-
if (lseek(fd, rwpi.prp_prinfo.pri_offset, SEEK_SET) != (off_t)-1)
2380-
{
2381-
uint32_t magic = 0;
2382-
ssize_t bytesRead = read(fd, &magic, sizeof(magic));
2383-
if (bytesRead == sizeof(magic))
2384-
{
2385-
if (magic == 0xFEEDFACF)
2386-
{
2387-
isMachO = true;
2388-
}
2389-
}
2390-
}
2391-
close(fd);
2392-
}
2375+
bool mightBeMachOHeader = rwpi.prp_prinfo.pri_offset == 0;
23932376

2394-
if (!dup && isMachO)
2377+
if (!dup && mightBeMachOHeader)
23952378
{
23962379
int cbModuleName = strlen(moduleName) + 1;
23972380
ProcessModules *entry = (ProcessModules *)malloc(sizeof(ProcessModules) + cbModuleName);

0 commit comments

Comments
 (0)