From patchwork Tue Nov 17 10:24:09 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 5721 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:6022:9292:b0:11a:f58a:e788 with SMTP id dc18csp2378580lab; Tue, 17 Nov 2026 02:24:26 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErFwaST67GDdupwyof2VE5qtscV8kMWqj7JGdW+KQRxql6VTXgEiP6GPtLkay+EPnT4V4Q3ShIMy2JA=@openvpn.net X-Received: by 2002:a05:7301:428f:b0:369:5583:bf4c with SMTP id 5a478bee46e88-379684ae79dmr12711168eec.28.1794911065671; Tue, 17 Nov 2026 02:24:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1794911065; cv=none; d=google.com; s=arc-20260327; b=eQUWnOoEQaa5aFuz0CokjUX4NCgafSOOo4k+YUibJljtTzyW3z5doAIy53nCK3/r5b uc96l2Jt7sZ8f3lEucK/+XEyFqZtdWiztPRrNgqNTRI9tP+eUB8kjw67PizLGDJsUgSn hlydY/6Fq/M7RYfqsCSRL4dslSnhEob5SAnZ0oPPNe4uWB0EimLwnXLbt52CKQzacDCA uSFHN9YMy5dyEd2N6s9/xbEFtGtLwFDI1mkKxoUQzVzWfoVfmPdYovWJZWK1bILqQUmr zDiZ6C+AfCfG1hpsX0bL7nNdirRP7I7afDqBJWGuVEU4/6hmyfVgLXclQx6I9IS2qic5 s9oQ== 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=9vUA7VedjLGjiAi2A9ZHxZFvVU4CzjZszwTnMk9F8RI=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=myl7YARHw4DndcIn6x6ZMa4P04uFK80JmedV8XLX3qaHX7W0tWeigE95KGUffWMYp+ 6GfDOez0yoMBk2eDNsMEwmhaHG5o7WpQfd7kp6zle5DAsML7zKqxzW+r+g36HRZhSj9h kMPQuPYr1j5PIdcEZd8DPmmxD47p38MnX4ouPCc9/r623hAY8e8P7LCN0SGyPCVjETU2 Pj+j6x6ozrk9M5D54m7kv+kQbCtDIGnv8KkgPOqVdPdm0/5JnGudv7QchKt1B3gsMhCb 95HXQXP1lp3sV8qkYLIxVhYFJLAHndtJrj+33/ZB26H1wCtWj18CDWOc9B6nLrSl29wB ncKg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=TkK1ursT; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=gS7437uS; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=LWIgp+IT; 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 5a478bee46e88-3795aa6a28esi34145408eec.52.2026.11.17.02.24.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Nov 2026 02:24:25 -0800 (PST) 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=TkK1ursT; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=gS7437uS; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=LWIgp+IT; 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-Unsubscribe-Post: List-Owner; bh=9vUA7VedjLGjiAi2A9ZHxZFvVU4CzjZszwTnMk9F8RI=; b=TkK1ursTRccCxR WUv5fJS6zcoGt2GItYv+i4MUpAY28RXmzs3tTWZC7cpw92/FFSlZWcuWlsbPXZ+Wf0NEW6xF1jNF4 T6RmLOpTeH0TfWFl6Iigz1+YUeOzWzIazt0wWlC99/aEOlBbUMsbVvvp1SBZWwZtutG2D0mdrhkWP Y4Q=; 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.100.1) (envelope-from ) id 1xTGMS-000000005J0-096z; Tue, 17 Nov 2026 10:24:24 +0000 Received: from [172.30.29.66] (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.100.1) (envelope-from ) id 1xTGMQ-000000005Iu-3v4T for openvpn-devel@lists.sourceforge.net; Tue, 17 Nov 2026 10:24:22 +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-Unsubscribe-Post:List-Subscribe:List-Post:List-Owner:List-Archive; bh=NtecEGWRvPg5DzppZO8q/KYFvO6wHKOO6S5aA9hrDQA=; b=gS7437uSI4k9GSwc0drDqJZAi+ IrQbntU4yVk/368tg/6aSXghRv/i1/3EXa34ZH9bJUEePvBF407NYBtxV3C6Ol740FL0rgoxjdhd+ 4e35u+HCKyOZhm/bIsORNk09YAmonpIhhEDpLv/9ETejmgUTIb6eBtHXMrpvSw+/Mx5Q=; 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-Unsubscribe-Post: List-Subscribe:List-Post:List-Owner:List-Archive; bh=NtecEGWRvPg5DzppZO8q/KYFvO6wHKOO6S5aA9hrDQA=; b=LWIgp+ITZB1ejpE9fv8Dn0sOHC scfUgRUFxqqapUgMzOci6R90IvQwoCSB+sBtmarKmsgb1M7I6mjXbdT2E7DPPIhzJqW2gHQVZ0Xtk 3MMbE/LaWrxCXXl1H6kcK9PFO6WJvGe2K9scXPQpdmelN2yyEXVgz4CFyVupV9KDVu8o=; Received: from [193.149.48.129] (helo=blue.greenie.muc.de) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.100.1) id 1xTGMP-000000006Fx-3p9H for openvpn-devel@lists.sourceforge.net; Tue, 17 Nov 2026 10:24:22 +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 6AHAOFQX031415 for ; Tue, 17 Nov 2026 11:24:15 +0100 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.2/8.18.1/Submit) id 6AHAOFPA031414 for openvpn-devel@lists.sourceforge.net; Tue, 17 Nov 2026 11:24:15 +0100 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Tue, 17 Nov 2026 11:24:09 +0100 Message-ID: <20261117102414.31377-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.55.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-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 That is consistent with sleep(3). Change-Id: I34dd7d46c9bc15e32f233741c525759715bb847c Signed-off-by: Frank Lichtenheld Acked-by: Razvan Cojocaru Gerrit URL: https://gerrit.openvpn.net/c/o [...] Content analysis details: (1.3 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_DNSWL_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to DNSWL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#DnsBlocklists-dnsbl-block for more information. [193.149.48.129 listed in list.dnswl.org] 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS X-Headers-End: 1xTGMP-000000006Fx-3p9H Subject: [Openvpn-devel] [PATCH v2] manage: Switch all sleep methods to unsigned 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: 1882100666057069161 X-GMAIL-MSGID: 1882100666057069161 From: Frank Lichtenheld That is consistent with sleep(3). Change-Id: I34dd7d46c9bc15e32f233741c525759715bb847c Signed-off-by: Frank Lichtenheld Acked-by: Razvan Cojocaru Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2200 --- 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/+/2200 This mail reflects revision 2 of this Change. Acked-by according to Gerrit (reflected above): Razvan Cojocaru diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c index ae30930..86c498e 100644 --- a/src/openvpn/manage.c +++ b/src/openvpn/manage.c @@ -3615,32 +3615,23 @@ } } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsign-conversion" -#endif - /* * Process the management event loop for sec seconds */ void -management_event_loop_n_seconds(struct management *man, int sec) +management_event_loop_n_seconds(struct management *man, unsigned int sec) { if (man_standalone_ok(man)) { volatile int signal_received = 0; const bool standalone_disabled_save = man->persist.standalone_disabled; - time_t expire = 0; + time_t expire = now + sec; /* This is so M_CLIENT messages will be correctly passed through msg() */ man->persist.standalone_disabled = false; /* set expire time */ update_time(); - if (sec >= 0) - { - expire = now + sec; - } /* if no client connection, wait for one */ man_wait_for_client_connection(man, &signal_received, expire, 0); @@ -3662,7 +3653,7 @@ return; } update_time(); - } while (expire && expire > now); + } while (expire > now); /* revert state */ man->persist.standalone_disabled = standalone_disabled_save; @@ -4026,7 +4017,7 @@ * Return true if the caller should not sleep for an additional time interval. */ bool -management_hold(struct management *man, int holdtime) +management_hold(struct management *man, unsigned int holdtime) { if (management_would_hold(man)) { @@ -4044,7 +4035,7 @@ if (!signal_received) { struct buffer out = alloc_buf_gc(128, &gc); - buf_printf(&out, ">HOLD:Waiting for hold release:%d", holdtime); + buf_printf(&out, ">HOLD:Waiting for hold release:%u", holdtime); man->persist.special_state_msg = BSTR(&out); msg(M_CLIENT, "%s", man->persist.special_state_msg); @@ -4244,8 +4235,9 @@ log_history_obj_init(struct log_history *h, int capacity) { CLEAR(*h); + ASSERT(capacity > 0); h->capacity = capacity; - ALLOC_ARRAY_CLEAR(h->array, struct log_entry, capacity); + ALLOC_ARRAY_CLEAR(h->array, struct log_entry, (size_t)capacity); } struct log_history * @@ -4332,34 +4324,6 @@ } void -management_sleep(const int n) -{ - if (n < 0) - { - return; - } - else if (management) - { - management_event_loop_n_seconds(management, n); - } - else - { -#ifdef _WIN32 - win32_sleep(n); -#else - if (n > 0) - { - sleep(n); - } -#endif - } -} - -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - -void management_check_bytecount_client(struct context *c, struct management *man, struct timeval *timeval) { if (man->persist.callback.flags & MCF_SERVER) @@ -4490,30 +4454,28 @@ gc_free(&gc); return false; } -#else /* ifdef ENABLE_MANAGEMENT */ +#endif /* ENABLE_MANAGEMENT */ #include "win32.h" -#if !defined(_WIN32) && (defined(__GNUC__) || defined(__clang__)) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsign-conversion" -#endif - void -management_sleep(const int n) +management_sleep(const unsigned int n) { -#ifdef _WIN32 - win32_sleep(n); -#else - if (n > 0) +#ifdef ENABLE_MANAGEMENT + if (management) { - sleep(n); + management_event_loop_n_seconds(management, n); } -#endif /* ifdef _WIN32 */ -} - -#if !defined(_WIN32) && (defined(__GNUC__) || defined(__clang__)) -#pragma GCC diagnostic pop + else #endif - -#endif /* ENABLE_MANAGEMENT */ + { +#ifdef _WIN32 + win32_sleep(n); +#else + if (n > 0) + { + sleep(n); + } +#endif + } +} diff --git a/src/openvpn/manage.h b/src/openvpn/manage.h index 82c0caa..697f830 100644 --- a/src/openvpn/manage.h +++ b/src/openvpn/manage.h @@ -387,9 +387,9 @@ bool management_would_hold(struct management *man); -bool management_hold(struct management *man, int holdtime); +bool management_hold(struct management *man, unsigned int holdtime); -void management_event_loop_n_seconds(struct management *man, int sec); +void management_event_loop_n_seconds(struct management *man, unsigned int sec); void management_up_down(const struct management *man, const char *updown, const struct env_set *es); @@ -522,6 +522,6 @@ * A sleep function that services the management layer for n seconds rather * than doing nothing. */ -void management_sleep(const int n); +void management_sleep(const unsigned int n); #endif /* ifndef MANAGE_H */ diff --git a/src/openvpn/resolve.c b/src/openvpn/resolve.c index b8d9899..544e5ea 100644 --- a/src/openvpn/resolve.c +++ b/src/openvpn/resolve.c @@ -161,13 +161,13 @@ } status = getaddrinfo(hostname, servname, &hints, res); - - if (status != 0) /* parse as numeric address failed? */ + /* parse as numeric address failed? */ + if (status != 0) { - const int fail_wait_interval = 5; /* seconds */ + const unsigned int fail_wait_interval = 5; /* seconds */ /* Add +4 to cause integer division rounding up (1 + 4) = 5, (0+4)/5=0 */ int resolve_retries = - (flags & GETADDR_TRY_ONCE) ? 1 : ((resolve_retry_seconds + 4) / fail_wait_interval); + (flags & GETADDR_TRY_ONCE) ? 1 : ((resolve_retry_seconds + 4) / (int)fail_wait_interval); const char *fmt; msglvl_t level = 0; diff --git a/src/openvpn/win32.c b/src/openvpn/win32.c index 079869f..f10c16d 100644 --- a/src/openvpn/win32.c +++ b/src/openvpn/win32.c @@ -1533,13 +1533,8 @@ } void -win32_sleep(const int n) +win32_sleep(const unsigned int n) { - if (n < 0) - { - return; - } - /* Sleep() is not interruptible. Use a WAIT_OBJECT to catch signal */ if (!HANDLE_DEFINED(win32_signal.in.read)) diff --git a/src/openvpn/win32.h b/src/openvpn/win32.h index 39ff7d8..8152e71 100644 --- a/src/openvpn/win32.h +++ b/src/openvpn/win32.h @@ -323,7 +323,7 @@ int openvpn_execve(const struct argv *a, const struct env_set *es, const unsigned int flags); /* Sleep that can be interrupted by signals and exit event */ -void win32_sleep(const int n); +void win32_sleep(const unsigned int n); /** * @brief Fetches a registry value for OpenVPN registry key. diff --git a/tests/unit_tests/openvpn/mock_management.c b/tests/unit_tests/openvpn/mock_management.c index f572dbb..aea43da 100644 --- a/tests/unit_tests/openvpn/mock_management.c +++ b/tests/unit_tests/openvpn/mock_management.c @@ -59,6 +59,6 @@ #endif void -management_sleep(const int n) +management_sleep(const unsigned int n) { }