@@ -325,6 +325,37 @@ INTERCEPTOR(FILE *, fmemopen, void *buf, size_t size, const char *mode) {
325325#define RTSAN_MAYBE_INTERCEPT_FMEMOPEN
326326#endif
327327
328+ #if SANITIZER_INTERCEPT_SETVBUF
329+ INTERCEPTOR (void , setbuf, FILE *stream, char *buf) {
330+ __rtsan_notify_intercepted_call (" setbuf" );
331+ return REAL (setbuf)(stream, buf);
332+ }
333+
334+ INTERCEPTOR (void , setbuffer, FILE *stream, char *buf, size_t size) {
335+ __rtsan_notify_intercepted_call (" setbuffer" );
336+ return REAL (setbuffer)(stream, buf, size);
337+ }
338+
339+ INTERCEPTOR (void , setlinebuf, FILE *stream) {
340+ __rtsan_notify_intercepted_call (" setlinebuf" );
341+ return REAL (setlinebuf)(stream);
342+ }
343+
344+ INTERCEPTOR (int , setvbuf, FILE *stream, char *buf, int mode, size_t size) {
345+ __rtsan_notify_intercepted_call (" setvbuf" );
346+ return REAL (setvbuf)(stream, buf, mode, size);
347+ }
348+ #define RTSAN_MAYBE_INTERCEPT_SETBUF INTERCEPT_FUNCTION (setbuf)
349+ #define RTSAN_MAYBE_INTERCEPT_SETBUFFER INTERCEPT_FUNCTION (setbuffer)
350+ #define RTSAN_MAYBE_INTERCEPT_SETLINEBUF INTERCEPT_FUNCTION (setlinebuf)
351+ #define RTSAN_MAYBE_INTERCEPT_SETVBUF INTERCEPT_FUNCTION (setvbuf)
352+ #else
353+ #define RTSAN_MAYBE_INTERCEPT_SETBUF
354+ #define RTSAN_MAYBE_INTERCEPT_SETBUFFER
355+ #define RTSAN_MAYBE_INTERCEPT_SETLINEBUF
356+ #define RTSAN_MAYBE_INTERCEPT_SETVBUF
357+ #endif
358+
328359INTERCEPTOR (int , puts, const char *s) {
329360 __rtsan_notify_intercepted_call (" puts" );
330361 return REAL (puts)(s);
@@ -986,6 +1017,10 @@ void __rtsan::InitializeInterceptors() {
9861017 RTSAN_MAYBE_INTERCEPT_FOPENCOOKIE;
9871018 RTSAN_MAYBE_INTERCEPT_OPEN_MEMSTREAM;
9881019 RTSAN_MAYBE_INTERCEPT_FMEMOPEN;
1020+ RTSAN_MAYBE_INTERCEPT_SETBUF;
1021+ RTSAN_MAYBE_INTERCEPT_SETBUFFER;
1022+ RTSAN_MAYBE_INTERCEPT_SETLINEBUF;
1023+ RTSAN_MAYBE_INTERCEPT_SETVBUF;
9891024 INTERCEPT_FUNCTION (lseek);
9901025 RTSAN_MAYBE_INTERCEPT_LSEEK64;
9911026 INTERCEPT_FUNCTION (dup);
0 commit comments