summaryrefslogtreecommitdiff
path: root/usr.bin/ssh/dns.c
diff options
context:
space:
mode:
authorJakob Schlyter <jakob@cvs.openbsd.org>2005-04-20 10:05:46 +0000
committerJakob Schlyter <jakob@cvs.openbsd.org>2005-04-20 10:05:46 +0000
commit21536ec7edaa4426dc77fc572b3cfbd30c2bd663 (patch)
treea35f6c2a59a080ded6e50e734a1ebcc0c02deb1a /usr.bin/ssh/dns.c
parentcfab8d04ea985d0bbee206f9389edcdfd1845a75 (diff)
do not try to look up SSHFP for numerical hostname. ok djm@
Diffstat (limited to 'usr.bin/ssh/dns.c')
-rw-r--r--usr.bin/ssh/dns.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/usr.bin/ssh/dns.c b/usr.bin/ssh/dns.c
index 140ab604293..5a964bc7fac 100644
--- a/usr.bin/ssh/dns.c
+++ b/usr.bin/ssh/dns.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dns.c,v 1.10 2004/06/21 17:36:31 avsm Exp $ */
+/* $OpenBSD: dns.c,v 1.11 2005/04/20 10:05:45 jakob Exp $ */
/*
* Copyright (c) 2003 Wesley Griffin. All rights reserved.
@@ -43,7 +43,7 @@
#include "uuencode.h"
extern char *__progname;
-RCSID("$OpenBSD: dns.c,v 1.10 2004/06/21 17:36:31 avsm Exp $");
+RCSID("$OpenBSD: dns.c,v 1.11 2005/04/20 10:05:45 jakob Exp $");
#ifndef LWRES
static const char *errset_text[] = {
@@ -142,6 +142,26 @@ dns_read_rdata(u_int8_t *algorithm, u_int8_t *digest_type,
return success;
}
+/*
+ * Check if hostname is numerical.
+ * Returns -1 if hostname is numeric, 0 otherwise
+ */
+static int
+is_numeric_hostname(const char *hostname)
+{
+ struct addrinfo hints, *ai;
+
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_socktype = SOCK_DGRAM;
+ hints.ai_flags = AI_NUMERICHOST;
+
+ if (getaddrinfo(hostname, "0", &hints, &ai) == 0) {
+ freeaddrinfo(ai);
+ return -1;
+ }
+
+ return 0;
+}
/*
* Verify the given hostname, address and host key using DNS.
@@ -171,6 +191,11 @@ verify_host_key_dns(const char *hostname, struct sockaddr *address,
if (hostkey == NULL)
fatal("No key to look up!");
+ if (is_numeric_hostname(hostname)) {
+ debug("skipped DNS lookup for numerical hostname");
+ return -1;
+ }
+
result = getrrsetbyname(hostname, DNS_RDATACLASS_IN,
DNS_RDATATYPE_SSHFP, 0, &fingerprints);
if (result) {