Re: [libvirt] [PATCH] virsh: avoid double-free

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

 



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

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel@xxxxxxxxxxxx  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

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