Fixed off-by-one error in SRV lookups
authorSenko Rasic <senko.rasic@collabora.co.uk>
Tue, 30 Oct 2007 00:24:57 +0100
changeset 300 ce78172edafd
parent 299 f38f614ce2ea
child 301 e83880152e77
Fixed off-by-one error in SRV lookups
loudmouth/asyncns.c
--- a/loudmouth/asyncns.c	Mon Oct 29 23:35:50 2007 +0100
+++ b/loudmouth/asyncns.c	Tue Oct 30 00:24:57 2007 +0100
@@ -368,7 +368,7 @@
             const char *dname;
 
             assert(length >= sizeof(res_request_t));
-            assert(length == sizeof(res_request_t) + res_req->dlen);
+            assert(length == sizeof(res_request_t) + res_req->dlen + 1);
 
             dname = (const char *) req + sizeof(res_request_t);
 
@@ -1004,7 +1004,7 @@
     
     req->header.id = q->id;
     req->header.type = q->type = qtype;
-    req->header.length = sizeof(res_request_t) + dlen;
+    req->header.length = sizeof(res_request_t) + dlen + 1;
 
     if (req->header.length > BUFSIZE)
         goto fail;
@@ -1013,11 +1013,11 @@
     req->type = type;
     req->dlen = dlen;
 
-    memcpy((uint8_t*) req + sizeof(res_request_t), dname, dlen);
+    memcpy((uint8_t*) req + sizeof(res_request_t), dname, dlen + 1);
 
     if (send(asyncns->fds[REQUEST_SEND_FD], req, req->header.length, 0) < 0)
         goto fail;
-    
+
     return q;
 
 fail: