From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id D3276912F4 for ; Wed, 3 Apr 2024 14:18:04 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id ADCE21764B for ; Wed, 3 Apr 2024 14:18:04 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Wed, 3 Apr 2024 14:18:03 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 7D15344D74 for ; Wed, 3 Apr 2024 14:18:03 +0200 (CEST) Message-ID: Date: Wed, 3 Apr 2024 14:18:02 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: Proxmox Backup Server development discussion , =?UTF-8?Q?Fabian_Gr=C3=BCnbichler?= References: <20240328123707.336951-1-c.ebner@proxmox.com> <20240328123707.336951-8-c.ebner@proxmox.com> <1712138653.sp8y5k19rp.astroid@yuna.none> Content-Language: en-US, de-DE From: Christian Ebner In-Reply-To: <1712138653.sp8y5k19rp.astroid@yuna.none> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.029 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: Re: [pbs-devel] [PATCH v3 pxar 07/58] decoder/accessor: add optional payload input stream X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Apr 2024 12:18:04 -0000 On 4/3/24 12:38, Fabian Grünbichler wrote: >> + >> + if let Some(payload_input) = self.payload_input.as_mut() { > > this condition (cted below) > >> + if seq_read_position(payload_input) >> + .await >> + .transpose()? >> + .is_none() >> + { >> + // Skip payload padding for injected chunks in sequential decoder >> + let to_skip = payload_ref.offset - self.payload_consumed; > > should we add a check here for the invariant that offsets should only > ever be increasing? (and avoid an underflow for corrupt/invalid archives > ;)) This is called by both, seq and random access decoder instances, so that will not be possible I guess. > >> + self.skip_payload(to_skip).await?; >> + } >> + } >> + >> + if let Some(payload_input) = self.payload_input.as_mut() { > > and this condition here are the same? While this seems just duplicate, it makes the borrow checker happy as otherwise it complains that the &mut self borrow of the skip_payload call and the following seq_read_entry call taking the payload_input are in conflict. I am happy for any hint on how to make the borrow checker happy without having to perform the if check two time > >> + let header: u64 = seq_read_entry(payload_input).await?; > > why not read a Header here? Yeah, definitely better to read the full header, and then check against the htype and content_size(). Will change this for the next version. > > > then these could use the size helpers of Header ;)