]> git.proxmox.com Git - qemu.git/commitdiff
hw/9pfs: Fix segfault with 9p2000.u
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Mon, 20 May 2013 05:59:52 +0000 (11:29 +0530)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Tue, 11 Jun 2013 21:39:23 +0000 (16:39 -0500)
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 <mjt@tls.msk.ru>
Acked-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
(cherry picked from commit c7e587b73ebac05943df78f5f37d80d32ff47d3d)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
hw/9pfs/virtio-9p.c

index 296f66f293c394cdc69868d9117cbff3612b66ea..8cbb8ae32a033c049646857ed4212eb1b34569af 100644 (file)
@@ -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;