summaryrefslogtreecommitdiff
path: root/auth.c
diff options
context:
space:
mode:
authortobhe@openbsd.org <tobhe@openbsd.org>2019-12-16 13:58:53 +0000
committerDarren Tucker <dtucker@dtucker.net>2019-12-20 14:25:08 +1100
commitf65cf1163ff01531ae02f3f9210391d0d692f699 (patch)
tree3dc82d371462c11bd6116e4240e5e116fe0bed14 /auth.c
parent57634bfc5708477826c0be265ddc59b9d83e4886 (diff)
upstream: strdup may return NULL if memory allocation fails. Use
the safer xstrdup which fatals on allocation failures. ok markus@ OpenBSD-Commit-ID: 8b608d387120630753cbcb8110e0b019c0c9a0d0
Diffstat (limited to 'auth.c')
-rw-r--r--auth.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/auth.c b/auth.c
index 0a46e1d8a..48838508e 100644
--- a/auth.c
+++ b/auth.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: auth.c,v 1.143 2019/11/25 00:54:23 djm Exp $ */ 1/* $OpenBSD: auth.c,v 1.144 2019/12/16 13:58:53 tobhe Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 * 4 *
@@ -748,7 +748,7 @@ remote_hostname(struct ssh *ssh)
748 if (getpeername(ssh_packet_get_connection_in(ssh), 748 if (getpeername(ssh_packet_get_connection_in(ssh),
749 (struct sockaddr *)&from, &fromlen) == -1) { 749 (struct sockaddr *)&from, &fromlen) == -1) {
750 debug("getpeername failed: %.100s", strerror(errno)); 750 debug("getpeername failed: %.100s", strerror(errno));
751 return strdup(ntop); 751 return xstrdup(ntop);
752 } 752 }
753 753
754 ipv64_normalise_mapped(&from, &fromlen); 754 ipv64_normalise_mapped(&from, &fromlen);
@@ -760,7 +760,7 @@ remote_hostname(struct ssh *ssh)
760 if (getnameinfo((struct sockaddr *)&from, fromlen, name, sizeof(name), 760 if (getnameinfo((struct sockaddr *)&from, fromlen, name, sizeof(name),
761 NULL, 0, NI_NAMEREQD) != 0) { 761 NULL, 0, NI_NAMEREQD) != 0) {
762 /* Host name not found. Use ip address. */ 762 /* Host name not found. Use ip address. */
763 return strdup(ntop); 763 return xstrdup(ntop);
764 } 764 }
765 765
766 /* 766 /*
@@ -775,7 +775,7 @@ remote_hostname(struct ssh *ssh)
775 logit("Nasty PTR record \"%s\" is set up for %s, ignoring", 775 logit("Nasty PTR record \"%s\" is set up for %s, ignoring",
776 name, ntop); 776 name, ntop);
777 freeaddrinfo(ai); 777 freeaddrinfo(ai);
778 return strdup(ntop); 778 return xstrdup(ntop);
779 } 779 }
780 780
781 /* Names are stored in lowercase. */ 781 /* Names are stored in lowercase. */
@@ -796,7 +796,7 @@ remote_hostname(struct ssh *ssh)
796 if (getaddrinfo(name, NULL, &hints, &aitop) != 0) { 796 if (getaddrinfo(name, NULL, &hints, &aitop) != 0) {
797 logit("reverse mapping checking getaddrinfo for %.700s " 797 logit("reverse mapping checking getaddrinfo for %.700s "
798 "[%s] failed.", name, ntop); 798 "[%s] failed.", name, ntop);
799 return strdup(ntop); 799 return xstrdup(ntop);
800 } 800 }
801 /* Look for the address from the list of addresses. */ 801 /* Look for the address from the list of addresses. */
802 for (ai = aitop; ai; ai = ai->ai_next) { 802 for (ai = aitop; ai; ai = ai->ai_next) {
@@ -811,9 +811,9 @@ remote_hostname(struct ssh *ssh)
811 /* Address not found for the host name. */ 811 /* Address not found for the host name. */
812 logit("Address %.100s maps to %.600s, but this does not " 812 logit("Address %.100s maps to %.600s, but this does not "
813 "map back to the address.", ntop, name); 813 "map back to the address.", ntop, name);
814 return strdup(ntop); 814 return xstrdup(ntop);
815 } 815 }
816 return strdup(name); 816 return xstrdup(name);
817} 817}
818 818
819/* 819/*