summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortobhe <tobhe@cvs.openbsd.org>2019-12-16 13:58:54 +0000
committertobhe <tobhe@cvs.openbsd.org>2019-12-16 13:58:54 +0000
commit4deb91293a6a07c7509495425bd5a33db236861e (patch)
tree97f399357a83f88467192678b8897fbe9cd35cde
parente1752708e5e8c4496b50a7180a3f19788a50d09b (diff)
strdup may return NULL if memory allocation fails. Use the safer xstrdup
which fatals on allocation failures. ok markus@
-rw-r--r--usr.bin/ssh/auth.c14
-rw-r--r--usr.bin/ssh/packet.c6
2 files changed, 10 insertions, 10 deletions
diff --git a/usr.bin/ssh/auth.c b/usr.bin/ssh/auth.c
index c696b8759d1..f0340a81b7e 100644
--- a/usr.bin/ssh/auth.c
+++ b/usr.bin/ssh/auth.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: auth.c,v 1.143 2019/11/25 00:54:23 djm Exp $ */
+/* $OpenBSD: auth.c,v 1.144 2019/12/16 13:58:53 tobhe Exp $ */
/*
* Copyright (c) 2000 Markus Friedl. All rights reserved.
*
@@ -631,7 +631,7 @@ remote_hostname(struct ssh *ssh)
if (getpeername(ssh_packet_get_connection_in(ssh),
(struct sockaddr *)&from, &fromlen) == -1) {
debug("getpeername failed: %.100s", strerror(errno));
- return strdup(ntop);
+ return xstrdup(ntop);
}
debug3("Trying to reverse map address %.100s.", ntop);
@@ -639,7 +639,7 @@ remote_hostname(struct ssh *ssh)
if (getnameinfo((struct sockaddr *)&from, fromlen, name, sizeof(name),
NULL, 0, NI_NAMEREQD) != 0) {
/* Host name not found. Use ip address. */
- return strdup(ntop);
+ return xstrdup(ntop);
}
/*
@@ -654,7 +654,7 @@ remote_hostname(struct ssh *ssh)
logit("Nasty PTR record \"%s\" is set up for %s, ignoring",
name, ntop);
freeaddrinfo(ai);
- return strdup(ntop);
+ return xstrdup(ntop);
}
/* Names are stored in lowercase. */
@@ -675,7 +675,7 @@ remote_hostname(struct ssh *ssh)
if (getaddrinfo(name, NULL, &hints, &aitop) != 0) {
logit("reverse mapping checking getaddrinfo for %.700s "
"[%s] failed.", name, ntop);
- return strdup(ntop);
+ return xstrdup(ntop);
}
/* Look for the address from the list of addresses. */
for (ai = aitop; ai; ai = ai->ai_next) {
@@ -690,9 +690,9 @@ remote_hostname(struct ssh *ssh)
/* Address not found for the host name. */
logit("Address %.100s maps to %.600s, but this does not "
"map back to the address.", ntop, name);
- return strdup(ntop);
+ return xstrdup(ntop);
}
- return strdup(name);
+ return xstrdup(name);
}
/*
diff --git a/usr.bin/ssh/packet.c b/usr.bin/ssh/packet.c
index a0e4f8e243d..9a3dda208fb 100644
--- a/usr.bin/ssh/packet.c
+++ b/usr.bin/ssh/packet.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: packet.c,v 1.286 2019/06/28 13:35:04 deraadt Exp $ */
+/* $OpenBSD: packet.c,v 1.287 2019/12/16 13:58:53 tobhe Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -505,9 +505,9 @@ ssh_remote_ipaddr(struct ssh *ssh)
ssh->local_ipaddr = get_local_ipaddr(sock);
ssh->local_port = get_local_port(sock);
} else {
- ssh->remote_ipaddr = strdup("UNKNOWN");
+ ssh->remote_ipaddr = xstrdup("UNKNOWN");
ssh->remote_port = 65535;
- ssh->local_ipaddr = strdup("UNKNOWN");
+ ssh->local_ipaddr = xstrdup("UNKNOWN");
ssh->local_port = 65535;
}
}