From d09fbf958f1c0b15372b3e87d784ae666b91a96b Mon Sep 17 00:00:00 2001 From: Selva Nair Date: Wed, 13 Apr 2016 23:53:33 -0400 Subject: [PATCH] Ensure input read using systemd-ask-password is null terminated Also properly check the return value of read() and leave room for termination. Fixes junk data occasionally seen in strings read through systemd. Signed-off-by: Selva Nair Acked-by: Gert Doering Message-Id: <1460606013-4983-1-git-send-email-selva.nair@gmail.com> URL: http://article.gmane.org/gmane.network.openvpn.devel/11437 Signed-off-by: Gert Doering --- src/openvpn/console.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/openvpn/console.c b/src/openvpn/console.c index e1d46c413..86331a11c 100644 --- a/src/openvpn/console.c +++ b/src/openvpn/console.c @@ -172,8 +172,9 @@ get_console_input_systemd (const char *prompt, const bool echo, char *input, con if ((std_out = openvpn_popen (&argv, NULL)) < 0) { return false; } - CLEAR (*input); - if (read (std_out, input, capacity) != 0) + + memset (input, 0, capacity); + if (read (std_out, input, capacity-1) > 0) { chomp (input); ret = true; -- 2.47.2