Zero all the hints before calling getaddrinfo. - irc - Unnamed repository; edit… | |
git clone git://vernunftzentrum.de/irc.git | |
Log | |
Files | |
Refs | |
README | |
--- | |
commit 15ec7fd992fc9943740da3d90aec084e13b4392e | |
parent 3597152e7424b24233a60fe1b7492e8ee178d08f | |
Author: Quentin Carbonneaux <[email protected]> | |
Date: Thu, 15 Mar 2012 00:42:39 +0100 | |
Zero all the hints before calling getaddrinfo. | |
Testing the program on NetBSD made getaddrinfo whine because all non | |
filled elements of the struct addrinfo given as hints must be zeros (or | |
null pointers). Except this point, irc.c seems to work like charm on | |
NetBSD. | |
Diffstat: | |
irc.c | 3 +-- | |
1 file changed, 1 insertion(+), 2 deletions(-) | |
--- | |
diff --git a/irc.c b/irc.c | |
@@ -119,11 +119,10 @@ dial(const char *host, short port) | |
{ | |
int f; | |
struct sockaddr_in sin; | |
- struct addrinfo *ai, hai; | |
+ struct addrinfo *ai, hai = { 0 }; | |
hai.ai_family = AF_INET; | |
hai.ai_socktype = SOCK_STREAM; | |
- hai.ai_flags = hai.ai_protocol = 0; | |
if (getaddrinfo(host, 0, &hai, &ai)) | |
panic("Cannot resolve host."); | |
memcpy(&sin, ai->ai_addr, sizeof sin); |