]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Cosmeti cleanups, restore of error handling (currently unused)
authorhno <>
Tue, 10 May 2005 16:39:56 +0000 (16:39 +0000)
committerhno <>
Tue, 10 May 2005 16:39:56 +0000 (16:39 +0000)
include/rfc1035.h
src/dns_internal.cc

index 9b89bf16d4de2397c42ad57db44c2b165c651676..f4852856ebf71358bd7d1dfdfa82a2387156d730 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: rfc1035.h,v 1.14 2005/05/10 10:09:31 hno Exp $
+ * $Id: rfc1035.h,v 1.15 2005/05/10 10:39:56 hno Exp $
  *
  * AUTHOR: Duane Wessels
  *
@@ -84,12 +84,12 @@ SQUIDCEXTERN ssize_t rfc1035BuildAQuery(const char *hostname,
     char *buf,
     size_t sz,
     unsigned short qid,
-    rfc1035_query *query);
+    rfc1035_query * query);
 SQUIDCEXTERN ssize_t rfc1035BuildPTRQuery(const struct IN_ADDR,
     char *buf,
     size_t sz,
     unsigned short qid,
-    rfc1035_query *query);
+    rfc1035_query * query);
 SQUIDCEXTERN void rfc1035SetQueryID(char *, unsigned short qid);
 SQUIDCEXTERN int rfc1035MessageUnpack(const char *buf,
     size_t sz,
index 94e654b97f834f219b57059fb787ede6107e2ec5..e1c880a8ce29431905c08af7243d663f126ddc48 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: dns_internal.cc,v 1.74 2005/05/10 10:09:32 hno Exp $
+ * $Id: dns_internal.cc,v 1.75 2005/05/10 10:39:56 hno Exp $
  *
  * DEBUG: section 78    DNS lookups; interacts with lib/rfc1035.c
  * AUTHOR: Duane Wessels
@@ -594,7 +594,6 @@ idnsCallback(idns_query *q, rfc1035_rr *answers, int n, const char *error)
     }
 }
 
-/* FIXME: We should also verify that the response is to the correct query to eleminate overlaps */
 static void
 idnsGrokReply(const char *buf, size_t sz)
 {
@@ -621,7 +620,6 @@ idnsGrokReply(const char *buf, size_t sz)
         return;
     }
 
-    /* FIXME: We should also verify the query to match ours */
     if (rfc1035QueryCompare(&q->query, message->query) != 0) {
         debug(78, 3) ("idnsGrokReply: Query mismatch (%s != %s)\n", q->query.name, message->query->name);
         rfc1035MessageDestroy(message);
@@ -938,6 +936,13 @@ idnsALookup(const char *name, IDNSCB * callback, void *data)
 
     q->sz = rfc1035BuildAQuery(name, q->buf, sizeof(q->buf), q->id, &q->query);
 
+    if (q->sz < 0) {
+        /* problem with query data -- query not sent */
+        callback(data, NULL, 0, "Internal error");
+        memFree(q, MEM_IDNS_QUERY);
+        return;
+    }
+
     debug(78, 3) ("idnsALookup: buf is %d bytes for %s, id = %#hx\n",
                   (int) q->sz, name, q->id);
 
@@ -969,6 +974,14 @@ idnsPTRLookup(const struct IN_ADDR addr, IDNSCB * callback, void *data)
 
     q->sz = rfc1035BuildPTRQuery(addr, q->buf, sizeof(q->buf), q->id, &q->query);
 
+    if (q->sz < 0)
+    {
+        /* problem with query data -- query not sent */
+        callback(data, NULL, 0, "Internal error");
+        memFree(q, MEM_IDNS_QUERY);
+        return;
+    }
+
     debug(78, 3) ("idnsPTRLookup: buf is %d bytes for %s, id = %#hx\n",
                   (int) q->sz, ip, q->id);