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 E6B4F8D97 for ; Wed, 23 Aug 2023 10:49:19 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id C5D6313FA7 for ; Wed, 23 Aug 2023 10:49:19 +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 ; Wed, 23 Aug 2023 10:49:19 +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 0079E437CB for ; Wed, 23 Aug 2023 10:49:19 +0200 (CEST) Date: Wed, 23 Aug 2023 10:49:18 +0200 From: Christoph Heiss To: Wolfgang Bumiller Cc: pve-devel@lists.proxmox.com Message-ID: References: <20230809134426.1009504-1-c.heiss@proxmox.com> <20230809134426.1009504-6-c.heiss@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-SPAM-LEVEL: Spam detection results: 0 AWL -0.038 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [block.pm] Subject: Re: [pve-devel] [PATCH installer 5/6] sys: block: fix possible use of `undef`-value when detecting disk sizes X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Aug 2023 08:49:19 -0000 On Wed, Aug 23, 2023 at 10:31:29AM +0200, Wolfgang Bumiller wrote: > > On Wed, Aug 09, 2023 at 03:44:24PM +0200, Christoph Heiss wrote: > > [..] > > diff --git a/Proxmox/Sys/Block.pm b/Proxmox/Sys/Block.pm > > index 26085e3..f76e0f1 100644 > > --- a/Proxmox/Sys/Block.pm > > +++ b/Proxmox/Sys/Block.pm > > @@ -90,10 +90,10 @@ my sub hd_list { > > } > > > > my $size = file_read_firstline("$bd/size"); > > + next if !$size; > > chomp $size; > > - $size = undef if !($size && $size =~ m/^\d+$/); > > + next if $size !~ m/^\d+$/; > > $size = int($size); > > - next if !$size; > > ^ not sure it makes sense to remove this, but OTOH, file_read_firstline > already chomps, so the first one already catches at least the zero-sized > device case Yeah, that was my thought here as well. It's chomped and the regex should take care of empty values / anything that is not some integer in any case. > (which btw. is easily reproducible by simply plugging in a card reader > without a card inserted ;-) ) I was wondering how such a case could even happen - makes sense tho, TIL :^)