From patchwork Tue Aug 18 14:22:21 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 5250 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:798a:b0:87d:ab56:3700 with SMTP id o10csp4562637maz; Tue, 18 Aug 2026 07:22:44 -0700 (PDT) X-Forwarded-Encrypted: i=2; AHgh+RrV3+4rRwElEZrPvd3LhBB54ssM7yrGBZKCXy/6GKgMjKXwn6XP8mWPwP4Rf9iu40eEgHpr+EKyl38=@openvpn.net X-Received: by 2002:a05:6820:2017:b0:6ae:4be6:64ee with SMTP id 006d021491bc7-6b0d693e720mr28006838eaf.34.1787062963845; Tue, 18 Aug 2026 07:22:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1787062963; cv=none; d=google.com; s=arc-20260327; b=TKcaZ5SqyHY84kkOSfT/jTi9OfjflsecR/lUk1cgDXpjzdOauRXI7wxUWpX4p65erc VrHDkUWjlaVcMYLPfhtTAl7GtjGTd2+SwE1eNFAgmVOQ5OBBQoRVyUpIZ5SoyZ0B/kcz fvWsoLC5vx0qQf1O/2FXb+b/spbvzsW+AZ9OUx3cRLuQXK30N66tjUB9FKbaX1cgW/1k 0MadajZubPW6QObd6/g86e+91CM1Gi+kjt+bH+tYP4aaUZHZ+dAxx0lNcSeS3mDxe7Kt 7Vyv13fJKkR0zLeWN6fH8l7VNLU4e6j1Ku3BInOj89Deufn77K/7wt4MsI36fESx+NaB uZ3A== 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=R18rYg8gsyLfhE89LgwnekXpWRyx/tXjf/yONndIihw=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=IABOID7Rk4AFCU0SHZrLS9yPx2kLyyml7+4bZ9y5qYPoIjIsO2gdsH3BHbAH6ZOTev pbA1ehDDa4HSoNbPk2qHww5aqv0kis9KgizqSoY3wfpgK8zdTQKD+pci2MnzSuxH/mnp nHi2shxmWzROxz/r+ZmDUbz+5MoCB83QrVqDFLv2jd03V9XHQFeYXcR78Kk0yCJWgsmk j52h5Js1WK3fFJNQIu31yc2UBVGhaH5jooDcGcMldmPMHtcg1m7batrgPjRgMLlBIlAu 8fUIadE0bSpQ8hXfEmof3CXTIYI0k/ZaL195AwPKHxwTdpglRVQNye/4rZiC9EkZO3tW 9/6A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=iTpB5Jgi; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=bZbuTPt+; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=iIlWAzNF; 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 46e09a7af769-7f41c1420cbsi8064769a34.144.2026.08.18.07.22.43 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Aug 2026 07:22:43 -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=iTpB5Jgi; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=bZbuTPt+; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=iIlWAzNF; 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=R18rYg8gsyLfhE89LgwnekXpWRyx/tXjf/yONndIihw=; b=iTpB5JgiY3ZbSKbNercfXPgTR0 hCLbLky8q4Z1p/oxAFnKXVwQEgcru4eyhy/3oUgA5PRH0ubCmYteuX9JDhROko6Cfz8flf0OPPVQH Ox9CFZgCTfv4bHe9opWC8y6vdguKKihsJl5aw8iyqVNnkl2S3yEw8vfGXFlBnoLfRZn8=; 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 1wwKi4-0001nb-Dw; Tue, 18 Aug 2026 14:22:37 +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.95) (envelope-from ) id 1wwKi3-0001nV-OF for openvpn-devel@lists.sourceforge.net; Tue, 18 Aug 2026 14:22:36 +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=LZL0OiIqL8FN+uPPC0s5RIsxoy82evPEYmNHvzI42Go=; b=bZbuTPt+ualhlOLWhAZjmFoeSc qrEB1Jh67mh27Bdidp2YlG5JUQ8lrE7DdSgNNGHp1SVEcBqhICZpwbBgr8AqmJTj9JJ7zMWsK2Orw OQZkjXJergcIsDhRac0T/9UwrtyFnc1l5PwaTAGfmQt+ljOvzwZ4M1mRD6O/fxy7HxlU=; 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=LZL0OiIqL8FN+uPPC0s5RIsxoy82evPEYmNHvzI42Go=; b=iIlWAzNFu6VgHfBxy0rHRRthlW J6DvidtYAK8lJf3gYSk4UqkNUAP7VesQzvxVpY3cBcgKLDk/HP8aKiLl5GfrgzWEmjybuBVPgu3Iu Y2MXmGK2wH2Z/PGZr4Yi+Ny3avp7meWxpBEe0vq5Et9CNpfEKCVi3JgRqAwjAXOfsjpk=; 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.95) id 1wwKi6-0001Q5-8c for openvpn-devel@lists.sourceforge.net; Tue, 18 Aug 2026 14:22:36 +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 67IEMRHZ027191 for ; Tue, 18 Aug 2026 16:22:27 +0200 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.2/8.18.1/Submit) id 67IEMRlX027190 for openvpn-devel@lists.sourceforge.net; Tue, 18 Aug 2026 16:22:27 +0200 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Tue, 18 Aug 2026 16:22:21 +0200 Message-ID: <20260818142226.27172-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: Frank Lichtenheld Most of these already have checks that the values are as expected, so we can just add the required casts. Only the circ list x_sizeof is changed to size_t since that is its purpose (and it is not actually used anyway). 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: 1wwKi6-0001Q5-8c Subject: [Openvpn-devel] [PATCH v8] packet_id: Avoid 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: 1873871334264441265 X-GMAIL-MSGID: 1873871334264441265 From: Frank Lichtenheld Most of these already have checks that the values are as expected, so we can just add the required casts. Only the circ list x_sizeof is changed to size_t since that is its purpose (and it is not actually used anyway). Change-Id: Ib0584e8728701cca10ac5675c9cb0e6f5eb901ac Signed-off-by: Frank Lichtenheld Acked-by: Razvan Cojocaru Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1407 --- 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/+/1407 This mail reflects revision 8 of this Change. Acked-by according to Gerrit (reflected above): Razvan Cojocaru diff --git a/src/openvpn/circ_list.h b/src/openvpn/circ_list.h index c29b0bb8..76484ca 100644 --- a/src/openvpn/circ_list.h +++ b/src/openvpn/circ_list.h @@ -33,7 +33,7 @@ int x_head; \ int x_size; \ int x_cap; \ - int x_sizeof; \ + size_t x_sizeof; \ type x_list[]; \ } @@ -58,14 +58,14 @@ (obj)->x_size = 0; \ } -#define CIRC_LIST_ALLOC(dest, list_type, size) \ - { \ - const int so = sizeof(list_type) + sizeof((dest)->x_list[0]) * (size); \ - (dest) = (list_type *)malloc(so); \ - check_malloc_return(dest); \ - memset((dest), 0, so); \ - (dest)->x_cap = size; \ - (dest)->x_sizeof = so; \ +#define CIRC_LIST_ALLOC(dest, list_type, size) \ + { \ + const size_t so = sizeof(list_type) + sizeof((dest)->x_list[0]) * (size); \ + (dest) = (list_type *)malloc(so); \ + check_malloc_return(dest); \ + memset((dest), 0, so); \ + (dest)->x_cap = size; \ + (dest)->x_sizeof = so; \ } #define CIRC_LIST_FREE(dest) free(dest) diff --git a/src/openvpn/packet_id.c b/src/openvpn/packet_id.c index a4b627c..b0211d7 100644 --- a/src/openvpn/packet_id.c +++ b/src/openvpn/packet_id.c @@ -71,11 +71,6 @@ #endif } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - static void packet_id_init_recv(struct packet_id_rec *rec, int seq_backtrack, int time_backtrack, const char *name, int unit) @@ -119,7 +114,7 @@ /* Reinitalise the source */ CLEAR(*src); - packet_id_init_recv(src, dest->seq_backtrack, dest->time_backtrack, dest->name, dest->unit); + packet_id_init_recv(src, (int)dest->seq_backtrack, dest->time_backtrack, dest->name, dest->unit); } void @@ -170,7 +165,7 @@ diff = p->id - pin->id; if (diff < CIRC_LIST_SIZE(p->seq_list) && local_now > SEQ_EXPIRED) { - CIRC_LIST_ITEM(p->seq_list, diff) = local_now; + CIRC_LIST_ITEM(p->seq_list, (int)diff) = local_now; } } else @@ -263,18 +258,16 @@ return false; } + const time_t v = CIRC_LIST_ITEM(p->seq_list, (int)diff); + if (v == 0) { - const time_t v = CIRC_LIST_ITEM(p->seq_list, diff); - if (v == 0) - { - return true; - } - else - { - /* raised from D_PID_DEBUG_LOW to reduce verbosity */ - packet_id_debug(D_PID_DEBUG_MEDIUM, p, pin, "PID_ERR replay", diff); - return false; - } + return true; + } + else + { + /* raised from D_PID_DEBUG_LOW to reduce verbosity */ + packet_id_debug(D_PID_DEBUG_MEDIUM, p, pin, "PID_ERR replay", diff); + return false; } } else if (pin->time < p->time) /* if time goes back, reject */ @@ -386,7 +379,7 @@ return false; } - const packet_id_type net_id = htonpid(p->id); + const packet_id_type net_id = htonpid((packet_id_type)p->id); const net_time_t net_time = htontime(p->time); if (prepend) { @@ -640,7 +633,7 @@ p->seq_backtrack, p->time_backtrack, p->max_backtrack_stat, (int)p->initialized); if (sl != NULL) { - buf_printf(&out, " sl=[%d,%d,%d,%d]", sl->x_head, sl->x_size, sl->x_cap, sl->x_sizeof); + buf_printf(&out, " sl=[%d,%d,%d,%zu]", sl->x_head, sl->x_size, sl->x_cap, sl->x_sizeof); } @@ -655,7 +648,6 @@ { uint64_t packet_id; - if (!buf_read(buf, &packet_id, sizeof(packet_id))) { return 0; @@ -663,16 +655,12 @@ uint64_t id = ntohll(packet_id); /* top most 16 bits */ - uint16_t epoch = id >> 48; + uint16_t epoch = (uint16_t)(id >> 48); pin->id = id & PACKET_ID_MASK; return epoch; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - bool packet_id_write_epoch(struct packet_id_send *p, uint16_t epoch, struct buffer *buf) { diff --git a/src/openvpn/packet_id.h b/src/openvpn/packet_id.h index ba59067..48752d3 100644 --- a/src/openvpn/packet_id.h +++ b/src/openvpn/packet_id.h @@ -280,26 +280,20 @@ return p->fd >= 0; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - -/* transfer packet_id -> packet_id_persist */ +/* transfer packet_id -> packet_id_persist + Note: Only supported for non-epoch format (i.e. 32bit ID, not 64bit format), + must be enforced at the caller. + */ static inline void packet_id_persist_save_obj(struct packet_id_persist *p, const struct packet_id *pid) { - if (packet_id_persist_enabled(p) && pid->rec.time) + if (packet_id_persist_enabled(p) && pid->rec.time && pid->rec.id <= PACKET_ID_MAX) { p->time = pid->rec.time; - p->id = pid->rec.id; + p->id = (packet_id_type)pid->rec.id; } } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - /** * Reset the current send packet id to its initial state. * Use very carefully (e.g. in the standalone reset packet context) to