summaryrefslogtreecommitdiffstats
path: root/lib/cache/knot_pkt.c
diff options
context:
space:
mode:
authorVladimír Čunát <vladimir.cunat@nic.cz>2023-05-29 13:59:00 +0200
committerVladimír Čunát <vladimir.cunat@nic.cz>2023-05-29 13:59:00 +0200
commit93169196498c2675936b4e7298c9abed16111cf3 (patch)
tree715a5059881f666c4bf54e872373c4dea435734c /lib/cache/knot_pkt.c
parentMerge !1397: hints docs: explain root hints better (diff)
downloadknot-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.c4
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);