auth_token.c: add NULL initialization
PATCH 1/1 auth_token.c: add NULL initialization
From: Lev Stipakov <[email protected]...>
This fixes
error C4703: potentially uninitialized local pointer variable 'b64output' used
found by arm64 msvc compiler with SDL enabled.
Not sure why this is not triggered on x86/x64.
--- src/openvpn/auth_token.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/openvpn/auth_token.c +1 -1
@@ -259,7 +259,7 @@ generate_auth_token(const struct user_pass *up, struct tls_multi *multi)ASSERT (buf_write (&token, ×tamp,sizeof (timestamp)));ASSERT (buf_write (&token, hmac_output,sizeof (hmac_output))); -char *b64output; +char *b64output =NULL ;openvpn_base64_encode (BPTR (&token),BLEN (&token), &b64output); struct buffer session_token = alloc_buf_gc(
Signature · 1 line
2.23.0.windows.1
Hi,
Quoted 20 lines · Lev Stipakov
From: Lev Stipakov <[email protected]...>
This fixes
error C4703: potentially uninitialized local pointer variable 'b64output' used
found by arm64 msvc compiler with SDL enabled.
Not sure why this is not triggered on x86/x64.
Signed-off-by Lev Stipakov <[email protected]...>--- src/openvpn/auth_token.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)src/openvpn/auth_token.c +0
-0
src/openvpn/auth_token.c generate_auth_token(const struct user_pass *up, struct tls_multi *multi) · line 263
Quoted 6 lines
src/openvpn/auth_token.c +1
-1@@ -259,7 +259,7 @@ generate_auth_token(const struct user_pass *up, struct tls_multi *multi)ASSERT (buf_write (&token, ×tamp,sizeof (timestamp)));ASSERT (buf_write (&token, hmac_output,sizeof (hmac_output))); -char *b64output; +char *b64output =NULL ;openvpn_base64_encode (BPTR (&token),BLEN (&token), &b64output);
It's impossible to leave b64output uninitialized, but the compiler is probably not smart enough to understand it.
On the other hand, passing uninitialized variables by reference to a function (without checking its return value) and using them later is never a good pattern..
Signature · 1 line
Antonio Quartulli
Am 07.01.22 um 13:35 schrieb Lev Stipakov:
Quoted 20 lines
From: Lev Stipakov <[email protected]...>
This fixes
error C4703: potentially uninitialized local pointer variable 'b64output' used
found by arm64 msvc compiler with SDL enabled.
Not sure why this is not triggered on x86/x64.
Signed-off-by Lev Stipakov <[email protected]...>--- src/openvpn/auth_token.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)src/openvpn/auth_token.c +0
-0
src/openvpn/auth_token.c generate_auth_token(const struct user_pass *up, struct tls_multi *multi) · line 265
Quoted 8 lines
src/openvpn/auth_token.c +1
-1@@ -259,7 +259,7 @@ generate_auth_token(const struct user_pass *up, struct tls_multi *multi)ASSERT (buf_write (&token, ×tamp,sizeof (timestamp)));ASSERT (buf_write (&token, hmac_output,sizeof (hmac_output))); -char *b64output; +char *b64output =NULL ;openvpn_base64_encode (BPTR (&token),BLEN (&token), &b64output); struct buffer session_token = alloc_buf_gc(
Fine with me
Your patch has been applied to the master and release/2.5 branch.
I have not done real testing, as it's quite obvious what it's doing :)
commit 4b6073b8253dafeb425361fb55bab0f2cdc5474f (master) commit 813d1ee3c8b6a914599e4705eee3b8835d606e4b (release/2.5)
Author: Lev Stipakov Date: Fri Jan 7 14:35:50 2022 +0200
auth_token.c: add NULL initialization
Signed-off-by: Lev Stipakov <[email protected]...>
Acked-by: Antonio Quartulli <[email protected]...>
Acked-by: Arne Schwabe <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg23511.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering