Re: [PATCH] tools: Change asprintf return code check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2022-09-13 at 16:47 +0200, Bartosz Golaszewski wrote:
> On Thu, Sep 8, 2022 at 4:03 PM Catalin Petrescu
> <catalin.petrescu@xxxxxxxxx> wrote:
> > 
> > Hi there,
> > 
> > I found a small error (IMHO) in libgpiod.
> > The issue is that asprintf may return -1 if it fails to allocate
> > memory, and if that happens, chip_open_by_number will pass a NULL
> > pointer to gpiod_chip_open.
> > 
> > I hope this helps.
> > 
> > Thanks,
> > 
> > Catalin.
> 
> Hey Catalin,
> 
> Please next time send the patch inline using git's send-email
> command.
> 
> You're right about the error code check but it should actually be ret
> < 0 as per asprintf's documentation.
> 
> Bart

Hi Bart,

I'll use git send-email next time. I was not aware of its existence.
And I still need to figure out how to pass the gmail SMTP
authentication.

You're right, when asprintf returns zero, technically, that's not an
error.
My thought was that if asprintf ever returns zero, that means that the
path is a zero-length string.
So, the next call to gpiod_chip_open(path) will likely fail. But I
guess, the right thing to do is to let gpiod_chip_open() deal with it.

Thanks,

Catalin.






[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux