From patchwork Sat Oct 18 17:02:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 4520 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:7d42:b0:72f:f16c:e055 with SMTP id fr2csp5160443mab; Sat, 18 Oct 2025 10:02:54 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWuMEBZKnzN0MPw5gqoiCKIhNz+0RLWR4CImJPFfk18kZ4Lx7EM6BRPcAqkf0Omws/yewRXuv2T7A8=@openvpn.net X-Google-Smtp-Source: AGHT+IGH1ydegZT7Nh0nOGqXSyCYtDpQ2p2TGN4TY3m6cWZUgN0T/5JMjoNcFxFw/Xyi56ta0x/J X-Received: by 2002:a05:6808:190d:b0:442:9a9f:daa9 with SMTP id 5614622812f47-443a314f730mr3300485b6e.45.1760806973957; Sat, 18 Oct 2025 10:02:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1760806973; cv=none; d=google.com; s=arc-20240605; b=WRYkqzEnduNinz1rjjbmQFrzqKNoXkWPwYCv4dHN5kDrOrmzqEiy6dau0scPWbagtp 43+3n4DummSxguE8mxrGKo2NRwwj/eKNVDIfxsp7Jqkd+6NFxvWDoqKvJ8jvLCAK5KvF SoydF+tbYwZ2bJUqqtXbtrVS7RUAdDrip+V906CEM9JptoC8WdrHV8KPGFHU7l8zCakf V3wRkOt7qRhTYNIyYbBv01Ly4/onjqMPIhfY3cX9KSpFFo1Np+bGuX1sq+iZ6QhU2oVD 3xKy/dzg6fdH2zssdaTpwT2ZRVrPM+SlUzlrG1A4uGydCYLer3Z8ZR++Pekel3XSo4CQ z3vA== 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=zcy+hvLcKFWMeoCzPrapq27o+194P5K2h/QrWdVSVTo=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=L8ri/wuzyC3YIZ2d1xoWTUgu/R9BQ8YC5V9GP/znJMe8ARANO1GFoJMvCOllmXBymX mg7IDqw0a5rxi949D78S6ujNebO84pHi74c3/PuRMKAbSgrVCbLEsqq5vaWEh1wwvxNE GPts0sgwtYAesyHwDBhV75yJg2cbNSQcKRAppISNlLvpt7f/Yuf4bFsjf32S3x8Bfjyd fuMnrIeb1bEfcEpLUNQJgrW2fXOZCFAqoCslLPNXQMKIgTiYIFZztS1w1YBRkINpt92L uisIdCk6ocdFqSTP64XUIbHfBat+E6ZoHe5Ksu39x2PmrmqxHy4vOJjvvkdBtRS0NTLt zKNw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=b+GMESc0; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=C+HCnVKG; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="l/es8jkk"; 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 006d021491bc7-651d446f3b7si609193eaf.145.2025.10.18.10.02.53 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Oct 2025 10:02:53 -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=b+GMESc0; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=C+HCnVKG; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="l/es8jkk"; 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=zcy+hvLcKFWMeoCzPrapq27o+194P5K2h/QrWdVSVTo=; b=b+GMESc08c70gG9Z8wKCwjn9/u cdUFPo8J2Tbac+jOrRCd53UsNw6/YD0iaMpxZeVu76FxzRIKVn5Ed+6+x1NqMJDNaKHKKNW5EuToR LQ8y6/ZFvE1636gl9xS3k6yOsU+0ecsQ5yUbNv6WP2I2vruPG3Nqv4UaZF4tOZxWQtrU=; 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 1vAAKS-0003lM-03; Sat, 18 Oct 2025 17:02:52 +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 1vAAKR-0003lF-Du for openvpn-devel@lists.sourceforge.net; Sat, 18 Oct 2025 17:02:51 +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=ailzEJG5O5OZTjTYMaE1+nWq7DDC/zu3MXAuamy0I6U=; b=C+HCnVKG4KDmLCO2/j5YPqQrm0 OW3/HFT1IftzNgE7y7sk9fZ3/669aewedum3SDMrjxzdoTDA8yU9m96T8aWf4ButqLQiJR2ciQZhL OSLm3pZ+EVcghz2SFLWH9guo5L7d94THiqSo1z3suSvjEYxD6REMC2QAY+Rxlhldcy3k=; 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=ailzEJG5O5OZTjTYMaE1+nWq7DDC/zu3MXAuamy0I6U=; b=l/es8jkkZ61Phj9XEvbRqIjmj0 jQWZf0Xy2V0ZadR2jGWS/auu8NMPwi/3y7ruLF383GlSuNYhFFg9gcNXGfP0To16fo5FaXSEZCQJS i3hbhkx/zp3kO9z4Z568KTzxUzITzKLVtPzCGnRbfXKTR33UVdk+fQi+k2qmJPeyLmo0=; 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 1vAAKQ-0003gp-Ij for openvpn-devel@lists.sourceforge.net; Sat, 18 Oct 2025 17:02:51 +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 59IH2ccA021950 for ; Sat, 18 Oct 2025 19:02:38 +0200 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.1/8.18.1/Submit) id 59IH2c4U021949 for openvpn-devel@lists.sourceforge.net; Sat, 18 Oct 2025 19:02:38 +0200 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Sat, 18 Oct 2025 19:02:32 +0200 Message-ID: <20251018170237.21928-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 Mostly just use better types. Change-Id: I4113d14c6ce33818573b0ca5857a9ab39b35a8f4 Signed-off-by: Frank Lichtenheld Acked-by: mrbff Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1 [...] 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: 1vAAKQ-0003gp-Ij Subject: [Openvpn-devel] [PATCH v1] push_util: Fix conversion warnings 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?1846339933128922098?= X-GMAIL-MSGID: =?utf-8?q?1846339933128922098?= From: Frank Lichtenheld Mostly just use better types. Change-Id: I4113d14c6ce33818573b0ca5857a9ab39b35a8f4 Signed-off-by: Frank Lichtenheld Acked-by: mrbff Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1283 --- 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/+/1283 This mail reflects revision 1 of this Change. Acked-by according to Gerrit (reflected above): mrbff diff --git a/src/openvpn/push_util.c b/src/openvpn/push_util.c index 06b4c8b..8c1a503 100644 --- a/src/openvpn/push_util.c +++ b/src/openvpn/push_util.c @@ -10,18 +10,13 @@ #include "ssl_util.h" #endif -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - int process_incoming_push_update(struct context *c, unsigned int permission_mask, unsigned int *option_types_found, struct buffer *buf, bool msg_sender) { int ret = PUSH_MSG_ERROR; - const uint8_t ch = buf_read_u8(buf); + const int ch = buf_read_u8(buf); if (ch == ',') { if (apply_push_options(c, &c->options, buf, permission_mask, option_types_found, c->c2.es, @@ -57,8 +52,8 @@ * Return index of last `,` or `0` if it didn't find any. * If there is a comma at index `0` it's an error anyway */ -static int -find_first_comma_of_next_bundle(const char *str, int ix) +static size_t +find_first_comma_of_next_bundle(const char *str, size_t ix) { while (ix > 0) { @@ -75,8 +70,8 @@ static struct buffer forge_msg(const char *src, const char *continuation, struct gc_arena *gc) { - int src_len = strlen(src); - int con_len = continuation ? strlen(continuation) : 0; + size_t src_len = strlen(src); + size_t con_len = continuation ? strlen(continuation) : 0; struct buffer buf = alloc_buf_gc(src_len + sizeof(push_update_cmd) + con_len + 2, gc); buf_printf(&buf, "%s,%s%s", push_update_cmd, src, continuation ? continuation : ""); @@ -93,11 +88,11 @@ return ret; } -/* It split the messagge (if necessay) and fill msgs with the message chunks. +/* It split the messagge (if necessary) and fill msgs with the message chunks. * Return `false` on failure an `true` on success. */ static bool -message_splitter(const char *s, struct buffer *msgs, struct gc_arena *gc, const int safe_cap) +message_splitter(const char *s, struct buffer *msgs, struct gc_arena *gc, const size_t safe_cap) { if (!s || !*s) { @@ -105,7 +100,7 @@ } char *str = gc_strdup(s, gc); - int i = 0; + size_t i = 0; int im = 0; while (*str) @@ -113,7 +108,7 @@ /* + ',' - '/0' */ if (strlen(str) > safe_cap) { - int ci = find_first_comma_of_next_bundle(str, safe_cap); + size_t ci = find_first_comma_of_next_bundle(str, safe_cap); if (!ci) { /* if no commas were found go to fail, do not send any message */ @@ -219,7 +214,7 @@ * @return The number of clients to which the message was sent. Might return < 0 in case of error. */ static int -send_push_update(struct multi_context *m, const void *target, const char *msg, const push_update_type type, const int push_bundle_size) +send_push_update(struct multi_context *m, const void *target, const char *msg, const push_update_type type, const size_t push_bundle_size) { if (dco_enabled(&m->top.options)) { @@ -228,19 +223,19 @@ return 0; } - if (!msg || !*msg || !m - || (!target && type != UPT_BROADCAST)) + if (!msg || !*msg || !m || (!target && type != UPT_BROADCAST)) { return -EINVAL; } struct gc_arena gc = gc_new(); /* extra space for possible trailing ifconfig and push-continuation */ - const int extra = 84 + sizeof(push_update_cmd); + const size_t extra = 84 + sizeof(push_update_cmd); /* push_bundle_size is the maximum size of a message, so if the message * we want to send exceeds that size we have to split it into smaller messages */ - const int safe_cap = push_bundle_size - extra; - int msgs_num = (strlen(msg) / safe_cap) + ((strlen(msg) % safe_cap) != 0); + ASSERT(push_bundle_size > extra); + const size_t safe_cap = push_bundle_size - extra; + size_t msgs_num = (strlen(msg) / safe_cap) + ((strlen(msg) % safe_cap) != 0); struct buffer *msgs = gc_malloc((msgs_num + 1) * sizeof(struct buffer), true, &gc); unsigned int option_types_found = 0; @@ -354,7 +349,3 @@ RETURN_UPDATE_STATUS(n_sent); } #endif /* ifdef ENABLE_MANAGEMENT */ - -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif