[libvirt] [libvirt-glib 1/2] Use g_strlcpy instead of strncpy

Christophe Fergeau cfergeau at redhat.com
Thu Jan 24 12:33:43 UTC 2013


On Wed, Jan 23, 2013 at 03:41:56PM +0100, Martin Kletzander wrote:
> On 12/14/2012 05:03 PM, Christophe Fergeau wrote:
> > This guarantees that the string will be nul-terminated. Coverity
> > warned about this issue.
> > ---
> >  libvirt-gobject/libvirt-gobject-connection.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/libvirt-gobject/libvirt-gobject-connection.c b/libvirt-gobject/libvirt-gobject-connection.c
> > index 91cc535..0525323 100644
> > --- a/libvirt-gobject/libvirt-gobject-connection.c
> > +++ b/libvirt-gobject/libvirt-gobject-connection.c
> > @@ -1583,7 +1583,7 @@ GVirNodeInfo *gvir_connection_get_node_info(GVirConnection *conn,
> >      }
> >  
> >      ret = g_slice_new(GVirNodeInfo);
> > -    strncpy (ret->model, info.model, sizeof (ret->model));
> > +    g_strlcpy (ret->model, info.model, sizeof (ret->model));
> >      ret->memory = info.memory;
> >      ret->cpus = info.cpus;
> >      ret->mhz = info.mhz;
> > 
> 
> OK, so nobody's having a look at this, so if I have the rights...
> 
> ACK,

Thanks for the review, I've pushed this now,

Christophe 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130124/65a1c44d/attachment-0001.sig>


More information about the libvir-list mailing list