Skip to content

Commit

Permalink
darwintrace: Don't fail on unreadable symlinks
Browse files Browse the repository at this point in the history
Don't call abort() just because we can't read a symlink. Instead, ignore
the error and let it bubble up to the build that attempted the read.

(cherry picked from commit e3eed16)
  • Loading branch information
neverpanic authored and jmroot committed Nov 21, 2024
1 parent 5bf933b commit 27c0051
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/darwintracelib1.0/darwintrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -1162,9 +1162,18 @@ bool __darwintrace_is_in_sandbox(const char *path, int flags) {
while (true) {
ssize_t linksize;
if (-1 == (linksize = readlink(path_native, link, maxLinkLength - 1))) {
free(path_native);
perror("darwintrace: readlink");
abort();
/* If we can't read the link, don't error out, but jsut continue as if the path
* wasn't a link. The build will later on have to deal with the same error and
* will likely either gracefully handle it, or return a useful error message. */
free(link);
link = strdup(path_native);
if (!link) {
perror("darwintrace: strdup");
abort();
}

pathIsSymlink = false;
break;
}
link[linksize] = '\0';
if ((size_t) linksize < maxLinkLength - 1) {
Expand Down

0 comments on commit 27c0051

Please sign in to comment.