]> git.ipfire.org Git - thirdparty/systemd.git/commit
resolved: split dns_query_process_cname() into two separate functions
authorLennart Poettering <lennart@poettering.net>
Thu, 25 Mar 2021 10:43:52 +0000 (11:43 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 25 Mar 2021 12:12:19 +0000 (13:12 +0100)
commit1db8e6d1db0880de240e5598e28d24d708479434
treee25b4f31bbb7c1f50de54ac3b87b7126655a0160
parentd451f0e84b1909ca0d24a1e3c135d5ffa2d8613c
resolved: split dns_query_process_cname() into two separate functions

This does some refactoring: the dns_query_process_cname() function
becomes two: dns_query_process_cname_one() and
dns_query_process_cname_many(). The former will process exactly one
CNAME chain element, the latter will follow a chain for as long as
possible within the current packet.

dns_query_process_cname_many() is mostly identical to the old
dns_query_process_cname(), and all existing code is moved over to using
that.

This is mostly preparation for the next commit, where we make direct use
of dns_query_process_cname_one().

This also renames the DNS_QUERY_RESTARTED return value to
DNS_QUERY_CNAME. That's because in the dns_query_process_cname_many()
case as before if we return this we restarted the query in case we
reached the end of the chain without a conclusive answer, as before. But
in dns_query_process_cname_one() we'll only go one step anyway, and
leave restarting if needed to the caller. Hence DNS_QUERY_RESTARTED is a
bit of a misnomer in that case.

This also gets rid of the weird tail recursion in
dns_query_process_cname() and replaces it with an explicit loop in
dns_query_process_cname_many(). The old recursion wasn't a security
issue since we put a limit on the number of CNAMEs we follow anyway, but
it's still icky to scale stack use by that.
src/resolve/resolved-bus.c
src/resolve/resolved-dns-query.c
src/resolve/resolved-dns-query.h
src/resolve/resolved-dns-stub.c
src/resolve/resolved-varlink.c