All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dnsproxy: Fix cached ttl update
@ 2024-04-08 22:24 Brian Fukano
  2024-04-17 20:17 ` Denis Kenzior
  0 siblings, 1 reply; 2+ messages in thread
From: Brian Fukano @ 2024-04-08 22:24 UTC (permalink / raw)
  To: bfukano, connman

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);
 	}
 
 	debug("sk %d id 0x%04x answers %d ptr %p length %zd dns %zd",
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] dnsproxy: Fix cached ttl update
  2024-04-08 22:24 [PATCH] dnsproxy: Fix cached ttl update Brian Fukano
@ 2024-04-17 20:17 ` Denis Kenzior
  0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2024-04-17 20:17 UTC (permalink / raw)
  To: Brian Fukano, connman

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-04-17 20:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-08 22:24 [PATCH] dnsproxy: Fix cached ttl update Brian Fukano
2024-04-17 20:17 ` Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.