From: octo Date: Mon, 30 Jan 2006 08:38:11 +0000 (+0000) Subject: Initialize `addrlen' before using. This might be the reason for `getnameinfo' failing.. X-Git-Tag: collectd-3.7.0~5 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=9f83cfeb5cb6c8cce71601a343a357d2563e00bd;p=collectd.git Initialize `addrlen' before using. This might be the reason for `getnameinfo' failing.. --- diff --git a/src/network.c b/src/network.c index 3a88b605..3fe25fd4 100644 --- a/src/network.c +++ b/src/network.c @@ -163,7 +163,7 @@ int network_create_socket (const char *node, const char *service) ai_hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG; ai_hints.ai_family = PF_UNSPEC; ai_hints.ai_socktype = SOCK_DGRAM; - ai_hints.ai_protocol = IPPROTO_UDP; /* XXX is this right here?!? */ + ai_hints.ai_protocol = IPPROTO_UDP; if ((ai_return = getaddrinfo (node, service, &ai_hints, &ai_list)) != 0) { @@ -346,6 +346,7 @@ int network_receive (char **host, char **type, char **inst, char **value) if ((fd = network_get_listen_socket ()) < 0) return (-1); + addrlen = sizeof (addr); if (recvfrom (fd, buffer, BUFF_SIZE, 0, (struct sockaddr *) &addr, &addrlen) == -1) { syslog (LOG_ERR, "recvfrom: %s", strerror (errno));