<br><tt><font size=2>Jim Meyering <jim@meyering.net> wrote on 03/29/2010
01:22:56 PM:<br>
<br>
> [image removed] </font></tt>
<br><tt><font size=2>> <br>
> Re: [libvirt] [PATCH] nwfilter_ebiptables_driver.c: avoid NULL dereference</font></tt>
<br><tt><font size=2>> <br>
> Jim Meyering </font></tt>
<br><tt><font size=2>> <br>
> to:</font></tt>
<br><tt><font size=2>> <br>
> Eric Blake</font></tt>
<br><tt><font size=2>> <br>
> 03/29/2010 01:23 PM</font></tt>
<br><tt><font size=2>> <br>
> Cc:</font></tt>
<br><tt><font size=2>> <br>
> Stefan Berger, Libvirt</font></tt>
<br><tt><font size=2>> <br>
> Eric Blake wrote:<br>
> > On 03/29/2010 10:37 AM, Jim Meyering wrote:<br>
> >> Another one caught by clang:<br>
> >><br>
> >> Note the first test to see if "inst" may be NULL.<br>
> >> Then, in the following loop, "inst" is unconditionally<br>
> >> dereferenced via "inst[i]".  There are other
unprotected<br>
> >> used of "inst[i]" below, too.<br>
> >><br>
> >> Rather than trying to protect all uses, one by one, I chose<br>
> >> to return "success" when given an empty list of
rules.<br>
> ><br>
> > ACK that your patch is the minimal fix to avoid a segfault, but
we<br>
> > should probably get Stefan's input on whether returning success
on an<br>
> > empty input is the best course of behavior.<br>
> <br>
> Ok.  I've Cc'd him.</font></tt>
<br>
<br><tt><font size=2>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.</font></tt>
<br>
<br><tt><font size=2>   Stefan<br>
</font></tt>