summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--canohost.c24
2 files changed, 21 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 1f9ef0251..c31b577d6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,11 @@
120020923 120020923
2 - (djm) OpenBSD CVS Sync
3 - stevesk@cvs.openbsd.org 2002/09/23 20:46:27
4 [canohost.c]
5 change get_peer_ipaddr() and get_local_ipaddr() to not return NULL for
6 non-sockets; fixes a problem passing NULL to snprintf(). ok markus@
7
820020923
2 - (tim) [configure.ac] s/return/exit/ patch by dtucker@zip.com.au 9 - (tim) [configure.ac] s/return/exit/ patch by dtucker@zip.com.au
3 10
420020922 1120020922
@@ -696,4 +703,4 @@
696 save auth method before monitor_reset_key_state(); bugzilla bug #284; 703 save auth method before monitor_reset_key_state(); bugzilla bug #284;
697 ok provos@ 704 ok provos@
698 705
699$Id: ChangeLog,v 1.2476 2002/09/23 23:54:10 tim Exp $ 706$Id: ChangeLog,v 1.2477 2002/09/25 02:19:08 djm Exp $
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"
15RCSID("$OpenBSD: canohost.c,v 1.33 2002/07/09 11:56:27 itojun Exp $"); 15RCSID("$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)
243char * 237char *
244get_peer_ipaddr(int socket) 238get_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
249char * 247char *
250get_local_ipaddr(int socket) 248get_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
255char * 257char *