]> git.proxmox.com Git - mirror_qemu.git/commitdiff
9pfs: Fix divide by zero bug
authorDan Schatzberg <dschatzberg@fb.com>
Fri, 22 Nov 2019 20:00:34 +0000 (12:00 -0800)
committerGreg Kurz <groug@kaod.org>
Sat, 23 Nov 2019 14:51:48 +0000 (15:51 +0100)
Some filesystems may return 0s in statfs (trivially, a FUSE filesystem
can do so). QEMU should handle this gracefully and just behave the
same as if statfs failed.

Signed-off-by: Dan Schatzberg <dschatzberg@fb.com>
Acked-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Signed-off-by: Greg Kurz <groug@kaod.org>
hw/9pfs/9p.c

index 37abcdb71ec0aeda42888ac9d1c711a776e9c7ef..520177f40c1774be3d30cbdb2972964cdf9b7d51 100644 (file)
@@ -1834,8 +1834,10 @@ static int32_t coroutine_fn get_iounit(V9fsPDU *pdu, V9fsPath *path)
      * and as well as less than (client msize - P9_IOHDRSZ))
      */
     if (!v9fs_co_statfs(pdu, path, &stbuf)) {
-        iounit = stbuf.f_bsize;
-        iounit *= (s->msize - P9_IOHDRSZ)/stbuf.f_bsize;
+        if (stbuf.f_bsize) {
+            iounit = stbuf.f_bsize;
+            iounit *= (s->msize - P9_IOHDRSZ) / stbuf.f_bsize;
+        }
     }
     if (!iounit) {
         iounit = s->msize - P9_IOHDRSZ;