summaryrefslogtreecommitdiffstats
path: root/usr.sbin/unbound/iterator/iter_utils.c
diff options
context:
space:
mode:
authorbrad <brad@openbsd.org>2015-01-31 23:34:17 +0000
committerbrad <brad@openbsd.org>2015-01-31 23:34:17 +0000
commit35fa0a9c24ca8cf4a544361f98ab7cef54a81f01 (patch)
tree10d79eb24d3a61fab3cf9a912fffa3db27a06b0f /usr.sbin/unbound/iterator/iter_utils.c
parentfree(NULL) works, so stop checking for non-zero length allocation (diff)
downloadwireguard-openbsd-35fa0a9c24ca8cf4a544361f98ab7cef54a81f01.tar.xz
wireguard-openbsd-35fa0a9c24ca8cf4a544361f98ab7cef54a81f01.zip
Merge in a commit from upstream..
- Fix 0x20 capsforid fallback to omit gratuitous NS and additional section changes. ok sthen@
Diffstat (limited to 'usr.sbin/unbound/iterator/iter_utils.c')
-rw-r--r--usr.sbin/unbound/iterator/iter_utils.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/usr.sbin/unbound/iterator/iter_utils.c b/usr.sbin/unbound/iterator/iter_utils.c
index 9d0aa698f99..10ae12f75c6 100644
--- a/usr.sbin/unbound/iterator/iter_utils.c
+++ b/usr.sbin/unbound/iterator/iter_utils.c
@@ -715,6 +715,42 @@ reply_equal(struct reply_info* p, struct reply_info* q, struct regional* region)
}
void
+caps_strip_reply(struct reply_info* rep)
+{
+ size_t i;
+ if(!rep) return;
+ /* see if message is a referral, in which case the additional and
+ * NS record cannot be removed */
+ /* referrals have the AA flag unset (strict check, not elsewhere in
+ * unbound, but for 0x20 this is very convenient). */
+ if(!(rep->flags&BIT_AA))
+ return;
+ /* remove the additional section from the reply */
+ if(rep->ar_numrrsets != 0) {
+ verbose(VERB_ALGO, "caps fallback: removing additional section");
+ rep->rrset_count -= rep->ar_numrrsets;
+ rep->ar_numrrsets = 0;
+ }
+ /* is there an NS set in the authority section to remove? */
+ /* the failure case (Cisco firewalls) only has one rrset in authsec */
+ for(i=rep->an_numrrsets; i<rep->an_numrrsets+rep->ns_numrrsets; i++) {
+ struct ub_packed_rrset_key* s = rep->rrsets[i];
+ if(ntohs(s->rk.type) == LDNS_RR_TYPE_NS) {
+ /* remove NS rrset and break from loop (loop limits
+ * have changed) */
+ /* move last rrset into this position (there is no
+ * additional section any more) */
+ verbose(VERB_ALGO, "caps fallback: removing NS rrset");
+ if(i < rep->rrset_count-1)
+ rep->rrsets[i]=rep->rrsets[rep->rrset_count-1];
+ rep->rrset_count --;
+ rep->ns_numrrsets --;
+ break;
+ }
+ }
+}
+
+void
iter_store_parentside_rrset(struct module_env* env,
struct ub_packed_rrset_key* rrset)
{