[compiler-rt] Fix compiler warnings and runtime errors in sanitizer RT strxfrm(_l...
authorDokyung Song <dokyungs@google.com>
Mon, 13 Jul 2020 21:56:02 +0000 (21:56 +0000)
committerMatt Morehouse <mascasa@google.com>
Mon, 13 Jul 2020 22:35:01 +0000 (22:35 +0000)
Summary: Fixed an implicit definition warning by including <string.h>. Also fixed run-time assertions that the return value of strxfrm_l calls is less than the buffer size by increasing the size of the referenced buffer.

Reviewers: morehouse

Reviewed By: morehouse

Subscribers: dberris, #sanitizers

Tags: #sanitizers

Differential Revision: https://reviews.llvm.org/D83593

compiler-rt/test/msan/__strxfrm_l.cpp
compiler-rt/test/sanitizer_common/TestCases/Posix/strxfrm.c

index c4eb10e..9766d33 100644 (file)
@@ -10,7 +10,7 @@
 extern "C" decltype(strxfrm_l) __strxfrm_l;
 
 int main(void) {
-  char q[10];
+  char q[100];
   locale_t loc = newlocale(LC_ALL_MASK, "", (locale_t)0);
   size_t n = __strxfrm_l(q, "qwerty", sizeof(q), loc);
   assert(n < sizeof(q));
index c28eb65..d08af1b 100644 (file)
@@ -3,16 +3,16 @@
 
 #include <assert.h>
 #include <locale.h>
-#include <wchar.h>
+#include <string.h>
 
 int main(int argc, char **argv) {
   char q[10];
   size_t n = strxfrm(q, "abcdef", sizeof(q));
   assert(n < sizeof(q));
 
-  char q2[10];
+  char q2[100];
   locale_t loc = newlocale(LC_ALL_MASK, "", (locale_t)0);
-  n = strxfrm_l(q2, L"qwerty", sizeof(q), loc);
+  n = strxfrm_l(q2, "qwerty", sizeof(q2), loc);
   assert(n < sizeof(q2));
 
   freelocale(loc);