forked from OSchip/llvm-project
[Sanitizer] Fix setbuffer() interceptor (it accept size, not mode)
Fixes: 0c81a62d9d
("[Sanitizer] Adding setvbuf in supported platforms and other stream buffer functions")
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D116176
This commit is contained in:
parent
ba6973c89b
commit
856550ca79
|
@ -7857,12 +7857,12 @@ INTERCEPTOR(void, setbuf, __sanitizer_FILE *stream, char *buf) {
|
|||
unpoison_file(stream);
|
||||
}
|
||||
|
||||
INTERCEPTOR(void, setbuffer, __sanitizer_FILE *stream, char *buf, int mode) {
|
||||
INTERCEPTOR(void, setbuffer, __sanitizer_FILE *stream, char *buf, SIZE_T size) {
|
||||
void *ctx;
|
||||
COMMON_INTERCEPTOR_ENTER(ctx, setbuffer, stream, buf, mode);
|
||||
REAL(setbuffer)(stream, buf, mode);
|
||||
COMMON_INTERCEPTOR_ENTER(ctx, setbuffer, stream, buf, size);
|
||||
REAL(setbuffer)(stream, buf, size);
|
||||
if (buf) {
|
||||
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, buf, __sanitizer_bufsiz);
|
||||
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, buf, size);
|
||||
}
|
||||
if (stream)
|
||||
unpoison_file(stream);
|
||||
|
|
|
@ -34,7 +34,9 @@ void test_setbuffer() {
|
|||
|
||||
print_something();
|
||||
|
||||
setbuffer(stdout, buf, BUFSIZ);
|
||||
// Ensure that interceptor reads correct size
|
||||
// (not BUFSIZ as by default, hence BUFSIZ/2).
|
||||
setbuffer(stdout, buf, BUFSIZ / 2);
|
||||
|
||||
print_something();
|
||||
|
||||
|
|
Loading…
Reference in New Issue