Skip to content

Commit 45a3b9c

Browse files
committed
tests: fix issue with /tmp paths on macOS[1]
1 parent 0eca423 commit 45a3b9c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/clar/sandbox.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#ifdef __APPLE__
2+
#include <sys/syslimits.h>
3+
#endif
4+
15
static char _clar_path[4096];
26

37
static int
@@ -31,13 +35,21 @@ find_tmp_path(char *buffer, size_t length)
3135
continue;
3236

3337
if (is_valid_tmp_path(env)) {
38+
#ifdef __APPLE__
39+
if (length >= PATH_MAX && realpath(env, buffer) != NULL)
40+
return 0;
41+
#endif
3442
strncpy(buffer, env, length);
3543
return 0;
3644
}
3745
}
3846

3947
/* If the environment doesn't say anything, try to use /tmp */
4048
if (is_valid_tmp_path("/tmp")) {
49+
#ifdef __APPLE__
50+
if (length >= PATH_MAX && realpath("/tmp", buffer) != NULL)
51+
return 0;
52+
#endif
4153
strncpy(buffer, "/tmp", length);
4254
return 0;
4355
}

0 commit comments

Comments
 (0)