summaryrefslogtreecommitdiff
path: root/evdns.c
diff options
context:
space:
mode:
authorLeonid Evdokimov <darkk@yandex-team.ru>2011-08-10 15:58:47 +0400
committerNick Mathewson <nickm@torproject.org>2011-09-12 15:38:05 -0400
commit94fba5b9acd6608c69befff99cf083cf60bde098 (patch)
tree3663036ef8f45cd70de51e5021f5c448b27b4612 /evdns.c
parent2b6eae5999b9a55475f29e1478340e178787757e (diff)
downloadlibevent-94fba5b9acd6608c69befff99cf083cf60bde098.tar.gz
Add DNS_ERR_NODATA error code to handle empty replies.
Diffstat (limited to 'evdns.c')
-rw-r--r--evdns.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/evdns.c b/evdns.c
index 4ff9f8dc..6b501698 100644
--- a/evdns.c
+++ b/evdns.c
@@ -843,13 +843,17 @@ reply_handle(struct request *const req, u16 flags, u32 ttl, struct reply *reply)
/* there was an error */
if (flags & 0x0200) {
error = DNS_ERR_TRUNCATED;
- } else {
+ } else if (flags & 0x000f) {
u16 error_code = (flags & 0x000f) - 1;
if (error_code > 4) {
error = DNS_ERR_UNKNOWN;
} else {
error = error_codes[error_code];
}
+ } else if (reply && !reply->have_answer) {
+ error = DNS_ERR_NODATA;
+ } else {
+ error = DNS_ERR_UNKNOWN;
}
switch (error) {
@@ -3871,6 +3875,7 @@ evdns_err_to_string(int err)
case DNS_ERR_TIMEOUT: return "request timed out";
case DNS_ERR_SHUTDOWN: return "dns subsystem shut down";
case DNS_ERR_CANCEL: return "dns request canceled";
+ case DNS_ERR_NODATA: return "no records in the reply";
default: return "[Unknown error code]";
}
}