summaryrefslogtreecommitdiff
path: root/src/dns.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-03 14:42:18 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-03 14:42:18 +0000
commitb7d632aa9a54a6eb708e44c25176be1844137dee (patch)
tree5c51991cbdba93495799fc2d2701c27ac31424af /src/dns.cpp
parent43759fd180caf1894e10e8adc2df86f029aa63b1 (diff)
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
Diffstat (limited to 'src/dns.cpp')
-rw-r--r--src/dns.cpp7
1 files changed, 5 insertions, 2 deletions
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;