[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 03/20] 9p: xattr: Fix crash due to free of uninit
From: |
Keno Fischer |
Subject: |
[Qemu-devel] [PATCH v2 03/20] 9p: xattr: Fix crash due to free of uninitialized value |
Date: |
Thu, 31 May 2018 21:25:58 -0400 |
If the size returned from llistxattr 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 a pointer that is safe to pass to g_free,
likely NULL.
Signed-off-by: Keno Fischer <address@hidden>
---
Changes since v1: New patch
hw/9pfs/9p.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
index d74302d..b80db65 100644
--- a/hw/9pfs/9p.c
+++ b/hw/9pfs/9p.c
@@ -3256,8 +3256,8 @@ static void coroutine_fn v9fs_xattrwalk(void *opaque)
xattr_fidp->fs.xattr.len = size;
xattr_fidp->fid_type = P9_FID_XATTR;
xattr_fidp->fs.xattr.xattrwalk_fid = true;
+ xattr_fidp->fs.xattr.value = g_malloc0(size);
if (size) {
- xattr_fidp->fs.xattr.value = g_malloc0(size);
err = v9fs_co_llistxattr(pdu, &xattr_fidp->path,
xattr_fidp->fs.xattr.value,
xattr_fidp->fs.xattr.len);
--
2.8.1
- [Qemu-devel] [PATCH v2 00/20] 9p: Add support for Darwin, Keno Fischer, 2018/05/31
- [Qemu-devel] [PATCH v2 01/20] cutils: Provide strchrnul, Keno Fischer, 2018/05/31
- [Qemu-devel] [PATCH v2 02/20] 9p: proxy: Fix size passed to `connect`, Keno Fischer, 2018/05/31
- [Qemu-devel] [PATCH v2 06/20] 9p: Avoid warning if FS_IOC_GETVERSION is not defined, Keno Fischer, 2018/05/31
- [Qemu-devel] [PATCH v2 03/20] 9p: xattr: Fix crash due to free of uninitialized value,
Keno Fischer <=
- [Qemu-devel] [PATCH v2 05/20] 9p: Properly set errp in fstatfs error path, Keno Fischer, 2018/05/31
- [Qemu-devel] [PATCH v2 04/20] 9p: linux: Fix a couple Linux assumptions, Keno Fischer, 2018/05/31
- [Qemu-devel] [PATCH v2 07/20] 9p: Move a couple xattr functions to 9p-util, Keno Fischer, 2018/05/31
- [Qemu-devel] [PATCH v2 11/20] 9p: darwin: Handle struct dirent differences, Keno Fischer, 2018/05/31
- [Qemu-devel] [PATCH v2 08/20] 9p: Rename 9p-util -> 9p-util-linux, Keno Fischer, 2018/05/31
- [Qemu-devel] [PATCH v2 09/20] 9p: Properly check/translate flags in unlinkat, Keno Fischer, 2018/05/31
- [Qemu-devel] [PATCH v2 10/20] 9p: darwin: Handle struct stat(fs) differences, Keno Fischer, 2018/05/31
- [Qemu-devel] [PATCH v2 12/20] 9p: darwin: Explicitly cast comparisons of mode_t with -1, Keno Fischer, 2018/05/31
- [Qemu-devel] [PATCH v2 14/20] 9p: darwin: Provide a compatibility definition for XATTR_SIZE_MAX, Keno Fischer, 2018/05/31
- [Qemu-devel] [PATCH v2 13/20] 9p: darwin: Ignore O_{NOATIME, DIRECT}, Keno Fischer, 2018/05/31