From b7d632aa9a54a6eb708e44c25176be1844137dee Mon Sep 17 00:00:00 2001 From: brain Date: Thu, 3 Aug 2006 14:42:18 +0000 Subject: add erroring if there are already 65536 id's in transit git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4669 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/dns.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/dns.cpp b/src/dns.cpp index 0329ea712..e9b863ea3 100644 --- a/src/dns.cpp +++ b/src/dns.cpp @@ -202,6 +202,9 @@ int DNSRequest::SendRequests(const DNSHeader *header, const int length, QueryTyp /* Add a query with a predefined header, and allocate an ID for it. */ DNSRequest* DNS::AddQuery(DNSHeader *header, int &id) { + if (requests.size() == DNS::MAX_REQUEST_ID + 1) + return NULL; + id = this->PRNG() & DNS::MAX_REQUEST_ID; /* This id is already 'in flight', pick another. @@ -351,7 +354,7 @@ int DNS::GetIP(const char *name) DNSRequest* req = this->AddQuery(&h, id); - if (req->SendRequests(&h, length, DNS_QUERY_A) == -1) + if ((!req) || (req->SendRequests(&h, length, DNS_QUERY_A) == -1)) return -1; return id; @@ -377,7 +380,7 @@ int DNS::GetName(const insp_inaddr *ip) DNSRequest* req = this->AddQuery(&h, id); - if (req->SendRequests(&h, length, DNS_QUERY_PTR) == -1) + if ((!req) || (req->SendRequests(&h, length, DNS_QUERY_PTR) == -1)) return -1; return id; -- cgit v1.2.3