Hi Stefan,

On Tue, Apr 16, 2013 at 10:11:50AM +0200, Stefan Hajnoczi wrote:
> On Thu, Apr 11, 2013 at 11:11:58PM +0800, Amos Kong wrote:
> > +static MacTableInfo *virtio_net_query_mactable(NetClientState *nc)
> > +{

....
> > +    for (i = 0; i < n->mac_table.first_multi; i++) {
> > +        info->has_unicast = true;
> > +        entry = g_malloc0(sizeof(*entry));
> > +        sprintf(str,
> > +                "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x",
> > +                n->mac_table.macs[i * ETH_ALEN],
> > +                n->mac_table.macs[i * ETH_ALEN + 1],
> > +                n->mac_table.macs[i * ETH_ALEN + 2],
> > +                n->mac_table.macs[i * ETH_ALEN + 3],
> > +                n->mac_table.macs[i * ETH_ALEN + 4],
> > +                n->mac_table.macs[i * ETH_ALEN + 5]);
> 
> Buffer overflow, char str[12], but luckily...
> 
> > +        entry->value = g_malloc0(sizeof(String *));
> > +        entry->value->str = g_strdup(str);
> 
> ...these lines can be replaced with g_strdup_printf():
> https://developer.gnome.org/glib/2.28/glib-String-Utility-Functions.html#g-strdup-printf

Fixed, thanks.
 
> > diff --git a/net/net.c b/net/net.c
> > index 7869161..2103e7f 100644
> > --- a/net/net.c
> > +++ b/net/net.c
> > @@ -964,6 +964,29 @@ void print_net_client(Monitor *mon, NetClientState *nc)
> >                     nc->info_str);

....

> Please add an optional net client name argument so the user can query
> just a single NIC.  This saves users from having to parse out a specific
> NIC when they just want to query one.

The reason why I didn't add argument is:
  All current info/query commands don't have arguments, Is there a
  special reason?
  (info network, info qtree, etc) output info of all devices.

But we have interface to support this (.args_type), I will add the
useful argument for info/query mac-table.

-- 
                        Amos.

Reply via email to