Re: [PATCH] Ignore bridge template names with multiple printf conversions

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

 



On Thu, Apr 30, 2015 at 08:21:34AM -0600, Eric Blake wrote:
> On 04/30/2015 06:28 AM, Ján Tomko wrote:
> > For some reason, we allow a bridge name with %d in it, which we replace
> > with an unsigned integer to form a bridge name that does not yet exist
> > on the host.
> > 
> > Do not blindly pass it to virAsprintf if it's not the only conversion,
> > to prevent crashing on input like:
> > 
> > <network>
> >   <name>test</name>
> >   <forward mode='none'/>
> >   <bridge name='virbr%d%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s'/>
> > </network>
> > 
> > Ignore any template strings that do not have exactly one %d conversion,
> > like we do in various drivers before calling virNetDevTapCreateInBridgePort.
> > ---
> 
> > +    if (def->bridge &&
> > +        (p = strchr(def->bridge, '%')) == strrchr(def->bridge, '%') &&
> > +        strstr(def->bridge, "%d"))
> 
> Shorter:
> 
> if (def->bridge &&
>     strstr(def->bridge, "%d") == strrchr(def->bridge, '%'))
> 

This only checks if there are no '%' characters after the first "%d",
it would still let "br%s%d" through.

> > @@ -2809,7 +2815,7 @@ networkFindUnusedBridgeName(virNetworkObjListPtr nets,
> >  
> >  /*
> >   * networkValidateBridgeName() - if no bridge name is set, or if the
> > - * bridge name contains a %d (indicating that this is a template for
> > + * bridge name contains a % (indicating that this is a template for
> 
> No need to change this comment any more.
> 
> >   * the actual name) try to set an appropriate bridge name.  If a
> >   * bridge name *is* set, make sure it doesn't conflict with any other
> >   * network's bridge name.
> > @@ -2820,7 +2826,7 @@ networkBridgeNameValidate(virNetworkObjListPtr nets,
> >  {
> >      int ret = -1;
> >  
> > -    if (def->bridge && !strstr(def->bridge, "%d")) {
> > +    if (def->bridge && !strchr(def->bridge, '%')) {
> 
> I'm also not sure we need to change this.
> 

Right, this is only used with STREQ.

Jan

Attachment: signature.asc
Description: Digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]