[PATCH] D27118: [sanitizers] Get the proper printf/scanf version when long double transition is involved.
Marcin Kościelnicki via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 28 13:25:26 PST 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL288064: [sanitizers] Get the proper printf/scanf version when long double transition is… (authored by koriakin).
Changed prior to commit:
https://reviews.llvm.org/D27118?vs=79265&id=79445#toc
Repository:
rL LLVM
https://reviews.llvm.org/D27118
Files:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
compiler-rt/trunk/test/sanitizer_common/TestCases/printf-ldbl.c
compiler-rt/trunk/test/sanitizer_common/TestCases/scanf-ldbl.c
Index: compiler-rt/trunk/test/sanitizer_common/TestCases/printf-ldbl.c
===================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/printf-ldbl.c
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/printf-ldbl.c
@@ -0,0 +1,13 @@
+// RUN: %clang %s -o %t && %run %t 2>&1
+
+#include <assert.h>
+#include <stdio.h>
+#include <string.h>
+
+int main(int argc, char **argv) {
+ char buf[20];
+ long double ld = 4.0;
+ snprintf(buf, sizeof buf, "%Lf %d", ld, 123);
+ assert(!strcmp(buf, "4.000000 123"));
+ return 0;
+}
Index: compiler-rt/trunk/test/sanitizer_common/TestCases/scanf-ldbl.c
===================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/scanf-ldbl.c
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/scanf-ldbl.c
@@ -0,0 +1,13 @@
+// RUN: %clang %s -o %t && %run %t 2>&1
+
+#include <assert.h>
+#include <stdio.h>
+#include <string.h>
+
+int main(int argc, char **argv) {
+ long double ld;
+ memset(&ld, 255, sizeof ld);
+ sscanf("4.0", "%Lf", &ld);
+ assert(ld == 4.0);
+ return 0;
+}
Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
===================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -1239,12 +1239,12 @@
#if SANITIZER_INTERCEPT_SCANF
#define INIT_SCANF \
- COMMON_INTERCEPT_FUNCTION(scanf); \
- COMMON_INTERCEPT_FUNCTION(sscanf); \
- COMMON_INTERCEPT_FUNCTION(fscanf); \
- COMMON_INTERCEPT_FUNCTION(vscanf); \
- COMMON_INTERCEPT_FUNCTION(vsscanf); \
- COMMON_INTERCEPT_FUNCTION(vfscanf);
+ COMMON_INTERCEPT_FUNCTION_LDBL(scanf); \
+ COMMON_INTERCEPT_FUNCTION_LDBL(sscanf); \
+ COMMON_INTERCEPT_FUNCTION_LDBL(fscanf); \
+ COMMON_INTERCEPT_FUNCTION_LDBL(vscanf); \
+ COMMON_INTERCEPT_FUNCTION_LDBL(vsscanf); \
+ COMMON_INTERCEPT_FUNCTION_LDBL(vfscanf);
#else
#define INIT_SCANF
#endif
@@ -1417,16 +1417,16 @@
#if SANITIZER_INTERCEPT_PRINTF
#define INIT_PRINTF \
- COMMON_INTERCEPT_FUNCTION(printf); \
- COMMON_INTERCEPT_FUNCTION(sprintf); \
- COMMON_INTERCEPT_FUNCTION(snprintf); \
- COMMON_INTERCEPT_FUNCTION(asprintf); \
- COMMON_INTERCEPT_FUNCTION(fprintf); \
- COMMON_INTERCEPT_FUNCTION(vprintf); \
- COMMON_INTERCEPT_FUNCTION(vsprintf); \
- COMMON_INTERCEPT_FUNCTION(vsnprintf); \
- COMMON_INTERCEPT_FUNCTION(vasprintf); \
- COMMON_INTERCEPT_FUNCTION(vfprintf);
+ COMMON_INTERCEPT_FUNCTION_LDBL(printf); \
+ COMMON_INTERCEPT_FUNCTION_LDBL(sprintf); \
+ COMMON_INTERCEPT_FUNCTION_LDBL(snprintf); \
+ COMMON_INTERCEPT_FUNCTION_LDBL(asprintf); \
+ COMMON_INTERCEPT_FUNCTION_LDBL(fprintf); \
+ COMMON_INTERCEPT_FUNCTION_LDBL(vprintf); \
+ COMMON_INTERCEPT_FUNCTION_LDBL(vsprintf); \
+ COMMON_INTERCEPT_FUNCTION_LDBL(vsnprintf); \
+ COMMON_INTERCEPT_FUNCTION_LDBL(vasprintf); \
+ COMMON_INTERCEPT_FUNCTION_LDBL(vfprintf);
#else
#define INIT_PRINTF
#endif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27118.79445.patch
Type: text/x-patch
Size: 3126 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161128/298ba243/attachment.bin>
More information about the llvm-commits
mailing list