connman.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Daniel Wagner <wagi@monom.org>
To: connman@lists.linux.dev
Cc: Matthias Gerstner <mgerstner@suse.de>
Subject: [PATCH 2/5] dnsproxy: Update TCP length header
Date: Tue, 25 Jan 2022 10:00:23 +0100	[thread overview]
Message-ID: <20220125090026.5108-3-wagi@monom.org> (raw)
In-Reply-To: <20220125090026.5108-1-wagi@monom.org>

From: Matthias Gerstner <mgerstner@suse.de>

---
 src/dnsproxy.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/dnsproxy.c b/src/dnsproxy.c
index fbbee0413f8f..cdfafbc292f2 100644
--- a/src/dnsproxy.c
+++ b/src/dnsproxy.c
@@ -2166,6 +2166,9 @@ static int forward_dns_reply(unsigned char *reply, int reply_len, int protocol,
 			err = sendto(sk, req->resp, req->resplen, 0,
 				&req->sa, req->sa_len);
 	} else {
+		uint16_t tcp_len = htons(req->resplen - 2);
+		/* correct TCP message length */
+		memcpy(req->resp, &tcp_len, sizeof(tcp_len));
 		sk = req->client_sk;
 		err = send(sk, req->resp, req->resplen, MSG_NOSIGNAL);
 	}
-- 
2.34.1


  parent reply	other threads:[~2022-01-25  9:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-25  9:00 [PATCH 0/5] dnsproxy: Add input validation checks Daniel Wagner
2022-01-25  9:00 ` [PATCH 1/5] main: Use g_strdup for online_check_ipv{4,6}_url config Daniel Wagner
2022-01-25  9:00 ` Daniel Wagner [this message]
2022-01-25  9:00 ` [PATCH 3/5] dnsproxy: Validate input data before using them Daniel Wagner
2022-01-25  9:00 ` [PATCH 4/5] dnsproxy: Avoid 100 % busy loop in TCP server case Daniel Wagner
2022-01-25  9:00 ` [PATCH 5/5] dnsproxy: Keep timeout in TCP case even after connection is established Daniel Wagner
2022-01-25  9:10 ` [PATCH 0/5] dnsproxy: Add input validation checks Daniel Wagner

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=20220125090026.5108-3-wagi@monom.org \
    --to=wagi@monom.org \
    --cc=connman@lists.linux.dev \
    --cc=mgerstner@suse.de \
    /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 NNTP newsgroup(s).