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

Re: [libvirt] [PATCH 1/7] nwfilter: fix NULL pointer check in virNWFilterSnoopReqNew



> On 2012年11月28日 21:34, Ján Tomko wrote:
> > This can't lead to a crash since virNWFilterSnoopReqNew is only
> > called
> > with a static array as the argument, but if we check for NULL we
> > should
> > do it right.

> >
> > -    if (ifkey == NULL || strlen(ifkey) != VIR_IFKEY_LEN - 1) {
> > +    if (ifkey == NULL || (ifkey&&  strlen(ifkey) != VIR_IFKEY_LEN
> > - 1)) {
> 
> Good catch, but personally I'd like use brackets for "strlen"
> expression
> too.

This hunk is pointless.  You cannot get to the right side of || unless
ifkey is non-NULL on the left side.  We should revert this hunk.

> 
> >           virReportError(VIR_ERR_INTERNAL_ERROR,
> >                          _("virNWFilterSnoopReqNew called with
> >                          invalid "
> >                            "key \"%s\" (%zu)"),
> >                          ifkey ? ifkey : "",
> > -                       strlen(ifkey));
> > +                       ifkey ? strlen(ifkey) : 0);

This is the real fix, and should be kept.


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