[pve-devel] [PATCH installer 5/6] sys: block: fix possible use of `undef`-value when detecting disk sizes
Christoph Heiss
c.heiss at proxmox.com
Wed Aug 23 10:49:18 CEST 2023
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
:^)
More information about the pve-devel
mailing list