[PATCH] D46545: [sanitizer] Add fgets, fputs and puts into sanitizer_common
Peter Wu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 11 15:59:43 PDT 2018
Lekensteyn updated this revision to Diff 150866.
Lekensteyn marked an inline comment as done.
Lekensteyn added a comment.
Thanks Vitaly, that's a very useful tool!
This version only has whitespace changes:
--- a/lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ b/lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -1190,7 +1190,7 @@ INTERCEPTOR(SSIZE_T, pwritev64, int fd, __sanitizer_iovec *iov, int iovcnt,
#endif
#if SANITIZER_INTERCEPT_FGETS
-INTERCEPTOR(char*, fgets, char *s, SIZE_T size, void *file) {
+INTERCEPTOR(char *, fgets, char *s, SIZE_T size, void *file) {
// libc file streams can call user-supplied functions, see fopencookie.
void *ctx;
COMMON_INTERCEPTOR_ENTER(ctx, fgets, s, size, file);
@@ -1198,7 +1198,8 @@ INTERCEPTOR(char*, fgets, char *s, SIZE_T size, void *file) {
// its metadata. See
// https://github.com/google/sanitizers/issues/321.
char *res = REAL(fgets)(s, size, file);
- if (res) COMMON_INTERCEPTOR_WRITE_RANGE(ctx, s, REAL(strlen)(s) + 1);
+ if (res)
+ COMMON_INTERCEPTOR_WRITE_RANGE(ctx, s, REAL(strlen)(s) + 1);
return res;
}
#define INIT_FGETS COMMON_INTERCEPT_FUNCTION(fgets)
--- a/test/asan/TestCases/Posix/fgets_fputs.cc
+++ b/test/asan/TestCases/Posix/fgets_fputs.cc
@@ -17,8 +17,8 @@ int test_fgets() {
int test_fputs() {
FILE *fp = fopen("/dev/null", "w");
- char buf[1] = { 'x' }; // Note: not nul-terminated
- fputs(buf, fp); // BOOM
+ char buf[1] = {'x'}; // Note: not nul-terminated
+ fputs(buf, fp); // BOOM
return fclose(fp);
}
https://reviews.llvm.org/D46545
Files:
lib/esan/esan_interceptors.cpp
lib/msan/msan_interceptors.cc
lib/sanitizer_common/sanitizer_common_interceptors.inc
lib/sanitizer_common/sanitizer_platform_interceptors.h
lib/tsan/rtl/tsan_interceptors.cc
test/asan/TestCases/Posix/fgets_fputs.cc
test/msan/fgets_fputs.cc
test/sanitizer_common/TestCases/Posix/fgets.cc
test/sanitizer_common/TestCases/Posix/fputs_puts.cc
test/tsan/race_on_fputs.cc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46545.150866.patch
Type: text/x-patch
Size: 9453 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180611/197e808e/attachment.bin>
More information about the llvm-commits
mailing list