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

Re: [libvirt] [PATCH] Ensure nodeinfo struct is initialized to zero



On Wed, Jan 23, 2013 at 11:18:04AM -0700, Eric Blake wrote:
> On 01/23/2013 11:13 AM, Daniel P. Berrange wrote:
> > On Wed, Jan 23, 2013 at 11:12:03AM -0700, Eric Blake wrote:
> >> On 01/23/2013 11:02 AM, Richard W.M. Jones wrote:
> >>> On Wed, Jan 23, 2013 at 05:06:35PM +0000, Daniel P. Berrange wrote:
> >>>>> +    memset(nodeinfo, 0, sizeof(nodeinfo));
> >>>>> +
> >>>>
> >>>> Of course i meant   sizeof(*nodeinfo)
> >>>
> >>> Yikes.  Doesn't libvirt have some type of VIR_* macro to either catch
> >>> that error systematically or to allocate pre-cleared memory?
> >>
> >> VIR_MALLOC guarantees pre-cleared memory, but in this case, nodeinfo was
> >> passed in by the caller rather than something that we control directly.
> > 
> > Of course there are plenty of places where we stack allocate
> > stuff which we then memset(), so I believe a VIR_ZERO is worth
> > while
> 
> Agreed.  Also, in the case of virNodeGetInfo(), I wonder if we should
> just hoist the VIR_ZERO into the libvirt.c entry point, rather than
> making every driver have to worry about clearing out potentially
> uninitialized incoming data on all error paths.

Makes sense - that's what we do for virDomainGetInfo. Might be other
APIs neeeding similar change

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]