diff options
author | Dag-Erling Smørgrav <des@FreeBSD.org> | 2018-05-12 14:36:58 +0000 |
---|---|---|
committer | Dag-Erling Smørgrav <des@FreeBSD.org> | 2018-05-12 14:36:58 +0000 |
commit | c7f4d7ad9b7dbb008bffe724ae877e10fea2f821 (patch) | |
tree | b564f93e102c15f0f4a9483b193b0621185c08cc /contrib/unbound/util/data/msgencode.c | |
parent | 92bb4ebdc49411ccb394823506e83f2e14dc69b0 (diff) | |
parent | 15de2de8449b4f5063f93578ae68aa0bc79a205c (diff) | |
download | src-c7f4d7ad9b7dbb008bffe724ae877e10fea2f821.tar.gz src-c7f4d7ad9b7dbb008bffe724ae877e10fea2f821.zip |
Upgrade Unbound to 1.6.4. More to follow.
Notes
Notes:
svn path=/head/; revision=333561
Diffstat (limited to 'contrib/unbound/util/data/msgencode.c')
-rw-r--r-- | contrib/unbound/util/data/msgencode.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/contrib/unbound/util/data/msgencode.c b/contrib/unbound/util/data/msgencode.c index 1f72a03b8c64..aab7f5dfecba 100644 --- a/contrib/unbound/util/data/msgencode.c +++ b/contrib/unbound/util/data/msgencode.c @@ -647,6 +647,8 @@ reply_info_encode(struct query_info* qinfo, struct reply_info* rep, sldns_buffer_clear(buffer); if(udpsize < sldns_buffer_limit(buffer)) sldns_buffer_set_limit(buffer, udpsize); + else if(sldns_buffer_limit(buffer) < udpsize) + udpsize = sldns_buffer_limit(buffer); if(sldns_buffer_remaining(buffer) < LDNS_HEADER_SIZE) return 0; @@ -810,7 +812,7 @@ reply_info_answer_encode(struct query_info* qinf, struct reply_info* rep, struct edns_data* edns, int dnssec, int secure) { uint16_t flags; - int attach_edns = 1; + unsigned int attach_edns = 0; if(!cached || rep->authoritative) { /* original flags, copy RD and CD bits from query. */ @@ -833,12 +835,15 @@ reply_info_answer_encode(struct query_info* qinf, struct reply_info* rep, log_assert(flags & BIT_QR); /* QR bit must be on in our replies */ if(udpsize < LDNS_HEADER_SIZE) return 0; + if(sldns_buffer_capacity(pkt) < udpsize) + udpsize = sldns_buffer_capacity(pkt); if(udpsize < LDNS_HEADER_SIZE + calc_edns_field_size(edns)) { /* packet too small to contain edns, omit it. */ attach_edns = 0; } else { /* reserve space for edns record */ - udpsize -= calc_edns_field_size(edns); + attach_edns = (unsigned int)calc_edns_field_size(edns); + udpsize -= attach_edns; } if(!reply_info_encode(qinf, rep, id, flags, pkt, timenow, region, @@ -846,7 +851,8 @@ reply_info_answer_encode(struct query_info* qinf, struct reply_info* rep, log_err("reply encode: out of memory"); return 0; } - if(attach_edns) + if(attach_edns && sldns_buffer_capacity(pkt) >= + sldns_buffer_limit(pkt)+attach_edns) attach_edns_record(pkt, edns); return 1; } |