summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/contrib/srvrec.cc10
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;