MemorySanitizer: address false positive
authorEmilia Kasper <emilia@openssl.org>
Mon, 22 Feb 2016 15:58:36 +0000 (16:58 +0100)
committerEmilia Kasper <emilia@openssl.org>
Mon, 22 Feb 2016 17:30:11 +0000 (18:30 +0100)
Explicitly unpoison the result of FD_ZERO

Tests now pass, using -fsanitize=memory

Reviewed-by: Rich Salz <rsalz@openssl.org>
apps/s_client.c

index 9d0b52a10f05cd8e62a5095047c27ddd5a43bcf5..b533780e287f03961291565c9b2fcb1bcaa9aaae 100644 (file)
@@ -173,6 +173,12 @@ typedef unsigned int u_int;
 # undef FIONBIO
 #endif
 
+#if defined(__has_feature)
+# if __has_feature(memory_sanitizer)
+#  include <sanitizer/msan_interface.h>
+# endif
+#endif
+
 #undef BUFSIZZ
 #define BUFSIZZ 1024*8
 #define S_CLIENT_IRC_READ_TIMEOUT 8
@@ -905,6 +911,16 @@ int s_client_main(int argc, char **argv)
     SRP_ARG srp_arg = { NULL, NULL, 0, 0, 0, 1024 };
 #endif
 
+    FD_ZERO(&readfds);
+    FD_ZERO(&writefds);
+/* Known false-positive of MemorySanitizer. */
+#if defined(__has_feature)
+# if __has_feature(memory_sanitizer)
+    __msan_unpoison(&readfds, sizeof(readfds));
+    __msan_unpoison(&writefds, sizeof(writefds));
+# endif
+#endif
+
     prog = opt_progname(argv[0]);
     c_quiet = 0;
     c_ign_eof = 0;