summaryrefslogtreecommitdiff
path: root/canohost.c
diff options
context:
space:
mode:
Diffstat (limited to 'canohost.c')
-rw-r--r--canohost.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/canohost.c b/canohost.c
index e5a6b6be3..1c22d4770 100644
--- a/canohost.c
+++ b/canohost.c
@@ -12,7 +12,7 @@
12 */ 12 */
13 13
14#include "includes.h" 14#include "includes.h"
15RCSID("$OpenBSD: canohost.c,v 1.41 2004/07/21 11:51:29 djm Exp $"); 15RCSID("$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"
@@ -231,6 +231,7 @@ get_socket_address(int sock, int remote, int flags)
231 struct sockaddr_storage addr; 231 struct sockaddr_storage addr;
232 socklen_t addrlen; 232 socklen_t addrlen;
233 char ntop[NI_MAXHOST]; 233 char ntop[NI_MAXHOST];
234 int r;
234 235
235 /* Get IP address of client. */ 236 /* Get IP address of client. */
236 addrlen = sizeof(addr); 237 addrlen = sizeof(addr);
@@ -251,9 +252,10 @@ get_socket_address(int sock, int remote, int flags)
251 addrlen = sizeof(struct sockaddr_in6); 252 addrlen = sizeof(struct sockaddr_in6);
252 253
253 /* Get the address in ascii. */ 254 /* Get the address in ascii. */
254 if (getnameinfo((struct sockaddr *)&addr, addrlen, ntop, sizeof(ntop), 255 if ((r = getnameinfo((struct sockaddr *)&addr, addrlen, ntop,
255 NULL, 0, flags) != 0) { 256 sizeof(ntop), NULL, 0, flags)) != 0) {
256 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));
257 return NULL; 259 return NULL;
258 } 260 }
259 return xstrdup(ntop); 261 return xstrdup(ntop);
@@ -329,6 +331,7 @@ get_sock_port(int sock, int local)
329 struct sockaddr_storage from; 331 struct sockaddr_storage from;
330 socklen_t fromlen; 332 socklen_t fromlen;
331 char strport[NI_MAXSERV]; 333 char strport[NI_MAXSERV];
334 int r;
332 335
333 /* Get IP address of client. */ 336 /* Get IP address of client. */
334 fromlen = sizeof(from); 337 fromlen = sizeof(from);
@@ -350,9 +353,10 @@ get_sock_port(int sock, int local)
350 fromlen = sizeof(struct sockaddr_in6); 353 fromlen = sizeof(struct sockaddr_in6);
351 354
352 /* Return port number. */ 355 /* Return port number. */
353 if (getnameinfo((struct sockaddr *)&from, fromlen, NULL, 0, 356 if ((r = getnameinfo((struct sockaddr *)&from, fromlen, NULL, 0,
354 strport, sizeof(strport), NI_NUMERICSERV) != 0) 357 strport, sizeof(strport), NI_NUMERICSERV)) != 0)
355 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));
356 return atoi(strport); 360 return atoi(strport);
357} 361}
358 362