Browse code

clamd: Fix potential null pointer dereference crash if HAVE_GETNAMEINFO is not defined.

Mark Pizzolato authored on 2014/11/27 07:58:21
Showing 1 changed files
... ...
@@ -112,8 +112,11 @@ int tcpserver(int **lsockets, unsigned int *nlsockets, char *ipaddr, const struc
112 112
             serv[0] = '\0';
113 113
         }
114 114
 #else
115
-        strncpy(host, ipaddr, sizeof(host));
116
-        host[sizeof(host)-1] = '\0';
115
+		if (ipaddr) {
116
+			strncpy(host, ipaddr, sizeof(host));
117
+			host[sizeof(host)-1] = '\0';
118
+		} else
119
+			host[0] = '\0';
117 120
         snprintf(serv, sizeof(serv), "%u", (unsigned int)(optget(opts, "TCPSocket")->numarg));
118 121
 #endif
119 122
         if(bind(sockfd, p->ai_addr, p->ai_addrlen) == -1) {