From: Aneesh Kumar K.V Date: Mon, 20 May 2013 06:05:00 +0000 (+0530) Subject: hw/9pfs: Fix segfault with 9p2000.u X-Git-Tag: v1.4.2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=745f6c0ef7f2fcd025e395538f1e2e3c9893de41;p=thirdparty%2Fqemu.git 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. Signed-off-by: Aneesh Kumar K.V Reviewed-by: Stefan Hajnoczi Reported-by: Michael Tokarev Acked-by: Michael Tokarev Signed-off-by: Michael Roth --- diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c index d3ea820eae4..52d9b8cc89e 100644 --- a/hw/9pfs/virtio-9p.c +++ b/hw/9pfs/virtio-9p.c @@ -659,7 +659,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;