From 5935ef0d212c588547f10031192ddee3418dfe7b Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 11 May 2018 14:35:30 +0200 Subject: don't try SRV requests based on IP addresses IP addresses are by definition not a domain so in the best case the requests will just fail; we can do better than that on our own. --- apt-pkg/contrib/srvrec.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/apt-pkg/contrib/srvrec.cc b/apt-pkg/contrib/srvrec.cc index 930989bfc..a97d9c615 100644 --- a/apt-pkg/contrib/srvrec.cc +++ b/apt-pkg/contrib/srvrec.cc @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -32,6 +33,15 @@ bool SrvRec::operator==(SrvRec const &other) const bool GetSrvRecords(std::string host, int port, std::vector &Result) { + // try SRV only for hostnames, not for IP addresses + { + struct in_addr addr4; + struct in6_addr addr6; + if (inet_pton(AF_INET, host.c_str(), &addr4) == 1 || + inet_pton(AF_INET6, host.c_str(), &addr6) == 1) + return true; + } + std::string target; int res; struct servent s_ent_buf; -- cgit v1.2.3