b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
From: Sven Eckelmann <sven@narfation.org>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: Sven Eckelmann <sven@narfation.org>
Subject: [PATCH] alfred: Ensure processed change_iface packet is 0-terminated
Date: Sat, 19 Feb 2022 08:54:24 +0100	[thread overview]
Message-ID: <20220219075424.802930-1-sven@narfation.org> (raw)

A client sending a alfred_change_interface_v0 packet to the alfred server
might have forgotten to 0-terminate the string. In this case, strstr in
unix_sock_change_iface might read outside of the available buffer.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 unix_sock.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/unix_sock.c b/unix_sock.c
index bc39199..8c2b762 100644
--- a/unix_sock.c
+++ b/unix_sock.c
@@ -329,6 +329,8 @@ unix_sock_change_iface(struct globals *globals,
 	if (len < (int)(sizeof(*change_iface) - sizeof(change_iface->header)))
 		goto err;
 
+	change_iface->ifaces[sizeof(change_iface->ifaces) - 1] = '\0';
+
 	if (globals->opmode == OPMODE_SECONDARY) {
 		if (strstr(change_iface->ifaces, ",") != NULL) {
 			ret = -EINVAL;
-- 
2.30.2


                 reply	other threads:[~2022-02-19  7:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20220219075424.802930-1-sven@narfation.org \
    --to=sven@narfation.org \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    /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).