]> git.proxmox.com Git - mirror_qemu.git/commit - hw/9pfs/9p.c
9p: xattr: Fix crashes due to free of uninitialized value
authorKeno Fischer <keno@juliacomputing.com>
Thu, 7 Jun 2018 10:17:22 +0000 (12:17 +0200)
committerGreg Kurz <groug@kaod.org>
Thu, 7 Jun 2018 10:17:22 +0000 (12:17 +0200)
commita647502c582981c395b5d16e52a22ac7aff0fb2b
tree0c523ce85c17bf164dba25bd35beef05e95a1b9f
parentec70b956fddf628ee2e42521c54362e80115a3c4
9p: xattr: Fix crashes due to free of uninitialized value

If the size returned from llistxattr/lgetxattr is 0, we skipped
the malloc call, leaving xattr.value uninitialized. However, this
value is later passed to `g_free` without any further checks,
causing an error. Fix that by always calling g_malloc unconditionally.
If `size` is 0, it will return NULL, which is safe to pass to g_free.

Signed-off-by: Keno Fischer <keno@juliacomputing.com>
Signed-off-by: Greg Kurz <groug@kaod.org>
hw/9pfs/9p.c