[PATCH] nslookup: ensure unique transaction IDs for the DNS queries

Denys Vlasenko vda.linux at googlemail.com
Tue May 9 17:33:08 UTC 2023


Applied, thank you.

On Sat, Oct 8, 2022 at 7:23 PM Uwe Kleine-König <uwe at kleine-koenig.org> wrote:
>
> The transaction IDs generated by res_mkquery() for both glibc and musl only
> depends on the state of the monotonic clock.
> For some machines (here: a TP-Link RE200 powered by a MediaTek MT7620A)
> the monotonic clock has a coarse resolution (here: 20 µs) and it can happen
> that the requests for A and AAAA share the same transaction ID.
>
> In that case the mapping from received responses to the sent queries
> doesn't work and name resolution fails as follows:
>
>         # /bin/busybox nslookup heise.de
>         Server:         127.0.0.1
>         Address:        127.0.0.1:53
>
>         Non-authoritative answer:
>         Name:   heise.de
>         Address: 193.99.144.80
>
>         *** Can't find heise.de: No answer
>
> because the AAAA reply is dropped as a duplicate reply to the A query.
>
> To prevent this make sure the transaction IDs are unique.
> ---
>  networking/nslookup.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/networking/nslookup.c b/networking/nslookup.c
> index 6da97baf4216..61e3eb6052ab 100644
> --- a/networking/nslookup.c
> +++ b/networking/nslookup.c
> @@ -978,6 +978,10 @@ int nslookup_main(int argc UNUSED_PARAM, char **argv)
>                 }
>         }
>
> +       /* Ensure the Transaction IDs are unique */
> +       for (rc = 1; rc < G.query_count; rc++)
> +               G.query[rc].query[1] = G.query[rc - 1].query[1] + 1;
> +
>         for (rc = 0; rc < G.serv_count;) {
>                 int c;
>
> --
> 2.37.2
>
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox


More information about the busybox mailing list