@@ -285,6 +285,33 @@ INTERCEPTOR(int, unlinkat, int fd, const char *pathname, int flag) {
285
285
return REAL (unlinkat)(fd, pathname, flag);
286
286
}
287
287
288
+ INTERCEPTOR (int , truncate, const char *pathname, off_t length) {
289
+ __rtsan_notify_intercepted_call (" truncate" );
290
+ return REAL (truncate)(pathname, length);
291
+ }
292
+
293
+ INTERCEPTOR (int , ftruncate, int fd, off_t length) {
294
+ __rtsan_notify_intercepted_call (" ftruncate" );
295
+ return REAL (ftruncate)(fd, length);
296
+ }
297
+
298
+ #if SANITIZER_LINUX
299
+ INTERCEPTOR (int , truncate64, const char *pathname, off64_t length) {
300
+ __rtsan_notify_intercepted_call (" truncate64" );
301
+ return REAL (truncate64)(pathname, length);
302
+ }
303
+
304
+ INTERCEPTOR (int , ftruncate64, int fd, off64_t length) {
305
+ __rtsan_notify_intercepted_call (" ftruncate64" );
306
+ return REAL (ftruncate64)(fd, length);
307
+ }
308
+ #define RTSAN_MAYBE_INTERCEPT_TRUNCATE64 INTERCEPT_FUNCTION (truncate64)
309
+ #define RTSAN_MAYBE_INTERCEPT_FTRUNCATE64 INTERCEPT_FUNCTION (ftruncate64)
310
+ #else
311
+ #define RTSAN_MAYBE_INTERCEPT_TRUNCATE64
312
+ #define RTSAN_MAYBE_INTERCEPT_FTRUNCATE64
313
+ #endif
314
+
288
315
// Streams
289
316
290
317
INTERCEPTOR (FILE *, fopen, const char *path, const char *mode) {
@@ -1437,6 +1464,10 @@ void __rtsan::InitializeInterceptors() {
1437
1464
RTSAN_MAYBE_INTERCEPT_READLINKAT;
1438
1465
INTERCEPT_FUNCTION (unlink);
1439
1466
INTERCEPT_FUNCTION (unlinkat);
1467
+ INTERCEPT_FUNCTION (truncate);
1468
+ INTERCEPT_FUNCTION (ftruncate);
1469
+ RTSAN_MAYBE_INTERCEPT_TRUNCATE64;
1470
+ RTSAN_MAYBE_INTERCEPT_FTRUNCATE64;
1440
1471
INTERCEPT_FUNCTION (fopen);
1441
1472
RTSAN_MAYBE_INTERCEPT_FOPEN64;
1442
1473
RTSAN_MAYBE_INTERCEPT_FREOPEN64;
0 commit comments