From: hno <> Date: Tue, 10 May 2005 16:39:56 +0000 (+0000) Subject: Cosmeti cleanups, restore of error handling (currently unused) X-Git-Tag: SQUID_3_0_PRE4~753 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2041330be5dbee730cc8708f96824a2c92396d0a;p=thirdparty%2Fsquid.git Cosmeti cleanups, restore of error handling (currently unused) --- diff --git a/include/rfc1035.h b/include/rfc1035.h index 9b89bf16d4..f4852856eb 100644 --- a/include/rfc1035.h +++ b/include/rfc1035.h @@ -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, diff --git a/src/dns_internal.cc b/src/dns_internal.cc index 94e654b97f..e1c880a8ce 100644 --- a/src/dns_internal.cc +++ b/src/dns_internal.cc @@ -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);