From: Marek Lindner <mareklindner@neomailbox.ch>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: Marek Lindner <mareklindner@neomailbox.ch>
Subject: [PATCH 3/3] alfred: properly initialize stack buffer before sending over unix socket
Date: Wed, 12 Jan 2022 22:05:06 +0100 [thread overview]
Message-ID: <20220112210506.3488775-3-mareklindner@neomailbox.ch> (raw)
In-Reply-To: <20220112210506.3488775-1-mareklindner@neomailbox.ch>
Without explicitely initializing the buffer with null bytes, the stack
variables may contain process information which may be leaked when
transmitted via unix socket.
Also, the size of the variables sitting on the stack can be reduced.
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
---
client.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/client.c b/client.c
index b5d8943..cf15ff4 100644
--- a/client.c
+++ b/client.c
@@ -35,6 +35,7 @@ int alfred_client_request_data(struct globals *globals)
return -1;
len = sizeof(request);
+ memset(&request, 0, len);
request.header.type = ALFRED_REQUEST;
request.header.version = ALFRED_VERSION;
@@ -184,6 +185,7 @@ int alfred_client_modeswitch(struct globals *globals)
return -1;
len = sizeof(modeswitch);
+ memset(&modeswitch, 0, len);
modeswitch.header.type = ALFRED_MODESWITCH;
modeswitch.header.version = ALFRED_VERSION;
@@ -260,6 +262,7 @@ int alfred_client_change_interface(struct globals *globals)
}
len = sizeof(change_interface);
+ memset(&change_interface, 0, len);
change_interface.header.type = ALFRED_CHANGE_INTERFACE;
change_interface.header.version = ALFRED_VERSION;
@@ -308,6 +311,7 @@ int alfred_client_change_bat_iface(struct globals *globals)
}
len = sizeof(change_bat_iface);
+ memset(&change_bat_iface, 0, len);
change_bat_iface.header.type = ALFRED_CHANGE_BAT_IFACE;
change_bat_iface.header.version = ALFRED_VERSION;
--
2.32.0.rc0
next prev parent reply other threads:[~2022-01-12 21:05 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-12 21:02 alfred: allow startup without network interface Marek Lindner
2022-01-12 21:05 ` [PATCH 1/3] alfred: move interface check into helper function Marek Lindner
2022-01-12 21:05 ` [PATCH 2/3] alfred: Allow operating without any interface specified Marek Lindner
2022-01-12 21:05 ` Marek Lindner [this message]
2022-01-21 15:34 ` [PATCH 3/3] alfred: properly initialize stack buffer before sending over unix socket Sven Eckelmann
2022-01-22 0:41 ` Marek Lindner
2022-01-22 8:03 ` Sven Eckelmann
2022-01-22 13:06 ` Marek Lindner
2022-01-12 21:11 ` alfred: allow startup without network interface Marek Lindner
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=20220112210506.3488775-3-mareklindner@neomailbox.ch \
--to=mareklindner@neomailbox.ch \
--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