@@ -244,14 +244,28 @@ INTERCEPTOR(FILE *, fopen, const char *path, const char *mode) {
244244 return REAL (fopen)(path, mode);
245245}
246246
247+ INTERCEPTOR (FILE *, freopen, const char *path, const char *mode, FILE *stream) {
248+ __rtsan_notify_intercepted_call (" freopen" );
249+ return REAL (freopen)(path, mode, stream);
250+ }
251+
252+ // Streams
253+
247254#if SANITIZER_INTERCEPT_FOPEN64
248255INTERCEPTOR (FILE *, fopen64, const char *path, const char *mode) {
249256 __rtsan_notify_intercepted_call (" fopen64" );
250257 return REAL (fopen64)(path, mode);
251258}
252- #define RTSAN_MAYBE_INTERCEPT_FOPEN64 INTERCEPT_FUNCTION (fopen64)
259+
260+ INTERCEPTOR (FILE *, freopen64, const char *path, const char *mode, FILE *stream) {
261+ __rtsan_notify_intercepted_call (" freopen64" );
262+ return REAL (freopen64)(path, mode, stream);
263+ }
264+ #define RTSAN_MAYBE_INTERCEPT_FOPEN64 INTERCEPT_FUNCTION (fopen64);
265+ #define RTSAN_MAYBE_INTERCEPT_FREOPEN64 INTERCEPT_FUNCTION (freopen64);
253266#else
254267#define RTSAN_MAYBE_INTERCEPT_FOPEN64
268+ #define RTSAN_MAYBE_INTERCEPT_FREOPEN64
255269#endif // SANITIZER_INTERCEPT_FOPEN64
256270
257271INTERCEPTOR (size_t , fread, void *ptr, size_t size, size_t nitems,
@@ -276,7 +290,11 @@ INTERCEPTOR(int, fputs, const char *s, FILE *stream) {
276290 return REAL (fputs)(s, stream);
277291}
278292
279- // Streams
293+ INTERCEPTOR (FILE *, fdopen, int fd, const char *mode) {
294+ __rtsan_notify_intercepted_call (" fdopen" );
295+ return REAL (fdopen)(fd, mode);
296+ }
297+
280298INTERCEPTOR (int , puts, const char *s) {
281299 __rtsan_notify_intercepted_call (" puts" );
282300 return REAL (puts)(s);
@@ -904,6 +922,7 @@ void __rtsan::InitializeInterceptors() {
904922 INTERCEPT_FUNCTION (close);
905923 INTERCEPT_FUNCTION (fopen);
906924 RTSAN_MAYBE_INTERCEPT_FOPEN64;
925+ RTSAN_MAYBE_INTERCEPT_FREOPEN64;
907926 INTERCEPT_FUNCTION (fread);
908927 INTERCEPT_FUNCTION (read);
909928 INTERCEPT_FUNCTION (write);
@@ -921,6 +940,8 @@ void __rtsan::InitializeInterceptors() {
921940 RTSAN_MAYBE_INTERCEPT_CREAT64;
922941 INTERCEPT_FUNCTION (puts);
923942 INTERCEPT_FUNCTION (fputs);
943+ INTERCEPT_FUNCTION (fdopen);
944+ INTERCEPT_FUNCTION (freopen);
924945 INTERCEPT_FUNCTION (lseek);
925946 RTSAN_MAYBE_INTERCEPT_LSEEK64;
926947 INTERCEPT_FUNCTION (dup);
0 commit comments