From: "cron2 (Code Review)" Date: Wed, 11 Sep 2024 12:07:48 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <1a308e59c809ce6dd8ccd40ef3026cc4a7047ba7-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="Ncye1I7LRw4="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: generate_auth_token: simplify code List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld , plaisthos Cc: openvpn-devel --Ncye1I7LRw4= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has uploaded a new patch set (#4) to the change originally created by= flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/310?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+2 by plaisthos Change subject: generate_auth_token: simplify code ...................................................................... generate_auth_token: simplify code The previous code went through some hoops to avoid compiler warnings. But there is a much easier way by just telling it exactly what you want to do. Also fix typo in variable name while I'm here. Change-Id: Icc86334b26ba1fcc20f4cd03644018d1d16796e3 Signed-off-by: Frank Lichtenheld Acked-by: Arne Schwabe Message-Id: <20240910170005.5586-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29= 178.html Signed-off-by: Gert Doering --- M src/openvpn/auth_token.c 1 file changed, 5 insertions(+), 11 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/10/310/4 diff --git a/src/openvpn/auth_token.c b/src/openvpn/auth_token.c index c4b59b9..192c7c2 100644 --- a/src/openvpn/auth_token.c +++ b/src/openvpn/auth_token.c @@ -182,24 +182,18 @@ char *initial_token_copy =3D string_alloc(multi->auth_token_initia= l, &gc); char *old_sessid =3D initial_token_copy + strlen(SESSION_ID_PREFIX= ); - char *old_tsamp_initial =3D old_sessid + AUTH_TOKEN_SESSION_ID_LEN= *8/6; + char *old_tstamp_initial =3D old_sessid + AUTH_TOKEN_SESSION_ID_LE= N*8/6; /* * We null terminate the old token just after the session ID to let * our base64 decode function only decode the session ID */ - old_tsamp_initial[12] =3D '\0'; - ASSERT(openvpn_base64_decode(old_tsamp_initial, old_tstamp_decode,= 9) =3D=3D 9); + old_tstamp_initial[12] =3D '\0'; + ASSERT(openvpn_base64_decode(old_tstamp_initial, old_tstamp_decode= , 9) =3D=3D 9); - /* - * Avoid old gcc (4.8.x) complaining about strict aliasing - * by using a temporary variable instead of doing it in one - * line - */ - uint64_t *tstamp_ptr =3D (uint64_t *) old_tstamp_decode; - initial_timestamp =3D *tstamp_ptr; + memcpy(&initial_timestamp, &old_tstamp_decode, sizeof(initial_time= stamp)); - old_tsamp_initial[0] =3D '\0'; + old_tstamp_initial[0] =3D '\0'; ASSERT(openvpn_base64_decode(old_sessid, sessid, AUTH_TOKEN_SESSIO= N_ID_LEN) =3D=3D AUTH_TOKEN_SESSION_ID_LEN); } else if (!rand_bytes(sessid, AUTH_TOKEN_SESSION_ID_LEN)) -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/310?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Icc86334b26ba1fcc20f4cd03644018d1d16796e3 Gerrit-Change-Number: 310 Gerrit-PatchSet: 4 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-MessageType: newpatchset --Ncye1I7LRw4= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 uploaded patch set #4 to the change originally cr= eated by flichtenheld.

View Change

The following approvals got outda= ted and were removed: Code-Review+2 by plaisthos

generate_auth_token: simplify code

The pr= evious code went through some hoops
to avoid compiler warnings. But ther= e is
a much easier way by just telling it
exactly what you want to do= .

Also fix typo in variable name while I'm
here.

Chang= e-Id: Icc86334b26ba1fcc20f4cd03644018d1d16796e3
Signed-off-by: Frank Lic= htenheld <frank@...2641...>
Acked-by: Arne Schwabe <arne-openvp= n@...1227...>
Message-Id: <20240910170005.5586-1-gert@...1296...&g= t;
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net= /msg29178.html
Signed-off-by: Gert Doering <gert@...1296...>
--= -
M src/openvpn/auth_token.c
1 file changed, 5 insertions(+), 11 dele= tions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/cha=
nges/10/310/4
diff --git a/src/openvpn/auth_token.c b/src/openvpn/a=
uth_token.c
index c4b59b9..192c7c2 100644
-= -- a/src/openvpn/auth_token.c
+++ b/src/openvpn/auth_token.= c
@@ -182,24 +182,18 @@
char *init= ial_token_copy =3D string_alloc(multi->auth_token_initial, &gc);

char *old_sessid =3D initial_token_= copy + strlen(SESSION_ID_PREFIX);
- char *old_tsamp_initial =3D old_sessid + AUTH_TOKEN_SES= SION_ID_LEN*8/6;
+ = char *old_tstamp_initial =3D old_sessid + AUTH_TOKEN_SESSION_ID_LEN*8/= 6;

/*
= * We null terminate the old token just after the session ID to let * our base64 decode function only decode the session ID
*/
- old_tsamp_initial[12] =3D '\0';
- ASSERT(openvpn_base64_decode(old_ts= amp_initial, old_tstamp_decode, 9) =3D=3D 9);
+ old_tstamp_initial[12] =3D '\0';<= /span>
+ ASSERT(openv= pn_base64_decode(old_tstamp_initial, old_tstamp_decode, 9) =3D=3D 9);

- /= *
- * Avoid old= gcc (4.8.x) complaining about strict aliasing
- * by using a temporary variable instead o= f doing it in one
- = * line
- *= /
- uint64_t *ts= tamp_ptr =3D (uint64_t *) old_tstamp_decode;
- initial_timestamp =3D *tstamp_ptr;+ memcpy(&initial_t= imestamp, &old_tstamp_decode, sizeof(initial_timestamp));

- old_tsamp= _initial[0] =3D '\0';
+ old_tstamp_initial[0] =3D '\0';
= ASSERT(openvpn_base64_decode(old_sessid, sessid, AUTH_TOKEN_SESSION= _ID_LEN) =3D=3D AUTH_TOKEN_SESSION_ID_LEN);
} else if (!rand_bytes(sessid, AUTH_TOKEN_SESSION_ID_LEN))

To view, visit change 310. To unsubscribe, or for= help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Icc86334b26ba1fcc20f4cd03644= 018d1d16796e3
Gerrit-Change-Number: 310
Gerrit-PatchSet: 4
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-MessageType: newpatchset
--Ncye1I7LRw4=--