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

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

 



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

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