mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-13 22:00:14 +00:00
[sanitizer] Improve getaddrinfo interceptor.
llvm-svn: 182775
This commit is contained in:
parent
dd0780f81c
commit
40d7ed5d1e
@ -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]]
|
||||
|
@ -760,10 +760,11 @@ INTERCEPTOR(int, getaddrinfo, char *node, char *service,
|
||||
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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user