diff options
author | David Kalnischkies <david@kalnischkies.de> | 2018-05-11 14:35:30 +0200 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2018-05-11 14:35:30 +0200 |
commit | 5935ef0d212c588547f10031192ddee3418dfe7b (patch) | |
tree | 3d3b0970cbde0f8c205b054a513a195c1f5e81d7 /apt-pkg/contrib/srvrec.cc | |
parent | 7e1e99319abf84e54908196d46aa960de8dfa2c8 (diff) |
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.
Diffstat (limited to 'apt-pkg/contrib/srvrec.cc')
-rw-r--r-- | apt-pkg/contrib/srvrec.cc | 10 |
1 files changed, 10 insertions, 0 deletions
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 <netdb.h> #include <arpa/nameser.h> +#include <arpa/inet.h> #include <netinet/in.h> #include <resolv.h> #include <time.h> @@ -32,6 +33,15 @@ bool SrvRec::operator==(SrvRec const &other) const bool GetSrvRecords(std::string host, int port, std::vector<SrvRec> &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; |