Skip to contentSkip to conversation

Fix binary and used instead auth-token check instead of logical and

PATCH In review Arne Schwabe 3 participants 3 messages Mar 31, 2021 – May 3, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix binary and used instead auth-token check instead of logical and

AUTH_TOKEN_HMAC_OK is 1, so the first term is always 0/1 and the bool from the second part is also 0/1, so the & does the same in this instance as &&.

In this specific case & instead && does not change behaviour but using && is the intended semantic behaviour.

---
 src/openvpn/auth_token.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/openvpn/auth_token.c +1 -1
index cc70c06c3..d571b686e 100644
@@ -99,7 +99,7 @@ add_session_token_env(struct tls_session *session, struct tls_multi *multi,
     /* We had a valid session id before */
     const char *session_id_source;
     if (multi->auth_token_state_flags & AUTH_TOKEN_HMAC_OK
-        &!(multi->auth_token_state_flags & AUTH_TOKEN_EXPIRED))
+        && !(multi->auth_token_state_flags & AUTH_TOKEN_EXPIRED))
     {
         session_id_source = up->password;
     }
Signature · 1 line
2.30.1
#1 lore raw

Hi,

I would reword the commit subject, because the way it is now fails to highlight that we are talking about a bitwise-and operator (&).

Quoted 18 lines · Arne Schwabe

AUTH_TOKEN_HMAC_OK is 1, so the first term is always 0/1 and the bool from the second part is also 0/1, so the & does the same in this instance as &&.

In this specific case & instead && does not change behaviour but using && is the intended semantic behaviour.

---
 src/openvpn/auth_token.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/openvpn/auth_token.c +0 -0
index cc70c06c3..d571b686e 100644

src/openvpn/auth_token.c add_session_token_env(struct tls_session *session, struct tls_multi *multi, · line 105

Quoted 8 lines
src/openvpn/auth_token.c +1 -1
@@ -99,7 +99,7 @@ add_session_token_env(struct tls_session *session, struct tls_multi *multi,
     /* We had a valid session id before */
     const char *session_id_source;
     if (multi->auth_token_state_flags & AUTH_TOKEN_HMAC_OK
-        &!(multi->auth_token_state_flags & AUTH_TOKEN_EXPIRED))
+        && !(multi->auth_token_state_flags & AUTH_TOKEN_EXPIRED))
     {
         session_id_source = up->password;
     }

Compile-tested and I stared at the change long enough that I can feel confident it does not change any functional behaviour.

The commit subject did not pass the compile test :) therefore I Will wait for a new revision before leaving my ACK.

Cheers,

Signature · 1 line
Antonio Quartulli
Acked-by on v1 1/1
#2 lore raw

[Openvpn-devel] [PATCH applied] Re: Fix binary and (&) used in auth-token check instead of logical and (&&)

In reply to Arne Schwabe

Your patch has been applied to the master branch.

Release/2.5 has this fix already, as part of commit 3aca477a1b58.

Antonio complained about the patch subject:, and asked for a v2 - which I did not see anywhere, so I rewrote the commit subject and now it's out of my work queue :-)

commit 0cbfa10e6aac01831bebe42ab33dc56c4704c1a6

Author: Arne Schwabe
Date:   Wed Mar 31 17:55:08 2021 +0200
     Fix binary and (&) used in auth-token check instead of logical and (&&)

     Signed-off-by: Arne Schwabe <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg21911.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering