From patchwork Sun Oct 8 10:37:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Lichtenheld X-Patchwork-Id: 3380 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7300:b412:b0:f2:62eb:61c1 with SMTP id dj18csp1441347dyb; Sun, 8 Oct 2023 03:38:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH2LWCz2To00Q7xsCheFOtgLPHSYRKmoLz/37kjiUSgnBSKU6qQSZGXG0Qz5CXULcO6I/Kd X-Received: by 2002:a05:6a20:7f84:b0:15a:4634:e4c with SMTP id d4-20020a056a207f8400b0015a46340e4cmr12729217pzj.5.1696761538113; Sun, 08 Oct 2023 03:38:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696761538; cv=none; d=google.com; s=arc-20160816; b=EZAfX3Mycd3LJqTGSZYM4Z9vWGpRu83ZFQP6mFFWtcPdguCtqRXnb1bVlmbZYdidxX MHFV81Pfzv4Yt4b2gEce+NA4/QPKeA0BVZCxUQ6rwv7rfMnzOn9ia223uvMERyypZ1Ds 1Z3+6nA5DaKrWl5fpxSFJsJHdRlCcJyFBdjg7tciE2dJPAyDvSAr909vAP7N/naoJg3L loMOKXjPkFDX6akUGO6Kcx9BieRtyft33CNUUlt/BmH5sE7OFRFOE7Sayq3UAMvryJFl fREFm7LLvC8UefP/tvt3tKiw5KJk7i0/u5Jq63rwHCwRP7hO6ofGUmOiVXnzqDTaiUkY F2oQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:content-transfer-encoding:cc: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:dkim-signature; bh=B6VBcJfQsUUEauqTW1+COO7Ehe6vtgETFAW1sQ7Fgtc=; fh=CfxSpwd5kfiMJoL3kcov7PTxVKT7pGe/79idnx9XlBs=; b=E5vPv8Dpj5ie2ZPr/Bl0EsM2304SfiQwn3pBomxMHUCVXbpJLuthSorpaMNaWAWntK PhAf8BVsxU7hGfS2QatNAFrrgiJKNNyhMVEYxS+c4CIgM3wrSpQwgd+N+qnwFarzRW5o LaNDxlvBb6Wv7lNDCim9LdKYvDClipSxS8ICUD9ZaK+sKlW/zljLEA1SHYn4XkcDqG8W KQMJh+GnrXgjdWqeuZRIIsbX+uI/Ap1mQuzrMcyxnFVbpCIJI2zy6aSBG6WKcZTd09vL EFX0Vg8Fiwz1tafzXRi6xinnSQLx7c8/tRvfgHGEtuP6VtrLsrjk1uyLncCa5JV31JqF bseA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=ChqWaOXa; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=Q9pKfxlm; dkim=neutral (body hash did not verify) header.i=@lichtenheld.com header.s=MBO0001 header.b=m+o0ZSI5; 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 Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 15-20020a63020f000000b00578acf1e8a4si7814070pgc.573.2023.10.08.03.38.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Oct 2023 03:38:58 -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=ChqWaOXa; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=Q9pKfxlm; dkim=neutral (body hash did not verify) header.i=@lichtenheld.com header.s=MBO0001 header.b=m+o0ZSI5; 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 Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1qpRAh-0007NJ-BM; Sun, 08 Oct 2023 10:38:01 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1qpRAg-0007N3-6L for openvpn-devel@lists.sourceforge.net; Sun, 08 Oct 2023 10:38:00 +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:Cc:To:From:Sender:Reply-To: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=axvmehlncluZhgpfoS3TEqBVIc/wdYF5Hsudd4v7uyc=; b=ChqWaOXa0RUg9i5JfnmOj6LDuu /FZkqKeHQ+nVNsrdWnCSi0k9vJXRZ6PlDaQ12+y0SeA+M2+x+2EofkCLmLb1TeaqUgM1N5R4x7R7H p01weDZMI83hmgT1hAyxscwnyQwSreLD5WwV8jN0o8OHb1IRctpKLw6adiIre8nrs1n8=; 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:Cc:To:From:Sender:Reply-To: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=axvmehlncluZhgpfoS3TEqBVIc/wdYF5Hsudd4v7uyc=; b=Q9pKfxlmk/nibJzbsESerI+IV2 bjjMFY+xqVZ0UJQYCu/8l9kwBSGpeLJ2GovILVvROLysMo6+Fy3nGNLuc8LSfPoTYSKhV/L5bJa7g LpmnzVMTfLn0P/zC9hmoo7JtFZov2+vjrAZXze5XUrJvbxymZVno3Z7pEscDSlAj4Btc=; Received: from mout-p-201.mailbox.org ([80.241.56.171]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1qpRAY-0070yQ-Oo for openvpn-devel@lists.sourceforge.net; Sun, 08 Oct 2023 10:38:00 +0000 Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4S3JX75q8Vz9sSN; Sun, 8 Oct 2023 12:37:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lichtenheld.com; s=MBO0001; t=1696761463; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=axvmehlncluZhgpfoS3TEqBVIc/wdYF5Hsudd4v7uyc=; b=m+o0ZSI5/4xBqvFDEJDqxSYelRBHV1w9DDJeKpNLrg0iCEIlwd1OSuXX5GjXfsTksNRosl ZrOUyJUb8bFq+HbTQQthqnl797S4I9Op/n3d5rpLxlzyAbNjhl0tf5xjjzpfUaCNpKHpCh qLXHRUMBnazhT0j5GzPx6CdEnEZlSndNXrqkDFnSAWAgjeYUpBYHkQBnv0peBPc9AV1IiQ /DjsMAV8OEmIRf9KVcLqX46vJInt8b21E4ACq7SbaK1WG1njtXfHAAvTyIj8LafXOzHgza 07aiC1ZqP7f3j1iXqVtXktQf/Qowh4wgZQ2mUQ65VmeCrkvyW8mVoU2JhWMKbQ== From: Frank Lichtenheld To: openvpn-devel@lists.sourceforge.net Date: Sun, 8 Oct 2023 12:37:42 +0200 Message-Id: <20231008103742.20019-1-frank@lichtenheld.com> In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 4S3JX75q8Vz9sSN X-Spam-Score: -1.9 (-) 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: 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 --- Content analysis details: (-1.9 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [80.241.56.171 listed in list.dnswl.org] -1.0 RCVD_IN_MSPIKE_H5 RBL: Excellent reputation (+5) [80.241.56.171 listed in wl.mailspike.net] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-Headers-End: 1qpRAY-0070yQ-Oo Subject: [Openvpn-devel] [PATCH] 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: , Cc: Arne Schwabe 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?1779183426808770870?= 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 1 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 6787ea7..28b58b0 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))