On Mon, Dec 14, 2009 at 04:04:29PM +0100, Daniel Veillard wrote: > On Mon, Dec 14, 2009 at 02:35:25PM +0100, Jim Meyering wrote: > > I didn't try to trigger the double free, but it looks feasible. > > > > >From 864cc161ffaf6c08cb980e66a673b53ac5ea52ab Mon Sep 17 00:00:00 2001 > > From: Jim Meyering <meyering@xxxxxxxxxx> > > Date: Mon, 14 Dec 2009 14:34:29 +0100 > > Subject: [PATCH] virsh: avoid double-free > > > > * tools/virsh.c (vshCommandParse): Avoid double-free of "tkdata". > > Set it to NULL immediately after free in the (cmd == NULL) case, > > just as in the other case, in case the final free(tkdata) is > > triggered by a syntax error. > > --- > > tools/virsh.c | 1 + > > 1 files changed, 1 insertions(+), 0 deletions(-) > > > > diff --git a/tools/virsh.c b/tools/virsh.c > > index 62c1270..0312945 100644 > > --- a/tools/virsh.c > > +++ b/tools/virsh.c > > @@ -8044,6 +8044,7 @@ vshCommandParse(vshControl *ctl, char *cmdstr) > > goto syntaxError; /* ... or ignore this command only? */ > > } > > free(tkdata); > > + tkdata = NULL; > > } else if (tk == VSH_TK_OPTION) { > > if (!(opt = vshCmddefGetOption(cmd, tkdata))) { > > vshError(ctl, > > ACK, that's the kind of things VIR_FREE() solved, but unfortunately > it's not available for virsh.c ... ACK, we could actually use VIR_FREE/etc in virsh these days. Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| -- Libvir-list mailing list Libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list