Jim Meyering <jim@xxxxxxxxxxxx> wrote on 03/29/2010 01:22:56 PM:
> [image removed]
>
> Re: [libvirt] [PATCH] nwfilter_ebiptables_driver.c: avoid NULL dereference
>
> Jim Meyering
>
> to:
>
> Eric Blake
>
> 03/29/2010 01:23 PM
>
> Cc:
>
> Stefan Berger, Libvirt
>
> Eric Blake wrote:
> > On 03/29/2010 10:37 AM, Jim Meyering wrote:
> >> Another one caught by clang:
> >>
> >> Note the first test to see if "inst" may be NULL.
> >> Then, in the following loop, "inst" is unconditionally
> >> dereferenced via "inst[i]". There are other unprotected
> >> used of "inst[i]" below, too.
> >>
> >> Rather than trying to protect all uses, one by one, I chose
> >> to return "success" when given an empty list of rules.
> >
> > ACK that your patch is the minimal fix to avoid a segfault, but we
> > should probably get Stefan's input on whether returning success on an
> > empty input is the best course of behavior.
>
> Ok. I've Cc'd him.
Actually the inst[n] accesses are protected by nInstances having to be > 0 for code to try to read a inst[n]. So it should be fine the way it is. nInstances and inst belong together and nInstances indicates the number of members in that array. No member of inst[] is expected to be NULL.
Stefan
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list