[PATCH] remote: Initialize args variable

Daniel P. Berrangé berrange at redhat.com
Thu Jan 26 15:27:37 UTC 2023


On Thu, Jan 26, 2023 at 04:09:24PM +0100, Michal Prívozník wrote:
> On 1/26/23 15:48, Daniel P. Berrangé wrote:
> > On Thu, Jan 26, 2023 at 01:41:24PM +0100, Michal Privoznik wrote:
> >> Recently, in v9.0.0-7-gb2034bb04c we've dropped initialization of
> >> @args variable. The reasoning was that eventually, all members of
> >> the variable will be set. Well, this is not correct. For
> >> instance, in remoteConnectGetAllDomainStats() the
> >> args.doms.doms_val pointer is set iff @ndoms != 0. However,
> >> regardless of that, the pointer is then passed to VIR_FREE().
> >>
> >> Worse, the whole args is passed to
> >> xdr_remote_connect_get_all_domain_stats_args() which then calls
> >> xdr_array, which tests the (uninitialized) pointer against NULL.
> > 
> > Urgh, thanks for discovery this mistake.
> > 
> > I wonder if we should just go full paranoia and unconditionally
> > initialize *every* '_args' variable, even in cases where we
> > know it is redundant.
> 
> That's what I did in this patch. What we might do next is to have a
> syntax-check rule that would check whether _args and _ret are
> initialized to {0}.

Oh, the patch didn't look big enough at first glance, to cover
everything, but I guess it is.  NB, there is still the auto-generated
code that you've not changed though. 


With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|


More information about the libvir-list mailing list