diff options
author | Simon Rettberg | 2014-06-02 15:00:15 +0200 |
---|---|---|
committer | Simon Rettberg | 2014-06-02 15:00:15 +0200 |
commit | 841e3e35937d942f4456d73070de32a0247eca46 (patch) | |
tree | 5451b84197a7091faac267fa21c6d028f8aa56e9 | |
parent | Fix getaddrinfo call (diff) | |
download | ldadp-841e3e35937d942f4456d73070de32a0247eca46.tar.gz ldadp-841e3e35937d942f4456d73070de32a0247eca46.tar.xz ldadp-841e3e35937d942f4456d73070de32a0247eca46.zip |
Actually really fix helper_connect4 when passing a hostname
-rw-r--r-- | helper.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -65,10 +65,12 @@ int helper_connect4(char *address, int port, char *ip) for (rp = result; rp != NULL; rp = rp->ai_next) { const int sock = socket_tcp4b(); if (sock == -1) continue; - memcpy(ip, rp->ai_addr->sa_data, 4); - if (socket_connect4(sock, ip, port) == 0) { - freeaddrinfo(result); - return sock; // Success + if (rp->ai_addr != NULL) { + memcpy(ip, &((struct sockaddr_in*)rp->ai_addr)->sin_addr, 4); + if (socket_connect4(sock, ip, port) == 0) { + freeaddrinfo(result); + return sock; // Success + } } close(sock); } |