[Openvpn-devel] Fix more of uninitialized struct user_pass local vars

Message ID 20240909204829.10379-1-selva.nair@gmail.com
State Accepted
Headers show
Series [Openvpn-devel] Fix more of uninitialized struct user_pass local vars | expand

Commit Message

Selva Nair Sept. 9, 2024, 8:48 p.m. UTC
From: Selva Nair <selva.nair@gmail.com>

Not all of these touch uninitialzed members of the struct, but that
could change in future.

Change-Id: I71bc847b48da54b70f60ccd7c4521ec699daf9cb
Signed-off-by: Selva Nair <selva.nair@gmail.com>
---
There is an unused & uninitialized struct user_pass in tun.c for ANDROID.
Could be removed?

 src/openvpn/auth_token.c | 1 +
 src/openvpn/pkcs11.c     | 1 +
 src/openvpn/socks.c      | 2 +-
 3 files changed, 3 insertions(+), 1 deletion(-)

Comments

Gert Doering Sept. 10, 2024, 6:03 a.m. UTC | #1
Acked-by: Gert Doering <gert@greenie.muc.de>

Thanks.  Not tested beyond "does it compile", as the changes are very
straightforward :-)

Your patch has been applied to the master and released/2.6 branch.

commit aa1dd09b5fc196499c84d2ef9b0c254ebb1745d8 (master)
commit f9ab7edbebd6dfb3fd384b56626aabb3171ac0ad (release/2.6)
Author: Selva Nair
Date:   Mon Sep 9 16:48:29 2024 -0400

     Fix more of uninitialized struct user_pass local vars

     Signed-off-by: Selva Nair <selva.nair@gmail.com>
     Acked-by: Gert Doering <gert@greenie.muc.de>
     Message-Id: <20240909204829.10379-1-selva.nair@gmail.com>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29152.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering

Patch

diff --git a/src/openvpn/auth_token.c b/src/openvpn/auth_token.c
index 5de65cb6..c4b59b99 100644
--- a/src/openvpn/auth_token.c
+++ b/src/openvpn/auth_token.c
@@ -452,6 +452,7 @@  check_send_auth_token(struct context *c)
     }
 
     struct user_pass up;
+    CLEAR(up);
     strncpynt(up.username, multi->locked_username, sizeof(up.username));
 
     generate_auth_token(&up, multi);
diff --git a/src/openvpn/pkcs11.c b/src/openvpn/pkcs11.c
index 418f6bb0..37cc1678 100644
--- a/src/openvpn/pkcs11.c
+++ b/src/openvpn/pkcs11.c
@@ -238,6 +238,7 @@  _pkcs11_openvpn_pin_prompt(
 {
     struct user_pass token_pass;
     char prompt[1024];
+    CLEAR(token_pass);
 
     (void)global_data;
     (void)user_data;
diff --git a/src/openvpn/socks.c b/src/openvpn/socks.c
index d95f3013..e280453d 100644
--- a/src/openvpn/socks.c
+++ b/src/openvpn/socks.c
@@ -96,7 +96,7 @@  socks_username_password_auth(struct socks_proxy_info *p,
     ssize_t size;
     bool ret = false;
 
-    creds.defined = 0;
+    CLEAR(creds);
     if (!get_user_pass(&creds, p->authfile, UP_TYPE_SOCKS, GET_USER_PASS_MANAGEMENT))
     {
         msg(M_NONFATAL, "SOCKS failed to get username/password.");