ConnMan network manager
 help / color / mirror / Atom feed
From: Brian Fukano <bfukano@gmail.com>
To: bfukano@gmail.com, connman@lists.linux.dev
Subject: [PATCH v2] dnsproxy: Fix cached ttl update
Date: Mon, 22 Apr 2024 12:38:05 -0700	[thread overview]
Message-ID: <20240422193805.123689-1-bfukano@gmail.com> (raw)

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 | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/dnsproxy.c b/src/dnsproxy.c
index d4242560..23015f74 100644
--- a/src/dnsproxy.c
+++ b/src/dnsproxy.c
@@ -507,10 +507,8 @@ static void send_cached_response(int sk, const unsigned char *ptr, size_t len,
 	/* if this is a negative reply, we are authoritative */
 	if (answers == 0)
 		hdr->aa = 1;
-	else {
-		const int adj_len = len - 2;
-		update_cached_ttl((unsigned char *)hdr, adj_len, ttl);
-	}
+	else
+		update_cached_ttl((unsigned char *)hdr, dns_len, ttl);
 
 	debug("sk %d id 0x%04x answers %d ptr %p length %zd dns %zd",
 		sk, hdr->id, answers, ptr, len, dns_len);
-- 
2.34.1


             reply	other threads:[~2024-04-22 19:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-22 19:38 Brian Fukano [this message]
2024-04-22 22:50 ` [PATCH v2] dnsproxy: Fix cached ttl update patchwork-bot+connman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240422193805.123689-1-bfukano@gmail.com \
    --to=bfukano@gmail.com \
    --cc=connman@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).