=== modified file 'src/dns_internal.cc' --- src/dns_internal.cc 2011-01-28 07:58:53 +0000 +++ src/dns_internal.cc 2011-02-23 11:36:34 +0000 @@ -124,7 +124,7 @@ char buf[RESOLV_BUFSZ]; char name[NS_MAXDNAME + 1]; char orig[NS_MAXDNAME + 1]; - size_t sz; + ssize_t sz; unsigned short msg_id; /// random query ID sent to server; changes with every query sent InstanceId xact_id; /// identifies our "transaction", stays constant when query is retried @@ -1145,6 +1145,14 @@ // see EDNS notes at top of file why this sends 0 q->sz = rfc3596BuildAQuery(q->name, q->buf, sizeof(q->buf), 0, &q->query, 0); } + + if (q->sz < 0) { + /* problem with query data -- query not sent */ + callback(q->callback_data, NULL, 0, "Internal error"); + cbdataFree(q); + return; + } + idnsCacheQuery(q); idnsSendQuery(q); return; @@ -1181,6 +1189,14 @@ // see EDNS notes at top of file why this sends 0 q->sz = rfc3596BuildAQuery(q->name, q->buf, sizeof(q->buf), 0, &q->query, 0); q->need_A = false; + + if (q->sz < 0) { + /* problem with query data -- query not sent */ + callback(q->callback_data, NULL, 0, "Internal error"); + cbdataFree(q); + return; + } + idnsCacheQuery(q); idnsSendQuery(q); return;