[compiler-rt] r182775 - [sanitizer] Improve getaddrinfo interceptor.
Evgeniy Stepanov
eugeni.stepanov at gmail.com
Tue May 28 07:34:37 PDT 2013
Author: eugenis
Date: Tue May 28 09:34:37 2013
New Revision: 182775
URL: http://llvm.org/viewvc/llvm-project?rev=182775&view=rev
Log:
[sanitizer] Improve getaddrinfo interceptor.
Modified:
compiler-rt/trunk/lib/msan/lit_tests/getaddrinfo-positive.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
Modified: compiler-rt/trunk/lib/msan/lit_tests/getaddrinfo-positive.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/lit_tests/getaddrinfo-positive.cc?rev=182775&r1=182774&r2=182775&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/lit_tests/getaddrinfo-positive.cc (original)
+++ compiler-rt/trunk/lib/msan/lit_tests/getaddrinfo-positive.cc Tue May 28 09:34:37 2013
@@ -8,10 +8,14 @@
#include <netdb.h>
#include <stdlib.h>
+volatile int z;
+
int main(void) {
struct addrinfo *ai;
struct addrinfo hint;
- int res = getaddrinfo("localhost", NULL, &hint, &ai);
+ int res = getaddrinfo("localhost", NULL, NULL, &ai);
+ if (ai) z = 1; // OK
+ res = getaddrinfo("localhost", NULL, &hint, &ai);
// CHECK: UMR in __interceptor_getaddrinfo at offset 0 inside
// CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
// CHECK: #0 {{.*}} in main {{.*}}getaddrinfo-positive.cc:[[@LINE-3]]
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc?rev=182775&r1=182774&r2=182775&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc Tue May 28 09:34:37 2013
@@ -760,10 +760,11 @@ INTERCEPTOR(int, getaddrinfo, char *node
if (hints)
COMMON_INTERCEPTOR_READ_RANGE(ctx, hints, sizeof(__sanitizer_addrinfo));
int res = REAL(getaddrinfo)(node, service, hints, out);
- if (res == 0) {
+ if (res == 0 && out) {
+ COMMON_INTERCEPTOR_WRITE_RANGE(ctx, out, sizeof(*out));
struct __sanitizer_addrinfo *p = *out;
while (p) {
- COMMON_INTERCEPTOR_WRITE_RANGE(ctx, p, sizeof(__sanitizer_addrinfo));
+ COMMON_INTERCEPTOR_WRITE_RANGE(ctx, p, sizeof(*p));
if (p->ai_addr)
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, p->ai_addr, struct_sockaddr_sz);
if (p->ai_canonname)
More information about the llvm-commits
mailing list