diff options
author | Vladimír Čunát <vladimir.cunat@nic.cz> | 2023-05-29 13:59:00 +0200 |
---|---|---|
committer | Vladimír Čunát <vladimir.cunat@nic.cz> | 2023-05-29 13:59:00 +0200 |
commit | 93169196498c2675936b4e7298c9abed16111cf3 (patch) | |
tree | 715a5059881f666c4bf54e872373c4dea435734c /lib/cache/knot_pkt.c | |
parent | Merge !1397: hints docs: explain root hints better (diff) | |
download | knot-resolver-93169196498c2675936b4e7298c9abed16111cf3.tar.xz knot-resolver-93169196498c2675936b4e7298c9abed16111cf3.zip |
lib/cache pkt_renew(): fix an edge-case bug
It could happen that this condition didn't get triggered,
but the structures weren't completely clear. In particular,
the current section could be past KNOT_ANSWER already.
Let's be more conservative here; pkt_recycle() shouldn't be expensive.
I'm not sure why I only ran into this on the new-policy branch,
but it really seems like bug here on master already.
Diffstat (limited to '')
-rw-r--r-- | lib/cache/knot_pkt.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/cache/knot_pkt.c b/lib/cache/knot_pkt.c index 31fa7e9b..864cb57c 100644 --- a/lib/cache/knot_pkt.c +++ b/lib/cache/knot_pkt.c @@ -11,8 +11,8 @@ int pkt_renew(knot_pkt_t *pkt, const knot_dname_t *name, uint16_t type) { - /* Update packet question if needed. */ - if (!knot_dname_is_equal(knot_pkt_qname(pkt), name) + /* Clear the packet if needed. */ + if (pkt->rrset_count != 0 || !knot_dname_is_equal(knot_pkt_qname(pkt), name) || knot_pkt_qtype(pkt) != type || knot_pkt_qclass(pkt) != KNOT_CLASS_IN) { int ret = kr_pkt_recycle(pkt); if (ret) return kr_error(ret); |