From patchwork Wed Jul 8 19:57:52 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 5103 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:1887:b0:869:83bc:8c48 with SMTP id r7csp8871471max; Wed, 8 Jul 2026 12:58:15 -0700 (PDT) X-Forwarded-Encrypted: i=2; AFNElJ8sb0dbBQf13eXpcLnUmKKIHwppue3a27yot6SVNF2kHoQ7EcjRjVeKHpftpdOF/0lf3PAuYMe1Yx0=@openvpn.net X-Received: by 2002:a05:6830:710e:b0:7e9:b537:102c with SMTP id 46e09a7af769-7ebcff9bd41mr3041080a34.25.1783540695078; Wed, 08 Jul 2026 12:58:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1783540695; cv=none; d=google.com; s=arc-20260327; b=IqgSUFopkBujfpJRpsL/oNBS4/Zn3tj4cT6pte9PvE/dRlNFWvKRO6Enr5oviVeMCQ XKLS7EHcZtt9a6v+AzNUHE39v/uwVWD9YV9FpTItYrdp5wF918tBJQ4TvZxIyNnnZqI3 1y1C1PefECK7iP+VzUvQvGJrznylP/AVSHnTXA+fTbolxOxksTwtlE2QNoI+FHpmosWa +WfrE4NYsHY4V1Wp0em+XD6TDXa3T1gQRC9K4JQ71sXo+2L1UIIyUh42ckR2YFdojo36 WcN3XDuotN6agKDnOoo1X6GDCulHBx+Wih7rOWh2oHW0PV6u6iWfT6cQ79POvFW73+2i 8EoA== 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=2A9LsIRz+nUZVmrxLSZLUIg3byQ881T9mOSDk1q3sIo=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=Cb1sbtR4fo+Q2KCFYn1Yd3qVIwHkEompRjmgKBRU9rixCjGrqmE6NUpbjgWyTz7sZ0 z/137c5BEFP99QIOdjx6LFxcC5HAsxbJGnQFvV2+ulF4mf4+/U+5H68e4MiM5C2xReBP HsQAxSIWNDIsHpzS2M1LeYwtypQdygR6qEe5BKN0+Bsd4YkGBYZYKs1MVnPCPBIX1xp2 PCRSkQ7ShB0c6DLdQH9XAH5qlgfWieDVVpAHN417aTA37aCJMo6pBwNvx2kkpGD5jiOu lva7kW26QXuibP2gCns5DGTBt9Mu5AqBoiHggAon1fz7JN+eQQ8kGOdMW+3NcKaLsWZm +JWQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=JgrNCBbE; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b="MbN/mUwC"; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=b3Cxj4Ew; 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-7ebcafbab81si2870058a34.54.2026.07.08.12.58.14 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Jul 2026 12:58:14 -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=JgrNCBbE; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b="MbN/mUwC"; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=b3Cxj4Ew; 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=2A9LsIRz+nUZVmrxLSZLUIg3byQ881T9mOSDk1q3sIo=; b=JgrNCBbE7H9rVpwu3iAshsOW7W m54KW9GVmuwS3l53BfL/0eLkycTTb+r1JANYXO+hUE/NyHIklM1Sar/q12jk8Jg6050iJ057p4Knt uqKo7e0UkqqCzKE5bTDtcNlK9eegjBHFsqysIA1MtFdOdwlgr4BZGmYZYX8bvdYxH0cg=; 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 1whYPI-0008HP-St; Wed, 08 Jul 2026 19:58:08 +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 1whYPH-0008HJ-Ej for openvpn-devel@lists.sourceforge.net; Wed, 08 Jul 2026 19:58:07 +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=8Po8ljTORmneu8+NqNzfs1V1eeUUxmWbHvDc9ZtjHqk=; b=MbN/mUwCzh7gMpJFb2mmDEVGK6 MdH3OmJplSJ5MhrQp1/Z9b5SAvMn3cwIMA18V5gkwyiZo0k1M5Lmr3DdVA6YMEndJLW9+800sUUjK FRgvPEE4R5eLPWbtUMCwnd9B+QrW2gnHPJcWcJtIY1O/wldC2dn+mhmp9/y3Ppom83+Q=; 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=8Po8ljTORmneu8+NqNzfs1V1eeUUxmWbHvDc9ZtjHqk=; b=b3Cxj4EwFJZ49VeovwtSLmfdQE CpMAuJ34HDEb7m4Bvm7RZgYTx65hpz6NwmRq5L+38uDJq1SJ0Ymu8ZxlSynEG52iEfihkwBqXDFVo yCwkL2g2FxN7hvGF5YB1lMr6aQix63LxTgy0OxfCUTbFaUB9kP2N2DX7qBTJWUymnV8M=; Received: from [193.149.48.129] (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 1whYPF-0000FS-WC for openvpn-devel@lists.sourceforge.net; Wed, 08 Jul 2026 19:58:07 +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 668Jvxnq018490 for ; Wed, 8 Jul 2026 21:57:59 +0200 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.2/8.18.1/Submit) id 668JvxZK018489 for openvpn-devel@lists.sourceforge.net; Wed, 8 Jul 2026 21:57:59 +0200 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Wed, 8 Jul 2026 21:57:52 +0200 Message-ID: <20260708195758.18466-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: Lev Stipakov Add 64-bit big-endian buffer accessors alongside the existing 8/16/32-bit helpers. There is no portable 64-bit byte-order primitive, so the value is handled as two big-endian 32-bit halves (most signi [...] 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: 1whYPF-0000FS-WC Subject: [Openvpn-devel] [PATCH v2] buffer: Add buf_read_u64() and buf_write_u64() 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: 1870177968279764789 X-GMAIL-MSGID: 1870177968279764789 From: Lev Stipakov Add 64-bit big-endian buffer accessors alongside the existing 8/16/32-bit helpers. There is no portable 64-bit byte-order primitive, so the value is handled as two big-endian 32-bit halves (most significant first). buf_read_u64() reports success via a bool out-parameter, mirroring buf_read_u32(): every 64-bit value is a legal result, leaving no room for an in-band sentinel. Change-Id: Ic677f43fc3eb0052f8e80d9a7f098d34ad03dfe1 Signed-off-by: Lev Stipakov Acked-by: Frank Lichtenheld Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1740 --- 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/+/1740 This mail reflects revision 2 of this Change. Acked-by according to Gerrit (reflected above): Frank Lichtenheld diff --git a/src/openvpn/buffer.h b/src/openvpn/buffer.h index fcc923b..1db9367 100644 --- a/src/openvpn/buffer.h +++ b/src/openvpn/buffer.h @@ -25,6 +25,7 @@ #include "basic.h" #include "error.h" +#include "integer.h" #define BUF_SIZE_MAX 1000000 @@ -702,6 +703,13 @@ } static inline bool +buf_write_u64(struct buffer *dest, uint64_t data) +{ + uint64_t u64 = htonll(data); + return buf_write(dest, &u64, sizeof(uint64_t)); +} + +static inline bool buf_copy(struct buffer *dest, const struct buffer *src) { return buf_write(dest, BPTR(src), BLENZ(src)); @@ -827,6 +835,30 @@ } } +/* Read a 64-bit big-endian value (see buf_write_u64()). Sets *good to indicate + * success, like buf_read_u32(). */ +static inline uint64_t +buf_read_u64(struct buffer *buf, bool *good) +{ + uint64_t ret; + if (!buf_read(buf, &ret, sizeof(uint64_t))) + { + if (good) + { + *good = false; + } + return 0; + } + else + { + if (good) + { + *good = true; + } + return ntohll(ret); + } +} + /** Return true if buffer contents are equal */ static inline bool buf_equal(const struct buffer *a, const struct buffer *b)