summaryrefslogtreecommitdiff
path: root/src/resolve/resolved-dns-query.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-03-01 23:10:06 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-03-01 23:12:51 +0100
commit97935302283729c9206b84f5e00b1aff0f78ad19 (patch)
tree8ed7489e5a8aef4ecfcacc5d7f61cabf77b3d07c /src/resolve/resolved-dns-query.c
parentf2ec080ef2763b691f8346121ce92cdcb05b150c (diff)
downloadsystemd-97935302283729c9206b84f5e00b1aff0f78ad19.tar.gz
resolved: disable event sources before unreffing them
We generally operate on the assumption that a source is "gone" as soon as we unref it. This is generally true because we have the only reference. But if something else holds the reference, our unref doesn't really stop the source and it could fire again. In particular, on_query_timeout() is called with DnsQuery* as userdata, and it calls dns_query_stop() which invalidates that pointer. If it was ever called again, we'd be accessing already-freed memory. I don't see what would hold the reference. sd-event takes a temporary reference, but on the sd_event object, not on the individual sources. And our sources are non-floating, so there is no reference from the sd_event object to the sources. For #18427.
Diffstat (limited to 'src/resolve/resolved-dns-query.c')
-rw-r--r--src/resolve/resolved-dns-query.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/resolve/resolved-dns-query.c b/src/resolve/resolved-dns-query.c
index 7fb2e110e0..7554d1e82f 100644
--- a/src/resolve/resolved-dns-query.c
+++ b/src/resolve/resolved-dns-query.c
@@ -326,7 +326,7 @@ static void dns_query_stop(DnsQuery *q) {
assert(q);
- q->timeout_event_source = sd_event_source_unref(q->timeout_event_source);
+ q->timeout_event_source = sd_event_source_disable_unref(q->timeout_event_source);
LIST_FOREACH(candidates_by_query, c, q->candidates)
dns_query_candidate_stop(c);