summaryrefslogtreecommitdiff
path: root/usr.bin/ssh
diff options
context:
space:
mode:
authorKevin Steves <stevesk@cvs.openbsd.org>2002-09-23 20:46:28 +0000
committerKevin Steves <stevesk@cvs.openbsd.org>2002-09-23 20:46:28 +0000
commitd1fb67fed297d6e7403c1dbfdf7f3c4f90c26dd8 (patch)
tree58a71c1cab2267b4be8197cd98856c8182a17e92 /usr.bin/ssh
parenta27c3bfb591614d166e9161fe822568953152fea (diff)
change get_peer_ipaddr() and get_local_ipaddr() to not return NULL for
non-sockets; fixes a problem passing NULL to snprintf(). ok markus@
Diffstat (limited to 'usr.bin/ssh')
-rw-r--r--usr.bin/ssh/canohost.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/usr.bin/ssh/canohost.c b/usr.bin/ssh/canohost.c
index 80c00d8e2a5..4772f5a04d1 100644
--- a/usr.bin/ssh/canohost.c
+++ b/usr.bin/ssh/canohost.c
@@ -12,7 +12,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: canohost.c,v 1.33 2002/07/09 11:56:27 itojun Exp $");
+RCSID("$OpenBSD: canohost.c,v 1.34 2002/09/23 20:46:27 stevesk Exp $");
#include "packet.h"
#include "xmalloc.h"
@@ -196,18 +196,12 @@ get_socket_address(int socket, int remote, int flags)
if (remote) {
if (getpeername(socket, (struct sockaddr *)&addr, &addrlen)
- < 0) {
- debug("get_socket_ipaddr: getpeername failed: %.100s",
- strerror(errno));
+ < 0)
return NULL;
- }
} else {
if (getsockname(socket, (struct sockaddr *)&addr, &addrlen)
- < 0) {
- debug("get_socket_ipaddr: getsockname failed: %.100s",
- strerror(errno));
+ < 0)
return NULL;
- }
}
/* Get the address in ascii. */
if (getnameinfo((struct sockaddr *)&addr, addrlen, ntop, sizeof(ntop),
@@ -221,13 +215,21 @@ get_socket_address(int socket, int remote, int flags)
char *
get_peer_ipaddr(int socket)
{
- return get_socket_address(socket, 1, NI_NUMERICHOST);
+ char *p;
+
+ if ((p = get_socket_address(socket, 1, NI_NUMERICHOST)) != NULL)
+ return p;
+ return xstrdup("UNKNOWN");
}
char *
get_local_ipaddr(int socket)
{
- return get_socket_address(socket, 0, NI_NUMERICHOST);
+ char *p;
+
+ if ((p = get_socket_address(socket, 0, NI_NUMERICHOST)) != NULL)
+ return p;
+ return xstrdup("UNKNOWN");
}
char *