From patchwork Tue Sep 10 17:00:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 3821 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:6bd4:b0:5b9:581e:f939 with SMTP id c20csp2227178max; Tue, 10 Sep 2024 10:00:25 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXlTkYG5tD9yPuWZLDS7vYx21eFDcDofjnV8jCZSH2h972+6grJNFNl3eIqFRhBkUTap4wey53zwcM=@openvpn.net X-Google-Smtp-Source: AGHT+IGI7XQ9zH3FHN+4ShpC3el1dS9205TCbiEZmQSKlbmjq+D7PDku/VpDKEyLnKZmY4THkR+8 X-Received: by 2002:a05:6870:1652:b0:270:2ceb:f212 with SMTP id 586e51a60fabf-27c1b7e4d5emr325940fac.29.1725987624985; Tue, 10 Sep 2024 10:00:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725987624; cv=none; d=google.com; s=arc-20240605; b=ZSTWudU3ttgvPMJuwf84lbe8TuhsavuTQ5ZLTtLMVwXSzLMqchcfba+IriQ0EBTxCq UNn6mBx4+c6DqbzjMEdl3xNG8r53YodLlHsjJlYB+SrE6Dq0L/KairsxqIT8NiJxqKp6 lXzORgiVgacMaGap96cJ1UxEtgJEq/kmcVgAdFcGDQdM5ZjD3t/OoKIQeYtL/3eIBU3Z Vw7fqEzjshB0OtPi0FLirsExlx8pCBCRqZ5UAnXekwd7XBQ6WpqTyhkCUDxFk8TKRo5a prWYsIsCrK/9RtVYu7V9l4dKERhb/7VF4bplvbaiAlvXcAlf3B5Zum6tvT+B9SzCAfW4 Z6Ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature; bh=2Gd0yYKRTJY7iP+iz10K+Wg90V3L7YqzDzo9plz5rAo=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=OPbOI+Chb3c7HRs7z2Sf4Yz2Kx+2YerbNMKEUabrbHvkTs6TVD2v+3iyZ0T9d3svtl j/SgG1u0BwP4svXzQMPRpXzGVh2fmYMNn+dcAUsPIRNHLWRhtbLqiZK/1/+v+Mh217kf m+5ezhHl2AQvyPiz3eMmCEXhCkAQFahGjuQPPbl1zUcWUdTsMXrkZObv05tiML021BD+ Pnk951YiODv4fEJ8PvaYM87jwNxppg3W0CNxYwSjbkkciruJD6ON1/YTwlVtbqmfI9iW og5HbZtAWzFcGgNQB+iQf4D6lWw0xwYaFh3oSfwtt0UYa/Eocm3TnmgzseIdK+oan4Pm v8fA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=GW2Sf3oS; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=D3nwFoEN; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 586e51a60fabf-27ba40a415fsi3502428fac.148.2024.09.10.10.00.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Sep 2024 10:00:24 -0700 (PDT) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=GW2Sf3oS; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=D3nwFoEN; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1so4Dx-0008T6-Bz; Tue, 10 Sep 2024 17:00:17 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1so4Dw-0008T0-1f for openvpn-devel@lists.sourceforge.net; Tue, 10 Sep 2024 17:00:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=HU3fI7Dt9sNvEiS9wMECSGghQXsp0RkbAjTFFYNYCYs=; b=GW2Sf3oSWw2yF3BRpmdgsaD9Aq b9q24VutkJ4jKQxOXJpq4hK+bGfC6uoXrZnwr+nKv6rE6evIInl83zidxMTou+hf+/V4Fyicylg3R dONn5jMHl9jwTvhOIA3le6aLw8GFOTv6vEPJdzdzeZPm1w4Fx2rnE/7ulhxmYPn5sdC8=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=HU3fI7Dt9sNvEiS9wMECSGghQXsp0RkbAjTFFYNYCYs=; b=D3nwFoENysSsVXCaJPNooIjnpO Q1YVpiUuA50cXZyv9qNoSSg5vRC0hZ+3pLy3a6LQx3juPeSn4E5TlKHbp738LBp3AMmWR7do/eD7D HgoVRCLhQV3clUR7T9dVbXcS9Pnrg5AtBIOeEbINiTjbfA+cximzmwCpcFQMxaVOnGuY=; Received: from dhcp-174.greenie.muc.de ([193.149.48.174] helo=blue.greenie.muc.de) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1so4Dv-0003Pk-04 for openvpn-devel@lists.sourceforge.net; Tue, 10 Sep 2024 17:00:15 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.17.1.9/8.17.1.9) with ESMTP id 48AH08XX005596 for ; Tue, 10 Sep 2024 19:00:08 +0200 Received: (from gert@localhost) by blue.greenie.muc.de (8.17.1.9/8.17.1.9/Submit) id 48AH088r005595 for openvpn-devel@lists.sourceforge.net; Tue, 10 Sep 2024 19:00:08 +0200 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Tue, 10 Sep 2024 19:00:05 +0200 Message-ID: <20240910170005.5586-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.44.2 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Score: -0.0 (/) X-Spam-Report: Spam detection software, running on the system "util-spamd-1.v13.lw.sourceforge.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Frank Lichtenheld 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. Content analysis details: (-0.0 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record X-Headers-End: 1so4Dv-0003Pk-04 Subject: [Openvpn-devel] [PATCH v3] generate_auth_token: simplify code X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1779183426808770870?= X-GMAIL-MSGID: =?utf-8?q?1809829198997633954?= From: Frank Lichtenheld 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 --- This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/310 This mail reflects revision 3 of this Change. Acked-by according to Gerrit (reflected above): Arne Schwabe 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 = string_alloc(multi->auth_token_initial, &gc); char *old_sessid = initial_token_copy + strlen(SESSION_ID_PREFIX); - char *old_tsamp_initial = old_sessid + AUTH_TOKEN_SESSION_ID_LEN*8/6; + char *old_tstamp_initial = 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] = '\0'; - ASSERT(openvpn_base64_decode(old_tsamp_initial, old_tstamp_decode, 9) == 9); + old_tstamp_initial[12] = '\0'; + ASSERT(openvpn_base64_decode(old_tstamp_initial, old_tstamp_decode, 9) == 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 = (uint64_t *) old_tstamp_decode; - initial_timestamp = *tstamp_ptr; + memcpy(&initial_timestamp, &old_tstamp_decode, sizeof(initial_timestamp)); - old_tsamp_initial[0] = '\0'; + old_tstamp_initial[0] = '\0'; ASSERT(openvpn_base64_decode(old_sessid, sessid, AUTH_TOKEN_SESSION_ID_LEN) == AUTH_TOKEN_SESSION_ID_LEN); } else if (!rand_bytes(sessid, AUTH_TOKEN_SESSION_ID_LEN))