@@ -376,6 +376,95 @@ INTERCEPTOR(void, setbuffer, FILE *stream, char *buf, int size) {
376
376
#define RTSAN_MAYBE_INTERCEPT_SETBUFFER
377
377
#endif
378
378
379
+ #if SANITIZER_INTERCEPT_FSEEK
380
+ INTERCEPTOR (int , fgetpos, FILE *stream, fpos_t *pos) {
381
+ __rtsan_notify_intercepted_call (" fgetpos" );
382
+ return REAL (fgetpos)(stream, pos);
383
+ }
384
+
385
+ INTERCEPTOR (int , fseek, FILE *stream, long offset, int whence) {
386
+ __rtsan_notify_intercepted_call (" fseek" );
387
+ return REAL (fseek)(stream, offset, whence);
388
+ }
389
+
390
+ INTERCEPTOR (int , fseeko, FILE *stream, off_t offset, int whence) {
391
+ __rtsan_notify_intercepted_call (" fseeko" );
392
+ return REAL (fseeko)(stream, offset, whence);
393
+ }
394
+
395
+ INTERCEPTOR (int , fsetpos, FILE *stream, const fpos_t *pos) {
396
+ __rtsan_notify_intercepted_call (" fsetpos" );
397
+ return REAL (fsetpos)(stream, pos);
398
+ }
399
+
400
+ INTERCEPTOR (long , ftell, FILE *stream) {
401
+ __rtsan_notify_intercepted_call (" ftell" );
402
+ return REAL (ftell)(stream);
403
+ }
404
+
405
+ INTERCEPTOR (off_t , ftello, FILE *stream) {
406
+ __rtsan_notify_intercepted_call (" ftello" );
407
+ return REAL (ftello)(stream);
408
+ }
409
+
410
+ #if SANITIZER_LINUX && !SANITIZER_MUSL
411
+ INTERCEPTOR (int , fgetpos64, FILE *stream, fpos64_t *pos) {
412
+ __rtsan_notify_intercepted_call (" fgetpos64" );
413
+ return REAL (fgetpos64)(stream, pos);
414
+ }
415
+
416
+ INTERCEPTOR (int , fseeko64, FILE *stream, off64_t offset, int whence) {
417
+ __rtsan_notify_intercepted_call (" fseeko64" );
418
+ return REAL (fseeko64)(stream, offset, whence);
419
+ }
420
+
421
+ INTERCEPTOR (int , fsetpos64, FILE *stream, const fpos64_t *pos) {
422
+ __rtsan_notify_intercepted_call (" fsetpos64" );
423
+ return REAL (fsetpos64)(stream, pos);
424
+ }
425
+
426
+ INTERCEPTOR (off64_t , ftello64, FILE *stream) {
427
+ __rtsan_notify_intercepted_call (" ftello64" );
428
+ return REAL (ftello64)(stream);
429
+ }
430
+ #endif
431
+
432
+ INTERCEPTOR (void , rewind, FILE *stream) {
433
+ __rtsan_notify_intercepted_call (" rewind" );
434
+ return REAL (rewind)(stream);
435
+ }
436
+ #define RTSAN_MAYBE_INTERCEPT_FGETPOS INTERCEPT_FUNCTION (fgetpos)
437
+ #define RTSAN_MAYBE_INTERCEPT_FSEEK INTERCEPT_FUNCTION (fseek)
438
+ #define RTSAN_MAYBE_INTERCEPT_FSEEKO INTERCEPT_FUNCTION (fseeko)
439
+ #define RTSAN_MAYBE_INTERCEPT_FSETPOS INTERCEPT_FUNCTION (fsetpos)
440
+ #define RTSAN_MAYBE_INTERCEPT_FTELL INTERCEPT_FUNCTION (ftell)
441
+ #define RTSAN_MAYBE_INTERCEPT_FTELLO INTERCEPT_FUNCTION (ftello)
442
+ #define RTSAN_MAYBE_INTERCEPT_REWIND INTERCEPT_FUNCTION (rewind)
443
+ #if SANITIZER_LINUX && !SANITIZER_MUSL
444
+ #define RTSAN_MAYBE_INTERCEPT_FGETPOS64 INTERCEPT_FUNCTION (fgetpos64)
445
+ #define RTSAN_MAYBE_INTERCEPT_FSEEKO64 INTERCEPT_FUNCTION (fseeko64)
446
+ #define RTSAN_MAYBE_INTERCEPT_FSETPOS64 INTERCEPT_FUNCTION (fsetpos64)
447
+ #define RTSAN_MAYBE_INTERCEPT_FTELLO64 INTERCEPT_FUNCTION (ftello64)
448
+ #else
449
+ #define RTSAN_MAYBE_INTERCEPT_FGETPOS64
450
+ #define RTSAN_MAYBE_INTERCEPT_FSEEKO64
451
+ #define RTSAN_MAYBE_INTERCEPT_FSETPOS64
452
+ #define RTSAN_MAYBE_INTERCEPT_FTELLO64
453
+ #endif
454
+ #else
455
+ #define RTSAN_MAYBE_INTERCEPT_FGETPOS
456
+ #define RTSAN_MAYBE_INTERCEPT_FSEEK
457
+ #define RTSAN_MAYBE_INTERCEPT_FSEEKO
458
+ #define RTSAN_MAYBE_INTERCEPT_FSETPOS
459
+ #define RTSAN_MAYBE_INTERCEPT_FTELL
460
+ #define RTSAN_MAYBE_INTERCEPT_FTELLO
461
+ #define RTSAN_MAYBE_INTERCEPT_REWIND
462
+ #define RTSAN_MAYBE_INTERCEPT_FGETPOS64
463
+ #define RTSAN_MAYBE_INTERCEPT_FSEEKO64
464
+ #define RTSAN_MAYBE_INTERCEPT_FSETPOS64
465
+ #define RTSAN_MAYBE_INTERCEPT_FTELLO64
466
+ #endif
467
+
379
468
INTERCEPTOR (int , puts, const char *s) {
380
469
__rtsan_notify_intercepted_call (" puts" );
381
470
return REAL (puts)(s);
@@ -1042,6 +1131,17 @@ void __rtsan::InitializeInterceptors() {
1042
1131
RTSAN_MAYBE_INTERCEPT_SETVBUF;
1043
1132
RTSAN_MAYBE_INTERCEPT_SETLINEBUF;
1044
1133
RTSAN_MAYBE_INTERCEPT_SETBUFFER;
1134
+ RTSAN_MAYBE_INTERCEPT_FGETPOS;
1135
+ RTSAN_MAYBE_INTERCEPT_FSEEK;
1136
+ RTSAN_MAYBE_INTERCEPT_FSEEKO;
1137
+ RTSAN_MAYBE_INTERCEPT_FSETPOS;
1138
+ RTSAN_MAYBE_INTERCEPT_FTELL;
1139
+ RTSAN_MAYBE_INTERCEPT_FTELLO;
1140
+ RTSAN_MAYBE_INTERCEPT_REWIND;
1141
+ RTSAN_MAYBE_INTERCEPT_FGETPOS64;
1142
+ RTSAN_MAYBE_INTERCEPT_FSEEKO64;
1143
+ RTSAN_MAYBE_INTERCEPT_FSETPOS64;
1144
+ RTSAN_MAYBE_INTERCEPT_FTELLO64;
1045
1145
INTERCEPT_FUNCTION (lseek);
1046
1146
RTSAN_MAYBE_INTERCEPT_LSEEK64;
1047
1147
INTERCEPT_FUNCTION (dup);
0 commit comments