From 037edbcb8ec34bf4a1966be139417ce64ebe535c Mon Sep 17 00:00:00 2001 From: rofl0r Date: Mon, 16 Jul 2012 01:19:30 +0200 Subject: [PATCH] proxy_getaddrinfo: fix segfault when hints is NULL --- src/core.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/core.c b/src/core.c index c0d48cf..7217b0d 100644 --- a/src/core.c +++ b/src/core.c @@ -878,10 +878,16 @@ int proxy_getaddrinfo(const char *node, const char *service, const struct addrin (*res)->ai_canonname = space->addr_name; (*res)->ai_next = NULL; (*res)->ai_family = space->sockaddr_space.sa_family = AF_INET; - (*res)->ai_socktype = hints->ai_socktype; - (*res)->ai_flags = hints->ai_flags; - (*res)->ai_protocol = hints->ai_protocol; (*res)->ai_addrlen = sizeof(space->sockaddr_space); + + if(hints) { + (*res)->ai_socktype = hints->ai_socktype; + (*res)->ai_flags = hints->ai_flags; + (*res)->ai_protocol = hints->ai_protocol; + } else { + (*res)->ai_flags = (AI_V4MAPPED | AI_ADDRCONFIG); + } + goto out; err2: free(space);