From patchwork Mon Oct 13 16:22:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 4506 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:7d42:b0:72f:f16c:e055 with SMTP id fr2csp2019460mab; Mon, 13 Oct 2025 09:22:39 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW9kifF0aeW5sBWO9TtWw5APwgHdLP2pb40ibZszsOixUp91HHOjFe0FrhLxa+K6l3BkzAqeNqSlh8=@openvpn.net X-Google-Smtp-Source: AGHT+IHtcx59HBlvPheehmdvOugdHoubYgihrKYDpa/QsbCtk2rFgh8sZZ0CqI003ODVKUJh70gD X-Received: by 2002:a05:6808:17a9:b0:43f:1a5f:281f with SMTP id 5614622812f47-4417b3c4d23mr9498876b6e.35.1760372559439; Mon, 13 Oct 2025 09:22:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1760372559; cv=none; d=google.com; s=arc-20240605; b=FGvQbZmOiu76NfWpuQLrS76HP0Qx6mHD+hazdvYD82zDjOFxRGggbY1jKWuh0b0TVm zE9J2KHO5vjTPe/ptMlIhpkPCyImnSjQYObvDc4llQ1P6iZL3USllSyNh6B8jzwkQ/kQ 8Hv7yaoOTU7BZ7hrdKNDSJovlZmUFW8GfmWnVvqbOox9q0mhnsR3Vv43mJ11pv2S5Kmd XLgBSswxECbJit6pmokjcxpR5PFneh7of2MRzhTMsCJ63LIDPn1buqw/CZJAVKs+d/Ch ScE9WlUCDrnpWIbYxD3ajIGnvrQURFpYLlZcRdTXTtXOF8L0pn3FC+GTDJDwAzIlVaGI MZ7Q== 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:dkim-signature; bh=tI6mkdPCyxRcuwZPSGFdi3TBZKIyP120vg8o3lhLO64=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=LXni1rhFejH/CnHZkAGqV9UcvJ5+hbFciOcDPfAXJeX0jM8LNxT5ciEiHX1kys+Ecc 1HwXV1hDlx/EnSySI5As71JALo4smlSaVXfVWsRBh/qXstgq3+e5KIuf0zLcBIVBcyVO db0fCtnncKOgkgJLhUMXmgB09X4nnWw9V0ZUYxEb+dTms+628yuM/RnccFvKsqAkmEk1 iuYsphC+w2gEAVk75A20lVEPugL2Pe3XnZYit/kmyJiSC2tC1g3mzPxskDDHGYbyMGy0 n59CJYWcLzKttaQRazuV1Oy9nsLtUFbbNynnYjPnsDXAw39AzD9nTuGfV+TSuzKymwyo kZnw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b="lwVrSm/+"; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=Dh2yt7Ou; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=VCojbF8w; 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-4419898c332si2464779b6e.139.2025.10.13.09.22.39 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Oct 2025 09:22:39 -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="lwVrSm/+"; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=Dh2yt7Ou; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=VCojbF8w; 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=tI6mkdPCyxRcuwZPSGFdi3TBZKIyP120vg8o3lhLO64=; b=lwVrSm/+yL/GXQJntJv5vd4aNJ tUT9+Mv1tN8T9JqPYzzwwxpb+BMyYwUlFjYdEI/4SMuzDYXTjHkCu4sDg1YzvI175vQ6HTTGYdjCl AfVdJo6IU0HSBBkoF0IGSp6O3xbvLsxd4btH3anY0FJRjoZIIj/CLVFj6yR/C52k/oME=; Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1v8LJk-0005IF-N5; Mon, 13 Oct 2025 16:22:37 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1v8LJi-0005I5-IU for openvpn-devel@lists.sourceforge.net; Mon, 13 Oct 2025 16:22:35 +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=RWtV4TJHJX+SeaBdzOiV0u5aHG+oCJrrItrJ37gp5Po=; b=Dh2yt7Ou/5D92hB7ZxJMmIAdIA iy128hbgnAsdgcmrEVp9/a9wt0AsgATB1AbEfgNx3zNst0WijjT8C+IMNsyYedgDgQxsYBtCVd4Ur 2yn49X+SXBGLYRS74OQrkHgOl6//BXvAFRfrcY1KHCoChUZmATsNgYUbUPklrMgDg3kg=; 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=RWtV4TJHJX+SeaBdzOiV0u5aHG+oCJrrItrJ37gp5Po=; b=VCojbF8wpPcHywCSp90d5qIOVG iBfurD0ugW6BUhN+EBJ+mUgJ44Rcm0sWgLp/MMsKI4E0yatSqZegaEGZCpgEE7ZnN3HD/EWWlM/4t BJhLhXt+1aRCQpZOBBGyTM0dgjOHILuVvo4YSfWiLRXBnyfP/R1QKoMtvOUcFHWVtB0Q=; Received: from [193.149.48.134] (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 1v8LJi-0000sO-AY for openvpn-devel@lists.sourceforge.net; Mon, 13 Oct 2025 16:22:35 +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 59DGMMWJ002171 for ; Mon, 13 Oct 2025 18:22:22 +0200 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.1/8.18.1/Submit) id 59DGMMNh002170 for openvpn-devel@lists.sourceforge.net; Mon, 13 Oct 2025 18:22:22 +0200 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Mon, 13 Oct 2025 18:22:15 +0200 Message-ID: <20251013162221.2156-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.49.1 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-2.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: Frank Lichtenheld This is what the Win32 APIs use. Since we put static integers into this (e.g. sizeof()) this doesn't result in new conversion warnings at the caller sites. 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: 1v8LJi-0000sO-AY Subject: [Openvpn-devel] [PATCH v1] win32: Change some APIs to use DWORD instead of size_t 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?1845884416867554210?= X-GMAIL-MSGID: =?utf-8?q?1845884416867554210?= From: Frank Lichtenheld This is what the Win32 APIs use. Since we put static integers into this (e.g. sizeof()) this doesn't result in new conversion warnings at the caller sites. Change-Id: Ia836e3c05a868a7e8419c2bb2f547d968260783c Signed-off-by: Frank Lichtenheld Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1269 --- 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/+/1269 This mail reflects revision 1 of this Change. Acked-by according to Gerrit (reflected above): Gert Doering diff --git a/src/openvpn/route.c b/src/openvpn/route.c index 0044794..fde460a 100644 --- a/src/openvpn/route.c +++ b/src/openvpn/route.c @@ -2840,7 +2840,7 @@ /* Returns RTA_SUCCESS on success, RTA_EEXIST if route exists, RTA_ERROR on error */ static int -do_route_service(const bool add, const route_message_t *rt, const size_t size, HANDLE pipe) +do_route_service(const bool add, const route_message_t *rt, const DWORD size, HANDLE pipe) { int ret = RTA_ERROR; ack_message_t ack; diff --git a/src/openvpn/win32.c b/src/openvpn/win32.c index eac2352..3c11ec3 100644 --- a/src/openvpn/win32.c +++ b/src/openvpn/win32.c @@ -1418,13 +1418,8 @@ return (const char *)out.data; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - bool -send_msg_iservice(HANDLE pipe, const void *data, size_t size, ack_message_t *ack, +send_msg_iservice(HANDLE pipe, const void *data, DWORD size, ack_message_t *ack, const char *context) { struct gc_arena gc = gc_new(); @@ -1527,7 +1522,8 @@ while (expire >= now) { - DWORD status = WaitForSingleObject(win32_signal.in.read, (expire - now) * 1000); + DWORD wait_ms = (DWORD)((expire - now) * 1000); + DWORD status = WaitForSingleObject(win32_signal.in.read, wait_ms); if ((status == WAIT_OBJECT_0 && win32_signal_get(&win32_signal)) || status == WAIT_TIMEOUT) { return; @@ -1539,7 +1535,7 @@ { if (expire > now) { - Sleep((expire - now) * 1000); + Sleep((DWORD)((expire - now) * 1000)); } return; } @@ -1602,7 +1598,7 @@ } bool -protect_buffer_win32(char *buf, size_t len) +protect_buffer_win32(char *buf, DWORD len) { bool ret; if (len % CRYPTPROTECTMEMORY_BLOCK_SIZE) @@ -1620,7 +1616,7 @@ } bool -unprotect_buffer_win32(char *buf, size_t len) +unprotect_buffer_win32(char *buf, DWORD len) { bool ret; if (len % CRYPTPROTECTMEMORY_BLOCK_SIZE) @@ -1637,8 +1633,4 @@ return ret; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - #endif /* ifdef _WIN32 */ diff --git a/src/openvpn/win32.h b/src/openvpn/win32.h index ff3145a..07a58d8 100644 --- a/src/openvpn/win32.h +++ b/src/openvpn/win32.h @@ -301,12 +301,14 @@ */ const char *win32_version_string(struct gc_arena *gc); -/* - * Send the |size| bytes in buffer |data| to the interactive service |pipe| - * and read the result in |ack|. Returns false on communication error. - * The string in |context| is used to prefix error messages. +/** + * Send the \p size bytes in buffer \p data to the interactive service \p pipe + * and read the result in \p ack. + * The string in \p context is used to prefix error messages. + * + * @return true on success, false on communication error */ -bool send_msg_iservice(HANDLE pipe, const void *data, size_t size, ack_message_t *ack, +bool send_msg_iservice(HANDLE pipe, const void *data, DWORD size, ack_message_t *ack, const char *context); /* @@ -350,7 +352,7 @@ * - len number of bytes to encrypt -- must be a multiple of * CRYPTPROTECTMEMORY_BLOCK_SIZE = 16 */ -bool protect_buffer_win32(char *buf, size_t len); +bool protect_buffer_win32(char *buf, DWORD len); /** * Decrypt a previously encrypted region of memory using CryptUnProtectMemory() @@ -360,7 +362,7 @@ * - len number of bytes to encrypt -- must be a multiple of * CRYPTPROTECTMEMORY_BLOCK_SIZE = 16 */ -bool unprotect_buffer_win32(char *buf, size_t len); +bool unprotect_buffer_win32(char *buf, DWORD len); #endif /* ifndef OPENVPN_WIN32_H */ #endif /* ifdef _WIN32 */ diff --git a/tests/unit_tests/openvpn/test_user_pass.c b/tests/unit_tests/openvpn/test_user_pass.c index f5dddd6..abe223c 100644 --- a/tests/unit_tests/openvpn/test_user_pass.c +++ b/tests/unit_tests/openvpn/test_user_pass.c @@ -79,17 +79,19 @@ return 0; } +#ifdef _WIN32 bool -protect_buffer_win32(char *buf, size_t len) +protect_buffer_win32(char *buf, DWORD len) { return true; } bool -unprotect_buffer_win32(char *buf, size_t len) +unprotect_buffer_win32(char *buf, DWORD len) { return true; } +#endif /* tooling */ static void