Skip to content

Commit 97834fa

Browse files
committed
Improve diagnostics if parameter is freed pointer
1 parent 6865d0a commit 97834fa

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2393,13 +2393,13 @@ INTERCEPTOR(int, setitimer, int which, const void *new_value, void *old_value) {
23932393
INTERCEPTOR(int, timespec_get, struct __sanitizer_timespec *ts, int base) {
23942394
void *ctx;
23952395
COMMON_INTERCEPTOR_ENTER(ctx, timespec_get, ts, base);
2396-
// FIXME: under ASan the call below may write to freed memory and corrupt
2397-
// its metadata. See
2398-
// https://github.com/google/sanitizers/issues/321.
2399-
int res = REAL(timespec_get)(ts, base);
2396+
// We don't yet know if ts is addressable, so we use our own scratch buffer
2397+
struct __sanitizer_timespec ts_local;
2398+
int res = REAL(timespec_get)(&ts_local, base);
24002399
if (res) {
24012400
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, ts,
24022401
sizeof(struct __sanitizer_timespec));
2402+
internal_memcpy(ts, &ts_local, sizeof(struct __sanitizer_timespec));
24032403
}
24042404
return res;
24052405
}

0 commit comments

Comments
 (0)