diff options
Diffstat (limited to 'canohost.c')
-rw-r--r-- | canohost.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/canohost.c b/canohost.c index 8ad684d6c..1c22d4770 100644 --- a/canohost.c +++ b/canohost.c | |||
@@ -12,7 +12,7 @@ | |||
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include "includes.h" | 14 | #include "includes.h" |
15 | RCSID("$OpenBSD: canohost.c,v 1.41 2004/07/21 11:51:29 djm Exp $"); | 15 | RCSID("$OpenBSD: canohost.c,v 1.42 2005/02/18 03:05:53 djm Exp $"); |
16 | 16 | ||
17 | #include "packet.h" | 17 | #include "packet.h" |
18 | #include "xmalloc.h" | 18 | #include "xmalloc.h" |
@@ -20,7 +20,6 @@ RCSID("$OpenBSD: canohost.c,v 1.41 2004/07/21 11:51:29 djm Exp $"); | |||
20 | #include "canohost.h" | 20 | #include "canohost.h" |
21 | 21 | ||
22 | static void check_ip_options(int, char *); | 22 | static void check_ip_options(int, char *); |
23 | static void ipv64_normalise_mapped(struct sockaddr_storage *, socklen_t *); | ||
24 | 23 | ||
25 | /* | 24 | /* |
26 | * Return the canonical name of the host at the other end of the socket. The | 25 | * Return the canonical name of the host at the other end of the socket. The |
@@ -166,7 +165,7 @@ check_ip_options(int sock, char *ipaddr) | |||
166 | #endif /* IP_OPTIONS */ | 165 | #endif /* IP_OPTIONS */ |
167 | } | 166 | } |
168 | 167 | ||
169 | static void | 168 | void |
170 | ipv64_normalise_mapped(struct sockaddr_storage *addr, socklen_t *len) | 169 | ipv64_normalise_mapped(struct sockaddr_storage *addr, socklen_t *len) |
171 | { | 170 | { |
172 | struct sockaddr_in6 *a6 = (struct sockaddr_in6 *)addr; | 171 | struct sockaddr_in6 *a6 = (struct sockaddr_in6 *)addr; |
@@ -232,6 +231,7 @@ get_socket_address(int sock, int remote, int flags) | |||
232 | struct sockaddr_storage addr; | 231 | struct sockaddr_storage addr; |
233 | socklen_t addrlen; | 232 | socklen_t addrlen; |
234 | char ntop[NI_MAXHOST]; | 233 | char ntop[NI_MAXHOST]; |
234 | int r; | ||
235 | 235 | ||
236 | /* Get IP address of client. */ | 236 | /* Get IP address of client. */ |
237 | addrlen = sizeof(addr); | 237 | addrlen = sizeof(addr); |
@@ -252,9 +252,10 @@ get_socket_address(int sock, int remote, int flags) | |||
252 | addrlen = sizeof(struct sockaddr_in6); | 252 | addrlen = sizeof(struct sockaddr_in6); |
253 | 253 | ||
254 | /* Get the address in ascii. */ | 254 | /* Get the address in ascii. */ |
255 | if (getnameinfo((struct sockaddr *)&addr, addrlen, ntop, sizeof(ntop), | 255 | if ((r = getnameinfo((struct sockaddr *)&addr, addrlen, ntop, |
256 | NULL, 0, flags) != 0) { | 256 | sizeof(ntop), NULL, 0, flags)) != 0) { |
257 | error("get_socket_address: getnameinfo %d failed", flags); | 257 | error("get_socket_address: getnameinfo %d failed: %s", flags, |
258 | r == EAI_SYSTEM ? strerror(errno) : gai_strerror(r)); | ||
258 | return NULL; | 259 | return NULL; |
259 | } | 260 | } |
260 | return xstrdup(ntop); | 261 | return xstrdup(ntop); |
@@ -330,6 +331,7 @@ get_sock_port(int sock, int local) | |||
330 | struct sockaddr_storage from; | 331 | struct sockaddr_storage from; |
331 | socklen_t fromlen; | 332 | socklen_t fromlen; |
332 | char strport[NI_MAXSERV]; | 333 | char strport[NI_MAXSERV]; |
334 | int r; | ||
333 | 335 | ||
334 | /* Get IP address of client. */ | 336 | /* Get IP address of client. */ |
335 | fromlen = sizeof(from); | 337 | fromlen = sizeof(from); |
@@ -351,9 +353,10 @@ get_sock_port(int sock, int local) | |||
351 | fromlen = sizeof(struct sockaddr_in6); | 353 | fromlen = sizeof(struct sockaddr_in6); |
352 | 354 | ||
353 | /* Return port number. */ | 355 | /* Return port number. */ |
354 | if (getnameinfo((struct sockaddr *)&from, fromlen, NULL, 0, | 356 | if ((r = getnameinfo((struct sockaddr *)&from, fromlen, NULL, 0, |
355 | strport, sizeof(strport), NI_NUMERICSERV) != 0) | 357 | strport, sizeof(strport), NI_NUMERICSERV)) != 0) |
356 | fatal("get_sock_port: getnameinfo NI_NUMERICSERV failed"); | 358 | fatal("get_sock_port: getnameinfo NI_NUMERICSERV failed: %s", |
359 | r == EAI_SYSTEM ? strerror(errno) : gai_strerror(r)); | ||
357 | return atoi(strport); | 360 | return atoi(strport); |
358 | } | 361 | } |
359 | 362 | ||