OpenSSH -current fails regression on Solaris 8, sshd dumps core
Kevin Steves
kevin at atomicgears.com
Tue Sep 24 11:10:14 EST 2002
On Sun, Sep 22, 2002 at 01:24:24AM +1000, Darren Tucker wrote:
> After poking around, it seems that:
> 1) get_local_ipaddr returns NULL
> 2) this NULL is passed to snprintf
> 3) which dereferences the NULL causing a SEGV
>
> (get_local_ipaddr returns NULL because it calls get_socket_address which
> calls getpeername on a non-socket.)
thanks. fixed a little different and cover the other case.
the canohost interface needs to be reworked.
Index: canohost.c
===================================================================
RCS file: /cvs/src/usr.bin/ssh/canohost.c,v
retrieving revision 1.33
diff -u -r1.33 canohost.c
--- canohost.c 9 Jul 2002 11:56:27 -0000 1.33
+++ canohost.c 23 Sep 2002 20:16:38 -0000
@@ -196,18 +196,12 @@
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 @@
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 *
More information about the openssh-unix-dev
mailing list