diff options
author | tobhe@openbsd.org <tobhe@openbsd.org> | 2019-12-16 13:58:53 +0000 |
---|---|---|
committer | Darren Tucker <dtucker@dtucker.net> | 2019-12-20 14:25:08 +1100 |
commit | f65cf1163ff01531ae02f3f9210391d0d692f699 (patch) | |
tree | 3dc82d371462c11bd6116e4240e5e116fe0bed14 /auth.c | |
parent | 57634bfc5708477826c0be265ddc59b9d83e4886 (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.c | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -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. * @@ -748,7 +748,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); } ipv64_normalise_mapped(&from, &fromlen); @@ -760,7 +760,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); } /* @@ -775,7 +775,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. */ @@ -796,7 +796,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) { @@ -811,9 +811,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); } /* |