From: Selva Nair Date: Thu, 14 Apr 2016 03:53:33 +0000 (-0400) Subject: Ensure input read using systemd-ask-password is null terminated X-Git-Tag: v2.4_alpha1~114 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d09fbf958f1c0b15372b3e87d784ae666b91a96b;p=thirdparty%2Fopenvpn.git 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 --- 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;