From patchwork Mon Dec 15 16:05:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 4687 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7001:1490:b0:7b1:439f:bdf with SMTP id bf16csp1919523mac; Mon, 15 Dec 2025 08:05:58 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXiL12DYSRmvqnQaRgelISGMzLBaDCSENypVneGRYTkZF0J+UPp47AGGfDQTtCQ4UD/1ywZjRlaVbw=@openvpn.net X-Google-Smtp-Source: AGHT+IG0Z/HZJFVEDNSwrzQ6EALsDIJwHEX6tmMqWcF9HJFuTmYmEWy3GvmLkrHYaS7eLMJl04k9 X-Received: by 2002:a05:6871:690e:b0:3e7:d2b3:7a3 with SMTP id 586e51a60fabf-3f5f8740112mr5211531fac.15.1765814757981; Mon, 15 Dec 2025 08:05:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1765814757; cv=none; d=google.com; s=arc-20240605; b=CnVH2dnidjhme+d2NA/emyhkMs89j73lr0hgI83lmGl9UKaBWtyjpJUWcLiU9jX2HX gywttP6C1fs0cpDWskEsmkD4zxxer5nVgtVKTiJwSYXz4tn0y35TlSv6pZEcbh5XQThv 8TGUV5Q0I30yu4++vy61y6Nyuyt+DIJC0gpUlocJw3gq9ixM6DJLOylmPCqV2rqAFc98 oJFicTMaeMD1CdEs4y/W2dpbm6paJmyy7CHRSvR8ssYBm2nIfbbTzRTvQKyuCiKUJDkI QezqoCQe5g7yGmOE1NL7oBZEw7yoToKy2hxt0Z2zyiZt3NeUO9wzxgmESSpdRr12VjxA KlIQ== 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=Dv5pHg5Ih6Jm2wP6Gq22cxmhfIJxigMucLB7EkDnZYM=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=DGmYY/457ASNeDYGwxBTy46OlLg9XPvh+9TOlkg4R/B1hPVnaYYsLiFYbQ0coxVarg 6NL/owZVPYeYnosskajLMH19pTz0jsEchLvzRjGN7wfzAkNhvwDkMrwS8NwWfw4oVQT2 NzvJ6H83WzcjhPb0zm4fvSJpBj4gxmWB2cJTcSq5tpp8M4dFhe0aZ4NSYJzLQfnrUmrV VAhh7A1ZWpSU5ApPlivmu0wmuOEzC58zkOU+VDrXxwm5gidGaC2x/CCo/xOYP+WOtbg+ J1+Y7h338zUGKguUsNMwucLxM9UjjmK23rNvZ7WEA2Cm2TImC7FeW8S/pSB6GjUurNWL /zVg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=FZCTBQM4; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=WUaFBRrh; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=mAKtzCKZ; 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 586e51a60fabf-3f614e48703si5719548fac.242.2025.12.15.08.05.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Dec 2025 08:05:57 -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=FZCTBQM4; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=WUaFBRrh; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=mAKtzCKZ; 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=Dv5pHg5Ih6Jm2wP6Gq22cxmhfIJxigMucLB7EkDnZYM=; b=FZCTBQM4fl+ir2TqklCqaZsWAI UXzC3wAptEpFncUuPn/TnCNvZ61MUTVbvBMu0hylOLyCmwOUnTGKCB+fqycdO55dwagfs1Sa7CX/i GwCcHiiWJegOTZeiyjUaiHe5PkSMjM6h0AypN9juIC+6IqPW8bnAJnWglfuh8q7Vx+d0=; Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1vVB59-00089G-QC; Mon, 15 Dec 2025 16:05:55 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1vVB58-000898-EN for openvpn-devel@lists.sourceforge.net; Mon, 15 Dec 2025 16:05:54 +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=izdh6Mwvr2ALfH+Rzag7pMtO/eYVhWDxlBekdAWuZkY=; b=WUaFBRrhgMd7rLhxqOVm8pNQVw CPBNlmdEYqXldVwKJSreB71/BdOV1iczYzwckNqAz8H7uasWjVaqZQsV4eI6SY1GBvd4guyeJxkDk Hgw2ApBiE1fz+L5n6aMaQxpWIiQCIias9tfaMgr5/10nYMp/YMMdyI5VG/KRH/X3646M=; 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=izdh6Mwvr2ALfH+Rzag7pMtO/eYVhWDxlBekdAWuZkY=; b=mAKtzCKZYaZTLzr9ODWg0nevMa R5cHEgVZzpSwwVG+6cY7N0n/KlaqDZhxcqJ/oAj/8dpQKxnwWZbYJrRam+nHsxN0uZLVLXsE0JR7g kwYto2yhTPpTL6wULJG+d9K+Ec6VoCpnkOkXVJCHa4iFw9GMCYUH0cwO6nTcRCBoAjAY=; 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 1vVB57-0006bG-0e for openvpn-devel@lists.sourceforge.net; Mon, 15 Dec 2025 16:05:54 +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 5BFG5fQY024255 for ; Mon, 15 Dec 2025 17:05:41 +0100 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.1/8.18.1/Submit) id 5BFG5f0L024254 for openvpn-devel@lists.sourceforge.net; Mon, 15 Dec 2025 17:05:41 +0100 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Mon, 15 Dec 2025 17:05:35 +0100 Message-ID: <20251215160541.24237-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.51.2 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 We already have tests to make sure the value is sane. Changing the argument to ssize_t allows to use it in more places without needing to do a cast before the checks. 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: 1vVB57-0006bG-0e Subject: [Openvpn-devel] [PATCH v1] buffer: Change buf_prepend and buf_advance to accept ssize_t for length 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?1851590975743404321?= X-GMAIL-MSGID: =?utf-8?q?1851590975743404321?= From: Frank Lichtenheld We already have tests to make sure the value is sane. Changing the argument to ssize_t allows to use it in more places without needing to do a cast before the checks. Change-Id: I123002255b37160d48ef6481f68a89d03073236b Signed-off-by: Frank Lichtenheld Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1437 --- 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/+/1437 This mail reflects revision 1 of this Change. Acked-by according to Gerrit (reflected above): Gert Doering diff --git a/src/openvpn/buffer.c b/src/openvpn/buffer.c index 293622f..aae4104 100644 --- a/src/openvpn/buffer.c +++ b/src/openvpn/buffer.c @@ -789,7 +789,7 @@ { if (buf_string_match_head_str(src, match)) { - buf_advance(src, (int)strlen(match)); + buf_advance(src, strlen(match)); return true; } else @@ -1312,7 +1312,7 @@ } void -buffer_list_advance(struct buffer_list *ol, int n) +buffer_list_advance(struct buffer_list *ol, ssize_t n) { if (ol->head) { diff --git a/src/openvpn/buffer.h b/src/openvpn/buffer.h index ab2a29d..5444dfd 100644 --- a/src/openvpn/buffer.h +++ b/src/openvpn/buffer.h @@ -601,26 +601,26 @@ */ static inline uint8_t * -buf_prepend(struct buffer *buf, int size) +buf_prepend(struct buffer *buf, ssize_t size) { if (!buf_valid(buf) || size < 0 || size > buf->offset) { return NULL; } - buf->offset -= size; - buf->len += size; + buf->offset -= (int)size; + buf->len += (int)size; return BPTR(buf); } static inline bool -buf_advance(struct buffer *buf, int size) +buf_advance(struct buffer *buf, ssize_t size) { if (!buf_valid(buf) || size < 0 || buf->len < size) { return false; } - buf->offset += size; - buf->len -= size; + buf->offset += (int)size; + buf->len -= (int)size; return true; } @@ -1175,7 +1175,7 @@ */ struct buffer *buffer_list_peek(struct buffer_list *ol); -void buffer_list_advance(struct buffer_list *ol, int n); +void buffer_list_advance(struct buffer_list *ol, ssize_t n); void buffer_list_pop(struct buffer_list *ol); diff --git a/src/openvpn/ps.c b/src/openvpn/ps.c index 31e7c25..917f871 100644 --- a/src/openvpn/ps.c +++ b/src/openvpn/ps.c @@ -596,7 +596,7 @@ { dmsg(D_PS_PROXY_DEBUG, "PORT SHARE PROXY: partial write[%d], tried=%d got=%zd", (int)sd, pc->buf.len, status); - buf_advance(&pc->buf, (int)status); + buf_advance(&pc->buf, status); return IOSTAT_EAGAIN_ON_WRITE; } else