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 4630191527 for ; Thu, 4 Apr 2024 10:47:17 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 20741345A9 for ; Thu, 4 Apr 2024 10:46:47 +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)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Thu, 4 Apr 2024 10:46:46 +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 D20F8451D1 for ; Thu, 4 Apr 2024 10:46:45 +0200 (CEST) Date: Thu, 04 Apr 2024 10:46:39 +0200 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Christian Ebner , Proxmox Backup Server development discussion References: <20240328123707.336951-1-c.ebner@proxmox.com> <20240328123707.336951-8-c.ebner@proxmox.com> <1712138653.sp8y5k19rp.astroid@yuna.none> In-Reply-To: MIME-Version: 1.0 User-Agent: astroid/0.16.0 (https://github.com/astroidmail/astroid) Message-Id: <1712219444.zzwibroi02.astroid@yuna.none> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL 0.059 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: Thu, 04 Apr 2024 08:47:17 -0000 On April 3, 2024 2:18 pm, Christian Ebner wrote: > On 4/3/24 12:38, Fabian Gr=C3=BCnbichler wrote: >>> + >>> + if let Some(payload_input) =3D self.payload_input.as_m= ut() { >>=20 >> this condition (cted below) >>=20 >>> + if seq_read_position(payload_input) >>> + .await >>> + .transpose()? >>> + .is_none() >>> + { >>> + // Skip payload padding for injected chunks in= sequential decoder >>> + let to_skip =3D payload_ref.offset - self.payl= oad_consumed; >>=20 >> should we add a check here for the invariant that offsets should only >> ever be increasing? (and avoid an underflow for corrupt/invalid archives >> ;)) >=20 > This is called by both, seq and random access decoder instances, so that=20 > will not be possible I guess. but.. payload_consumed only ever goes up? if the offset then jumps back to a position before the payload_consumed counter, this will underflow (to_skip is unsigned)? >>> + self.skip_payload(to_skip).await?; >>> + } >>> + } >>> + >>> + if let Some(payload_input) =3D self.payload_input.as_m= ut() { >>=20 >> and this condition here are the same? >=20 > While this seems just duplicate, it makes the borrow checker happy as=20 > otherwise it complains that the &mut self borrow of the skip_payload=20 > call and the following seq_read_entry call taking the payload_input are=20 > in conflict. > I am happy for any hint on how to make the borrow checker happy without=20 > having to perform the if check two time ah, yeah, that makes sense.. I think the only way to avoid it is to inline skip_payload here (it's the only call site anyway).