From: Aneesh Kumar K.V Date: Mon, 20 May 2013 05:59:52 +0000 (+0530) Subject: hw/9pfs: Fix segfault with 9p2000.u X-Git-Tag: v1.5.1~55 X-Git-Url: https://git.proxmox.com/?p=qemu.git;a=commitdiff_plain;h=eabdf85d86fc90166aa9a866a46ffaf310bf2155 hw/9pfs: Fix segfault with 9p2000.u When guest tries to chmod a block or char device file over 9pfs, the qemu process segfaults. With 9p2000.u protocol we use wstat to change mode bits and client don't send extension information for chmod. We need to check for size field to check whether extension info is present or not. Reported-by: Michael Tokarev Acked-by: Michael Tokarev Reviewed-by: Stefan Hajnoczi Signed-off-by: Aneesh Kumar K.V (cherry picked from commit c7e587b73ebac05943df78f5f37d80d32ff47d3d) Signed-off-by: Michael Roth --- diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c index 296f66f29..8cbb8ae32 100644 --- a/hw/9pfs/virtio-9p.c +++ b/hw/9pfs/virtio-9p.c @@ -658,7 +658,7 @@ static mode_t v9mode_to_mode(uint32_t mode, V9fsString *extension) ret |= S_IFIFO; } if (mode & P9_STAT_MODE_DEVICE) { - if (extension && extension->data[0] == 'c') { + if (extension->size && extension->data[0] == 'c') { ret |= S_IFCHR; } else { ret |= S_IFBLK;