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 3B9E78D1F for ; Wed, 23 Aug 2023 10:31:31 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 24F3913BF5 for ; Wed, 23 Aug 2023 10:31:31 +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:31:30 +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 47DCF437B2 for ; Wed, 23 Aug 2023 10:31:30 +0200 (CEST) Date: Wed, 23 Aug 2023 10:31:29 +0200 From: Wolfgang Bumiller To: Christoph Heiss 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: <20230809134426.1009504-6-c.heiss@proxmox.com> X-SPAM-LEVEL: Spam detection results: 0 AWL 0.101 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: [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:31:31 -0000 On Wed, Aug 09, 2023 at 03:44:24PM +0200, Christoph Heiss wrote: > `$size` and `$logical_bsize` might get unset if there invalid, but then > are unconditionally converted to an int - which throws an error. > This was reported on the forum by a user [0]. > > Fix it by changing the check a bit to skip the disk immediately if > detecting either of those two values are invalid or simply not present. > The fix for `$logical_bsize` simply avoids trying to convert to value to > an int if invalid. > > tl;dr: Should have no impact at all, in the end. The same > `run-env-info.json` is generated w/ and w/o the patch if all disks are > fine. I then also hacked up the script a bit to actually have an invalid > size, this resulted in the "affected" disk simply missing from the disk > array - the expected behavior in this case. > > [0] https://forum.proxmox.com/threads/error-installing-proxmox-8.131921/ > > Signed-off-by: Christoph Heiss > --- > Proxmox/Sys/Block.pm | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) > > 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 (which btw. is easily reproducible by simply plugging in a card reader without a card inserted ;-) )