[compiler-rt] r319484 - [msan] Fix return type of mbrtowc
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 30 14:15:39 PST 2017
Author: vitalybuka
Date: Thu Nov 30 14:15:39 2017
New Revision: 319484
URL: http://llvm.org/viewvc/llvm-project?rev=319484&view=rev
Log:
[msan] Fix return type of mbrtowc
Summary: Fixes https://github.com/google/oss-fuzz/issues/1009
Reviewers: eugenis
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D40676
Modified:
compiler-rt/trunk/lib/msan/msan_interceptors.cc
compiler-rt/trunk/lib/msan/tests/msan_test.cc
Modified: compiler-rt/trunk/lib/msan/msan_interceptors.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan_interceptors.cc?rev=319484&r1=319483&r2=319484&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/msan/msan_interceptors.cc Thu Nov 30 14:15:39 2017
@@ -526,7 +526,8 @@ INTERCEPTOR(int, mbtowc, wchar_t *dest,
return res;
}
-INTERCEPTOR(int, mbrtowc, wchar_t *dest, const char *src, SIZE_T n, void *ps) {
+INTERCEPTOR(SIZE_T, mbrtowc, wchar_t *dest, const char *src, SIZE_T n,
+ void *ps) {
ENSURE_MSAN_INITED();
SIZE_T res = REAL(mbrtowc)(dest, src, n, ps);
if (res != (SIZE_T)-1 && dest) __msan_unpoison(dest, sizeof(wchar_t));
Modified: compiler-rt/trunk/lib/msan/tests/msan_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/tests/msan_test.cc?rev=319484&r1=319483&r2=319484&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/tests/msan_test.cc (original)
+++ compiler-rt/trunk/lib/msan/tests/msan_test.cc Thu Nov 30 14:15:39 2017
@@ -2121,13 +2121,15 @@ TEST(MemorySanitizer, mbtowc) {
}
TEST(MemorySanitizer, mbrtowc) {
- const char *x = "abc";
- wchar_t wx;
- mbstate_t mbs;
- memset(&mbs, 0, sizeof(mbs));
- int res = mbrtowc(&wx, x, 3, &mbs);
- EXPECT_GT(res, 0);
- EXPECT_NOT_POISONED(wx);
+ mbstate_t mbs = {};
+
+ wchar_t wc;
+ size_t res = mbrtowc(&wc, "\377", 1, &mbs);
+ EXPECT_EQ(res, -1ULL);
+
+ res = mbrtowc(&wc, "abc", 3, &mbs);
+ EXPECT_GT(res, 0ULL);
+ EXPECT_NOT_POISONED(wc);
}
TEST(MemorySanitizer, wcsftime) {
More information about the llvm-commits
mailing list