summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Friedl <markus@cvs.openbsd.org>1999-11-15 00:42:02 +0000
committerMarkus Friedl <markus@cvs.openbsd.org>1999-11-15 00:42:02 +0000
commite7b08259428230e65dcbcc9029e16ec68d0fd7b0 (patch)
treec2411b60a134f2a16f7c51575fee72b494ddea20
parent649bfbb5c639f8010a8192be1bffc693a9fafabb (diff)
disconnect if getpeername() fails
-rw-r--r--usr.bin/ssh/auth-krb4.c6
-rw-r--r--usr.bin/ssh/canohost.c15
-rw-r--r--usr.bin/ssh/sshconnect.c6
-rw-r--r--usr.bin/ssh/sshd.c10
4 files changed, 21 insertions, 16 deletions
diff --git a/usr.bin/ssh/auth-krb4.c b/usr.bin/ssh/auth-krb4.c
index 7fbc061c38e..adca6018fcb 100644
--- a/usr.bin/ssh/auth-krb4.c
+++ b/usr.bin/ssh/auth-krb4.c
@@ -6,7 +6,7 @@
Kerberos v4 authentication and ticket-passing routines.
- $Id: auth-krb4.c,v 1.7 1999/11/14 22:58:44 markus Exp $
+ $Id: auth-krb4.c,v 1.8 1999/11/15 00:42:00 markus Exp $
*/
#include "includes.h"
@@ -89,8 +89,10 @@ int auth_krb4(const char *server_user, KTEXT auth, char **client)
debug("getsockname failed: %.100s", strerror(errno));
r = sizeof(foreign);
memset(&foreign, 0, sizeof(foreign));
- if (getpeername(s, (struct sockaddr *)&foreign, &r) < 0)
+ if (getpeername(s, (struct sockaddr *)&foreign, &r) < 0) {
debug("getpeername failed: %.100s", strerror(errno));
+ fatal_cleanup();
+ }
instance[0] = '*'; instance[1] = 0;
diff --git a/usr.bin/ssh/canohost.c b/usr.bin/ssh/canohost.c
index b7e60e0814e..d2502de5be6 100644
--- a/usr.bin/ssh/canohost.c
+++ b/usr.bin/ssh/canohost.c
@@ -14,7 +14,7 @@ Functions for returning the canonical host name of the remote site.
*/
#include "includes.h"
-RCSID("$Id: canohost.c,v 1.4 1999/11/14 22:30:58 markus Exp $");
+RCSID("$Id: canohost.c,v 1.5 1999/11/15 00:42:01 markus Exp $");
#include "packet.h"
#include "xmalloc.h"
@@ -35,9 +35,8 @@ char *get_remote_hostname(int socket)
memset(&from, 0, sizeof(from));
if (getpeername(socket, (struct sockaddr *)&from, &fromlen) < 0)
{
- error("getpeername failed: %.100s", strerror(errno));
- strlcpy(name, "UNKNOWN", sizeof name);
- goto check_ip_options;
+ debug("getpeername failed: %.100s", strerror(errno));
+ fatal_cleanup();
}
/* Map the IP address to a host name. */
@@ -184,8 +183,8 @@ const char *get_remote_ipaddr()
memset(&from, 0, sizeof(from));
if (getpeername(socket, (struct sockaddr *)&from, &fromlen) < 0)
{
- error("getpeername failed: %.100s", strerror(errno));
- return NULL;
+ debug("getpeername failed: %.100s", strerror(errno));
+ fatal_cleanup();
}
/* Get the IP address in ascii. */
@@ -207,8 +206,8 @@ int get_peer_port(int sock)
memset(&from, 0, sizeof(from));
if (getpeername(sock, (struct sockaddr *)&from, &fromlen) < 0)
{
- error("getpeername failed: %.100s", strerror(errno));
- return 0;
+ debug("getpeername failed: %.100s", strerror(errno));
+ fatal_cleanup();
}
/* Return port number. */
diff --git a/usr.bin/ssh/sshconnect.c b/usr.bin/ssh/sshconnect.c
index 7a033e69098..83e8f4b899e 100644
--- a/usr.bin/ssh/sshconnect.c
+++ b/usr.bin/ssh/sshconnect.c
@@ -15,7 +15,7 @@ login (authentication) dialog.
*/
#include "includes.h"
-RCSID("$Id: sshconnect.c,v 1.27 1999/11/11 23:36:53 markus Exp $");
+RCSID("$Id: sshconnect.c,v 1.28 1999/11/15 00:42:01 markus Exp $");
#include <ssl/bn.h>
#include "xmalloc.h"
@@ -724,8 +724,10 @@ int try_kerberos_authentication()
r = sizeof(foreign);
memset(&foreign, 0, sizeof(foreign));
if (getpeername(packet_get_connection_in(),
- (struct sockaddr *)&foreign, &r) < 0)
+ (struct sockaddr *)&foreign, &r) < 0) {
debug("getpeername failed: %s", strerror(errno));
+ fatal_cleanup();
+ }
/* Get server reply. */
type = packet_read(&plen);
diff --git a/usr.bin/ssh/sshd.c b/usr.bin/ssh/sshd.c
index b430bab8f6b..3f418e6b236 100644
--- a/usr.bin/ssh/sshd.c
+++ b/usr.bin/ssh/sshd.c
@@ -18,7 +18,7 @@ agent connections.
*/
#include "includes.h"
-RCSID("$Id: sshd.c,v 1.52 1999/11/14 23:20:09 markus Exp $");
+RCSID("$Id: sshd.c,v 1.53 1999/11/15 00:42:01 markus Exp $");
#include "xmalloc.h"
#include "rsa.h"
@@ -1241,7 +1241,7 @@ do_authloop(struct passwd *pw)
packet_integrity_check(plen, nlen, type);
authenticated = auth_rsa(pw, n);
BN_clear_free(n);
- log("RSA authentication %s for %.100s failed.",
+ log("RSA authentication %s for %.100s.",
authenticated ? "accepted" : "failed",
pw->pw_name);
break;
@@ -1811,8 +1811,10 @@ void do_exec_pty(const char *command, int ptyfd, int ttyfd,
{
fromlen = sizeof(from);
if (getpeername(packet_get_connection_in(),
- (struct sockaddr *)&from, &fromlen) < 0)
- fatal("getpeername: %.100s", strerror(errno));
+ (struct sockaddr *)&from, &fromlen) < 0) {
+ debug("getpeername: %.100s", strerror(errno));
+ fatal_cleanup();
+ }
}
/* Record that there was a login on that terminal. */