From patchwork Fri Jun 26 15:29:46 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 5036 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7001:a48a:b0:861:c897:cb9d with SMTP id vp10csp2009653mab; Fri, 26 Jun 2026 08:30:43 -0700 (PDT) X-Forwarded-Encrypted: i=2; AFNElJ+W72SmoBvrU0xEeF06LrjcCab6K/qd/MEJ/IQJMZDESBE/SCLeIGSc8G0efr6N9zRjYsGHvRDVaGU=@openvpn.net X-Received: by 2002:a05:6808:c2a7:b0:491:7c98:710d with SMTP id 5614622812f47-4921841099amr6289145b6e.31.1782487843173; Fri, 26 Jun 2026 08:30:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1782487843; cv=none; d=google.com; s=arc-20260327; b=We5efJIhjI4Ei+QDZdhADtQc/V2kJmbbmptIt+AlhgTr9KnpjaRAtB2ssxKOQGitQg hCKl1q7Zpt9yWlAg10hI/aNGqDqqXZayTdUw6g9ByL/hzfRJtFojXaskbmIjbnWBV97y tfAdcB+jYYzpz7/yP+PCmysPFIdLGybdBNlKCsIQyVpFCTxt9lcSqDTQnxBkexmTxyr5 42+GlhFkmba27IjM+mRB36dBMCYodQdu9yDXAG3PLc4T7oGx7evVpdOUxS4vYmY4pOYT bDxhYjOCWYSZorNd4AxX/0akqyEE5Js4UbT4rSYz/7cOyzWDyYE3EGVe8OdJ7uIhGsL+ MOZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; 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:dkim-signature; bh=1mup4dMEPdIln5KXdCzq4XHDRjsrQKNO5Zm+FmxNUPA=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=UfHzTUHGlHASr1iFZEFv6/V6mdjYlSFXxQiFnNDBBsG1T3WzEMMX2dD5Z0IWgZmxzE drG+Ytwu5NUYQZ+AXKyfU3VguGpp5YpOcepi1q/D6kFZDC8T3T1kVB9YCuj2VlNbQyzQ 5Bv0m4hvPYETVmkULi4CXj7cPdYfd7nX7jHP3kMOMyQSFcCC7FZWjli/NjuljRXvKQXi 65NY1eBW+1qLzyBHRT8BPMj4ivyy1ExuSOBcrRnI475wL7ZrwoF6aSuv8yj7p+0QCP1r jtg/4KDyKu8z7wIsUkW3QoElXsgsd32ZYoWEjOA9C2aCXaBhqiTrjXjZKYEyZ5LIJyko WV5A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=XUCPvvuz; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=YbdRtlvs; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=LurtpiDr; 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 5614622812f47-49351dd7c2asi1698942b6e.25.2026.06.26.08.30.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Jun 2026 08:30:42 -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=pass header.i=@lists.sourceforge.net header.s=beta header.b=XUCPvvuz; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=YbdRtlvs; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=LurtpiDr; 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 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Subject:MIME-Version:References:In-Reply-To:Message-ID:Date:To:From:Sender: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=1mup4dMEPdIln5KXdCzq4XHDRjsrQKNO5Zm+FmxNUPA=; b=XUCPvvuzltYYK/RbRDQgGN60u0 IqV9Z6xKtmPoZDulhBFdGC3tizTHQgzGGrjbYOz5RHJvGeBspGr/xfVbku7tUc83ZBAZtTKuy70hS T8Ax3RcP6LroBU8crWsVqcEdUd1DBkXj7yRdExdqyNKhCdofJeBPHbK4GwkWe6hzhkwM=; Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1wd8Vs-0007WH-CI; Fri, 26 Jun 2026 15:30:37 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1wd8VY-0007Vq-Li for openvpn-devel@lists.sourceforge.net; Fri, 26 Jun 2026 15:30:23 +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=V9vSu3C/sIYSvdNowAdX9Ev6DaW/6HC+v+QvsfN0bcQ=; b=YbdRtlvsqmT6LHAx/0x4OmyA42 YjWjJyfoecczLjPMZxPpTALrRd3o7Fm97DXNicQPBXiy+ALtM64X0wPs+s69Kx+y3l6Mt8wMXegnI sS47bE/VRSDE8aGUKbX9erC4Rj2X/9cXuk/4GyaZBB6eJRJjGP8IUB98ZeEA663HfuAU=; 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=V9vSu3C/sIYSvdNowAdX9Ev6DaW/6HC+v+QvsfN0bcQ=; b=LurtpiDrYf9IOlNeFPZjVvhmTV 2vMbGvWAKwFWEj8tvyCrOQz65+740Roc5ylO2ZWNnZ118d1qG/YQJ8P0ihIvLnTUoo32eL3YuVmuh +0L1dFP8/tCepNqbizSKU2mo/wOXKq96GB/no8qTDwOkBBhrJeCNuvMMRA8SA889mCVE=; Received: from [193.149.48.129] (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 1wd8VH-0008Hn-91 for openvpn-devel@lists.sourceforge.net; Fri, 26 Jun 2026 15:30:05 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.18.1/8.18.1) with ESMTP id 65QFTpXF029229 for ; Fri, 26 Jun 2026 17:29:51 +0200 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.2/8.18.1/Submit) id 65QFTp1w029227 for openvpn-devel@lists.sourceforge.net; Fri, 26 Jun 2026 17:29:51 +0200 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Fri, 26 Jun 2026 17:29:46 +0200 Message-ID: <20260626152951.29207-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Score: 1.3 (+) X-Spam-Report: Spam detection software, running on the system "sfi-spamd-1.hosts.colo.sdot.me", 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: Arne Schwabe This avoids having get_ranomd being different on 32bit/Windows vs 64 bit Unix platform. Also adjust platform_create_temp_file to create the same files on all platforms. Content analysis details: (1.3 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS X-Headers-End: 1wd8VH-0008Hn-91 Subject: [Openvpn-devel] [PATCH v2] Make get_random return int64 instead of long 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: 1869073972543089937 X-GMAIL-MSGID: 1869073972543089937 From: Arne Schwabe This avoids having get_ranomd being different on 32bit/Windows vs 64 bit Unix platform. Also adjust platform_create_temp_file to create the same files on all platforms. Change-Id: Ifefb3ad204c0c16cb4952dd6e8661fdc9136b125 Signed-off-by: Arne Schwabe Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1732 --- 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/+/1732 This mail reflects revision 2 of this Change. Acked-by according to Gerrit (reflected above): Gert Doering diff --git a/src/openvpn/crypto.c b/src/openvpn/crypto.c index 7954e8a..3d79fe5 100644 --- a/src/openvpn/crypto.c +++ b/src/openvpn/crypto.c @@ -1731,11 +1731,12 @@ ASSERT(rand_bytes(output, len)); } -/* an analogue to the random() function, but use prng_bytes */ -long int +/* an analogue to the random() function, but use prng_bytes and + * also int64_t instead of long to avoid LLP64 vs LP64 */ +int64_t get_random(void) { - long int l; + int64_t l; prng_bytes((unsigned char *)&l, sizeof(l)); if (l < 0) { diff --git a/src/openvpn/crypto.h b/src/openvpn/crypto.h index fbca2a0..ee5b50f 100644 --- a/src/openvpn/crypto.h +++ b/src/openvpn/crypto.h @@ -603,8 +603,13 @@ */ void prng_bytes(uint8_t *output, int len); -/* an analogue to the random() function, but use prng_bytes */ -long int get_random(void); +/** + * an analogue to the random() function, but use prng_bytes and + * also int64_t instead of long to avoid LLP64 vs LP64 + * + * @return Returns a random positive 63 bit integer + */ +int64_t get_random(void); /** Print a cipher list entry */ void print_cipher(const char *cipher); diff --git a/src/openvpn/platform.c b/src/openvpn/platform.c index 9fa9363..85b6408 100644 --- a/src/openvpn/platform.c +++ b/src/openvpn/platform.c @@ -543,7 +543,7 @@ const char *retfname = NULL; unsigned int attempts = 0; char fname[256] = { 0 }; - const char *fname_fmt = PACKAGE "_%.*s_%08lx%08lx.tmp"; + const char *fname_fmt = PACKAGE "_%.*s_%08" PRIx64 "%08" PRIx64 ".tmp"; const int max_prefix_len = sizeof(fname) - (sizeof(PACKAGE) + 7 + (2 * 8)); while (attempts < 6) @@ -551,7 +551,7 @@ ++attempts; if (!checked_snprintf(fname, sizeof(fname), fname_fmt, max_prefix_len, prefix, - (unsigned long)get_random(), (unsigned long)get_random())) + get_random(), get_random())) { msg(M_WARN, "ERROR: temporary filename too long"); return NULL;