Re: [PATCH] convert: fail gracefully upon missing clean cmd on required filter

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

 



On Thu, 25 Feb 2021 at 19:18, Matheus Tavares <matheus.bernardino@xxxxxx> wrote:
> This assertion and the one above it are not really necessary, as the
> apply_filter() call bellow them already performs the same checks. And

s/bellow/below/

> when these conditions are not met, the function returns 0, making the
> caller die() with a much nicer message. (Also note that die()-ing here

Makes sense. I noticed one thing:

> -       assert(ca.drv);

If ca.drv is NULL ....

> -       assert(ca.drv->clean || ca.drv->process);
> -
>         if (!apply_filter(path, NULL, 0, fd, dst, ca.drv, CAP_CLEAN, NULL, NULL))

... the return value will be 0, so this will trigger ...

>                 die(_("%s: clean filter '%s' failed"), path, ca.drv->name);

... and we'll dereference NULL to grab the name.

It seems like you could leave that first assertion and your new tests
would still pass. Hitting an assertion is arguably better than wandering
off into undefined behavior. (What will probably happen is ca.drv->name
will effectively also be NULL, because it's at the top of the struct.
Some implementations will format this as "(null)", others will crash.)

As you note, and my reading agrees, you can't really have ca.drv be NULL
here. So this is like, if and when we grow a bug somewhere and actually
do have NULL, maybe we would rather hit that "assert" than go
dereferencing NULL.

Martin




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux