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

Re: [libvirt] [libvirt-glib] API to get node information about the connection



On Sun, Feb 19, 2012 at 07:49:18PM +0200, Zeeshan Ali (Khattak) wrote:
> +GVirNodeInfo *gvir_connection_get_node_info(GVirConnection *conn,
> +                                            GError **err)
> +{
> +    GVirConnectionPrivate *priv = conn->priv;
> +    virNodeInfo info;
> +    GVirNodeInfo *ret;
> +
> +    if (virNodeGetInfo(priv->conn, &info) < 0) {
> +        gvir_set_error_literal(err, GVIR_CONNECTION_ERROR,
> +                               0,
> +                               "Unable to get node info");
> +        return NULL;
> +    }
> +
> +    ret = g_slice_new(GVirNodeInfo);
> +    g_utf8_strncpy (ret->model, info.model, sizeof (ret->model));

Danger Will Robinson !

sizeof(ret->model) is measured in bytes, but g_ut8_strncpy's
third parameter is measured in characters. Use a plain strncpy
here.

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|


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