From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 216011FF0E9 for ; Wed, 12 Aug 2026 10:26:24 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id A3AA92158B; Wed, 12 Aug 2026 10:26:23 +0200 (CEST) From: Robert Obkircher To: pbs-devel@lists.proxmox.com Subject: [PATCH v2 proxmox 5/6] io: remove unused append_to_vec functions Date: Wed, 12 Aug 2026 10:23:34 +0200 Message-ID: <20260812082549.21561-6-r.obkircher@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260812082549.21561-1-r.obkircher@proxmox.com> References: <20260812082549.21561-1-r.obkircher@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1786523163514 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.733 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: 2VDMD6SEA2UATNECUQAGB2COGHH7QX74 X-Message-ID-Hash: 2VDMD6SEA2UATNECUQAGB2COGHH7QX74 X-MailFrom: r.obkircher@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Backup Server development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: These functions leaked uninitialized bytes on the error paths, which could cause undefined behavior or return sensitive data from memory. Remove them for now, as they appear to be unused. Signed-off-by: Robert Obkircher --- proxmox-io/src/read.rs | 32 +------------------------------- proxmox-io/src/vec/byte_vec.rs | 14 -------------- 2 files changed, 1 insertion(+), 45 deletions(-) diff --git a/proxmox-io/src/read.rs b/proxmox-io/src/read.rs index 0a73eea8..2cced5e0 100644 --- a/proxmox-io/src/read.rs +++ b/proxmox-io/src/read.rs @@ -5,7 +5,7 @@ use std::mem; use endian_trait::Endian; -use crate::vec::{self, ByteVecExt}; +use crate::vec; /// Adds some additional related functionality for types implementing [`Read`](std::io::Read). /// @@ -22,9 +22,6 @@ use crate::vec::{self, ByteVecExt}; /// // read some bytes into a newly allocated Vec: /// let mut data = file.read_exact_allocated(64)?; /// -/// // appending data to a vector: -/// let actually_appended = file.append_to_vec(&mut data, 64)?; // .read() version -/// file.append_exact_to_vec(&mut data, 64)?; // .read_exact() version /// # Ok(()) /// # } /// ``` @@ -71,12 +68,6 @@ pub trait ReadExt { /// ``` fn read_exact_allocated(&mut self, size: usize) -> io::Result>; - /// Append data to a vector, growing it as necessary. Returns the amount of data appended. - fn append_to_vec(&mut self, out: &mut Vec, size: usize) -> io::Result; - - /// Append an exact amount of data to a vector, growing it as necessary. - fn append_exact_to_vec(&mut self, out: &mut Vec, size: usize) -> io::Result<()>; - /// Read a value with host endianness. /// /// This is limited to types implementing the [`Endian`] trait under the assumption that @@ -244,27 +235,6 @@ impl ReadExt for R { Ok(out) } - fn append_to_vec(&mut self, out: &mut Vec, size: usize) -> io::Result { - let pos = out.len(); - unsafe { - out.grow_uninitialized(size); - } - let got = self.read(&mut out[pos..])?; - unsafe { - out.set_len(pos + got); - } - Ok(got) - } - - fn append_exact_to_vec(&mut self, out: &mut Vec, size: usize) -> io::Result<()> { - let pos = out.len(); - unsafe { - out.grow_uninitialized(size); - } - self.read_exact(&mut out[pos..])?; - Ok(()) - } - unsafe fn read_host_value(&mut self) -> io::Result { let mut value = std::mem::MaybeUninit::::uninit(); unsafe { diff --git a/proxmox-io/src/vec/byte_vec.rs b/proxmox-io/src/vec/byte_vec.rs index e8d1962b..0a45ba0a 100644 --- a/proxmox-io/src/vec/byte_vec.rs +++ b/proxmox-io/src/vec/byte_vec.rs @@ -25,13 +25,6 @@ /// # } /// ``` /// -/// Note that this module also provides a safe alternative for the case where -/// `grow_uninitialized()` is directly followed by a `read_exact()` call via the [`ReadExt`] -/// trait: -/// ```ignore -/// file.append_to_vec(&mut data, 1024)?; -/// ``` -/// /// [`ReadExt`]: crate::ReadExt pub trait ByteVecExt { /// Grow a vector without initializing its elements. The difference to simply using `reserve` @@ -57,13 +50,6 @@ pub trait ByteVecExt { /// # } /// ``` /// - /// Although for the above case it is recommended to use the even shorter version from the - /// [`ReadExt`] trait: - /// ```ignore - /// // use crate::tools::vec::ByteVecExt; - /// file.append_to_vec(&mut buffer, 1024)?; - /// ``` - /// /// # Safety /// /// When increasing the size, the new contents are uninitialized and have nothing to do with -- 2.47.3