From: Wouter Wijngaards Date: Tue, 6 Jan 2009 17:50:56 +0000 (+0000) Subject: fixup libunbound message buffer. X-Git-Tag: release-1.2.0~11 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6e9d2148165dad756a1e1cea8793e51487b50fd2;p=thirdparty%2Funbound.git fixup libunbound message buffer. git-svn-id: file:///svn/unbound/trunk@1412 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/doc/Changelog b/doc/Changelog index 39555c3a1..b0c684630 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -11,6 +11,7 @@ - fix reading included config files when chrooted. Give full path names for include files. Relative path names work if the start dir equals the working dir. + - fix libunbound message transport when no packet buffer is available. 5 January 2009: Wouter - fixup getaddrinfo failure handling for remote control port. diff --git a/libunbound/libworker.c b/libunbound/libworker.c index b18d55514..10baff79a 100644 --- a/libunbound/libworker.c +++ b/libunbound/libworker.c @@ -539,11 +539,15 @@ add_bg_result(struct libworker* w, struct ctx_query* q, ldns_buffer* pkt, /* serialize and delete unneeded q */ if(w->is_bg_thread) { lock_basic_lock(&w->ctx->cfglock); - q->msg_len = ldns_buffer_remaining(pkt); - q->msg = memdup(ldns_buffer_begin(pkt), q->msg_len); - if(!q->msg) - msg = context_serialize_answer(q, UB_NOMEM, NULL, &len); - else msg = context_serialize_answer(q, err, NULL, &len); + if(pkt) { + q->msg_len = ldns_buffer_remaining(pkt); + q->msg = memdup(ldns_buffer_begin(pkt), q->msg_len); + if(!q->msg) + msg = context_serialize_answer(q, UB_NOMEM, + NULL, &len); + else msg = context_serialize_answer(q, err, + NULL, &len); + } else msg = context_serialize_answer(q, err, NULL, &len); lock_basic_unlock(&w->ctx->cfglock); } else { msg = context_serialize_answer(q, err, pkt, &len);