Re: [PATCH] dnsproxy: Fix cached ttl update
Denis Kenzior <[email protected]>
| Newsgroups | dev.linux.lists.connman |
|---|---|
| Message-ID | <[email protected]> |
Hi Brian,
On 4/8/24 17:24, Brian Fukano wrote:
> This bug was exposed after fixing the signedness comparison warnings
> found in dnsproxy.c update_cached_ttl() consistently comes up two
> bytes short when processing the last record.
> ---
> src/dnsproxy.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/src/dnsproxy.c b/src/dnsproxy.c
> index d4242560..506e1b9d 100644
> --- a/src/dnsproxy.c
> +++ b/src/dnsproxy.c
> @@ -508,8 +508,7 @@ static void send_cached_response(int sk, const unsigned char *ptr, size_t len,
> if (answers == 0)
> hdr->aa = 1;
> else {
> - const int adj_len = len - 2;
> - update_cached_ttl((unsigned char *)hdr, adj_len, ttl);
> + update_cached_ttl((unsigned char *)hdr, len, ttl);
Looks like this should be dns_len? Also, the { } around the else are no longer
needed.
https://datatracker.ietf.org/doc/html/rfc1035#section-4.2.2
> }
>
> debug("sk %d id 0x%04x answers %d ptr %p length %zd dns %zd",
Regards,
-Denis