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

Daniel P. Berrange berrange at redhat.com
Mon Feb 20 09:59:02 UTC 2012


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 :|




More information about the libvir-list mailing list