diff options
Diffstat (limited to 'canohost.c')
-rw-r--r-- | canohost.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/canohost.c b/canohost.c index 8081ed598..a457d3c52 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.33 2002/07/09 11:56:27 itojun Exp $"); | 15 | RCSID("$OpenBSD: canohost.c,v 1.34 2002/09/23 20:46:27 stevesk Exp $"); |
16 | 16 | ||
17 | #include "packet.h" | 17 | #include "packet.h" |
18 | #include "xmalloc.h" | 18 | #include "xmalloc.h" |
@@ -218,18 +218,12 @@ get_socket_address(int socket, int remote, int flags) | |||
218 | 218 | ||
219 | if (remote) { | 219 | if (remote) { |
220 | if (getpeername(socket, (struct sockaddr *)&addr, &addrlen) | 220 | if (getpeername(socket, (struct sockaddr *)&addr, &addrlen) |
221 | < 0) { | 221 | < 0) |
222 | debug("get_socket_ipaddr: getpeername failed: %.100s", | ||
223 | strerror(errno)); | ||
224 | return NULL; | 222 | return NULL; |
225 | } | ||
226 | } else { | 223 | } else { |
227 | if (getsockname(socket, (struct sockaddr *)&addr, &addrlen) | 224 | if (getsockname(socket, (struct sockaddr *)&addr, &addrlen) |
228 | < 0) { | 225 | < 0) |
229 | debug("get_socket_ipaddr: getsockname failed: %.100s", | ||
230 | strerror(errno)); | ||
231 | return NULL; | 226 | return NULL; |
232 | } | ||
233 | } | 227 | } |
234 | /* Get the address in ascii. */ | 228 | /* Get the address in ascii. */ |
235 | if (getnameinfo((struct sockaddr *)&addr, addrlen, ntop, sizeof(ntop), | 229 | if (getnameinfo((struct sockaddr *)&addr, addrlen, ntop, sizeof(ntop), |
@@ -243,13 +237,21 @@ get_socket_address(int socket, int remote, int flags) | |||
243 | char * | 237 | char * |
244 | get_peer_ipaddr(int socket) | 238 | get_peer_ipaddr(int socket) |
245 | { | 239 | { |
246 | return get_socket_address(socket, 1, NI_NUMERICHOST); | 240 | char *p; |
241 | |||
242 | if ((p = get_socket_address(socket, 1, NI_NUMERICHOST)) != NULL) | ||
243 | return p; | ||
244 | return xstrdup("UNKNOWN"); | ||
247 | } | 245 | } |
248 | 246 | ||
249 | char * | 247 | char * |
250 | get_local_ipaddr(int socket) | 248 | get_local_ipaddr(int socket) |
251 | { | 249 | { |
252 | return get_socket_address(socket, 0, NI_NUMERICHOST); | 250 | char *p; |
251 | |||
252 | if ((p = get_socket_address(socket, 0, NI_NUMERICHOST)) != NULL) | ||
253 | return p; | ||
254 | return xstrdup("UNKNOWN"); | ||
253 | } | 255 | } |
254 | 256 | ||
255 | char * | 257 | char * |