summaryrefslogtreecommitdiff
path: root/canohost.c
diff options
context:
space:
mode:
Diffstat (limited to 'canohost.c')
-rw-r--r--canohost.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/canohost.c b/canohost.c
index 9aa942a9f..941db23b6 100644
--- a/canohost.c
+++ b/canohost.c
@@ -59,11 +59,14 @@ get_remote_hostname(int socket, int verify_reverse_mapping)
59 memset(&from, 0, sizeof(from)); 59 memset(&from, 0, sizeof(from));
60 60
61 from4->sin_family = AF_INET; 61 from4->sin_family = AF_INET;
62 fromlen = sizeof(*from4);
62 memcpy(&from4->sin_addr, &addr, sizeof(addr)); 63 memcpy(&from4->sin_addr, &addr, sizeof(addr));
63 from4->sin_port = port; 64 from4->sin_port = port;
64 } 65 }
65 } 66 }
66#endif 67#endif
68 if (from.ss_family == AF_INET6)
69 fromlen = sizeof(struct sockaddr_in6);
67 70
68 if (getnameinfo((struct sockaddr *)&from, fromlen, ntop, sizeof(ntop), 71 if (getnameinfo((struct sockaddr *)&from, fromlen, ntop, sizeof(ntop),
69 NULL, 0, NI_NUMERICHOST) != 0) 72 NULL, 0, NI_NUMERICHOST) != 0)
@@ -225,6 +228,11 @@ get_socket_address(int socket, int remote, int flags)
225 < 0) 228 < 0)
226 return NULL; 229 return NULL;
227 } 230 }
231
232 /* Work around Linux IPv6 weirdness */
233 if (addr.ss_family == AF_INET6)
234 addrlen = sizeof(struct sockaddr_in6);
235
228 /* Get the address in ascii. */ 236 /* Get the address in ascii. */
229 if (getnameinfo((struct sockaddr *)&addr, addrlen, ntop, sizeof(ntop), 237 if (getnameinfo((struct sockaddr *)&addr, addrlen, ntop, sizeof(ntop),
230 NULL, 0, flags) != 0) { 238 NULL, 0, flags) != 0) {
@@ -319,6 +327,11 @@ get_sock_port(int sock, int local)
319 fatal_cleanup(); 327 fatal_cleanup();
320 } 328 }
321 } 329 }
330
331 /* Work around Linux IPv6 weirdness */
332 if (from.ss_family == AF_INET6)
333 fromlen = sizeof(struct sockaddr_in6);
334
322 /* Return port number. */ 335 /* Return port number. */
323 if (getnameinfo((struct sockaddr *)&from, fromlen, NULL, 0, 336 if (getnameinfo((struct sockaddr *)&from, fromlen, NULL, 0,
324 strport, sizeof(strport), NI_NUMERICSERV) != 0) 337 strport, sizeof(strport), NI_NUMERICSERV) != 0)