From: "flichtenheld (Code Review)"
Date: Tue, 10 Sep 2024 12:14:10 +0000
In-Reply-To:
References:
Reply-To: frank@...2641..., arne-openvpn@...1227...,
openvpn-devel@lists.sourceforge.net
Message-ID: <494afba00515c6afe8cab54745c753d01080f3e0-EmailReplacePatchSet-HTML@...2715...>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Disposition: inline
Content-Type: multipart/alternative; boundary="ooOq0TTeFaE="; 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: plaisthos
Cc: openvpn-devel
--ooOq0TTeFaE=
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Attention is currently required from: flichtenheld.
Hello plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/310?usp=3Demail
to look at the new patch set (#3).
The change is no longer submittable: checks~ChecksSubmitRule is unsatisfied=
now.
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
---
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/3
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: 3
Gerrit-Owner: flichtenheld
Gerrit-Reviewer: plaisthos
Gerrit-CC: openvpn-devel
Gerrit-Attention: flichtenheld
Gerrit-MessageType: newpatchset
--ooOq0TTeFaE=
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Attention is currently required from: flichtenheld.
flichtenheld uploaded patch set #3 to this change.
<=
p>View Ch=
ange
The change is no longer submittable: checks~ChecksSubmitRule=
is unsatisfied now.
generate_auth_token: simplify code
The previous=
code went through some hoops
to avoid compiler warnings. But there isa much easier way by just telling it
exactly what you want to do.
<=
br>Also fix typo in variable name while I'm
here.
Change-Id: =
Icc86334b26ba1fcc20f4cd03644018d1d16796e3
Signed-off-by: Frank Lichtenhe=
ld <frank@...2641...>
---
M src/openvpn/auth_token.c
1 file =
changed, 5 insertions(+), 11 deletions(-)
git pull ssh://gerrit.o=
penvpn.net:29418/openvpn refs/changes/10/310/3
diff --git a/src/ope=
nvpn/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_initial, &gc);
ch=
ar *old_sessid =3D initial_token_copy + strlen(SESSION_ID_PREFIX);- char *old_tsamp_initia=
l =3D old_sessid + AUTH_TOKEN_SESSION_ID_LEN*8/6;
+ char *old_tstamp_initial =3D old_sess=
id + AUTH_TOKEN_SESSION_ID_LEN*8/6;
=
/*
* We null terminate the old token just aft=
er the session ID to let
* our base64 decode func=
tion only decode the session ID
*/
- old_tsamp_initial[12] =3D =
39;\0';
- AS=
SERT(openvpn_base64_decode(old_tsamp_initial, old_tstamp_decode, 9) =3D=3D =
9);
+ old_tsta=
mp_initial[12] =3D '\0';
+ ASSERT(openvpn_base64_decode(old_tstamp_initial, old_t=
stamp_decode, 9) =3D=3D 9);
- /*
- * Avoid old gcc (4.8.x) complaining about strict alia=
sing
- * by usi=
ng a temporary variable instead of doing it in one
- * line
- */
- uint64_t *tstamp_ptr =3D (uint64_t *) old_tstamp_decod=
e;
- initial_tim=
estamp =3D *tstamp_ptr;
+ memcpy(&initial_timestamp, &old_tstamp_decode, sizeof(i=
nitial_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_LE=
N);
}
else if (!rand_bytes(sessid=
, AUTH_TOKEN_SESSION_ID_LEN))
To view, =
visit cha=
nge 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: 3
Gerrit-Owner: flichtenheld <frank@...2723...=
.>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...=
.1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...=
ts.sourceforge.net>
Gerrit-Attention: flichtenheld <frank@...2375...=
41...>
Gerrit-MessageType: newpatchset
--ooOq0TTeFaE=--