[parted-devel] [PATCH] libparted: Check devpath before passing to strlen

Brian C. Lane bcl at redhat.com
Tue Aug 24 16:50:09 BST 2021


On Mon, Aug 23, 2021 at 12:52:45PM -0400, Phillip Susi wrote:
> 
> "Brian C. Lane" <bcl at redhat.com> writes:
> 
> > ---
> >  libparted/arch/linux.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
> > index aacc94f..16d95d9 100644
> > --- a/libparted/arch/linux.c
> > +++ b/libparted/arch/linux.c
> > @@ -2453,6 +2453,9 @@ _device_get_part_path (PedDevice const *dev, int num)
> >  #else
> >          devpath = dev->path;
> >  #endif
> > +        if (!devpath)
> > +            return NULL;
> > +
> >          path_len = strlen (devpath);
> >          /* Check for devfs-style /disc => /partN transformation
> >             unconditionally; the system might be using udev with devfs rules,
> 
> Probably a good idea, but is it actually possible to have a device with
> no path?
> 

Probably not, but this helps reduce noise from some of the static tests
we run, and should be safe.

Brian

-- 
Brian C. Lane (PST8PDT) - weldr.io - lorax - parted - pykickstart




More information about the parted-devel mailing list