From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 05D3B1FF390 for ; Fri, 24 May 2024 10:20:08 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D20E955A0; Fri, 24 May 2024 10:20:27 +0200 (CEST) Message-ID: <8ed01519-808b-4fb2-971e-a587f3719dc2@proxmox.com> Date: Fri, 24 May 2024 10:19:55 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Beta To: Thomas Lamprecht , Proxmox Backup Server development discussion References: <20240523100800.3969965-1-d.csapak@proxmox.com> <0917bf6a-8207-44ec-b5c2-718e20c23fd2@proxmox.com> Content-Language: en-US From: Dominik Csapak In-Reply-To: <0917bf6a-8207-44ec-b5c2-718e20c23fd2@proxmox.com> X-SPAM-LEVEL: Spam detection results: 0 AWL 0.016 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 proxmox-backup] tape: mam: actually enforcing the length when writing attributes 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: , Reply-To: Proxmox Backup Server development discussion Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" On 5/24/24 09:50, Thomas Lamprecht wrote: > Am 23/05/2024 um 12:08 schrieb Dominik Csapak: >> we have to check against the length of the attribute, not the u16 >> maximum value. >> >> Signed-off-by: Dominik Csapak >> --- >> pbs-tape/src/sg_tape/mam.rs | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/pbs-tape/src/sg_tape/mam.rs b/pbs-tape/src/sg_tape/mam.rs >> index 4e995d0b..dc5163a5 100644 >> --- a/pbs-tape/src/sg_tape/mam.rs >> +++ b/pbs-tape/src/sg_tape/mam.rs >> @@ -169,7 +169,7 @@ pub fn write_mam_attribute( >> attr_data.extend(data); >> if !data.is_empty() && data.len() < attribute.len as usize { >> attr_data.resize(attr_data.len() - data.len() + attribute.len as usize, 0); >> - } else if data.len() > u16::MAX as usize { >> + } else if data.len() > attribute.len as usize { >> bail!("data to long"); > > Can we extend this error with the attribute name, the length we got and > the defined max length to have some more info for when a user runs into > this? > > Something like: > > bail!("attribute '{}' length {} is over the maximum allowed length {}", ...); > > Or is this error already extended/concatenated with similar info somewhere > in the return chain (sorry, just doing a quick review directly in my MUA) it's logged with: could not set MAM attribute {id}: {err} and from the id we can infer the maximum length but printing the expected/actual len probably make sense _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel