summaryrefslogtreecommitdiffstats
path: root/hw/9pfs/9p.c
diff options
context:
space:
mode:
authorDan Schatzberg2019-11-22 21:00:34 +0100
committerGreg Kurz2019-11-23 15:51:48 +0100
commit68d654daee4364a0eca589a547d716084d9cb33d (patch)
tree206d0160ee0205abaaa695575cbac7ecb005c82a /hw/9pfs/9p.c
parentMerge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging (diff)
downloadqemu-68d654daee4364a0eca589a547d716084d9cb33d.tar.gz
qemu-68d654daee4364a0eca589a547d716084d9cb33d.tar.xz
qemu-68d654daee4364a0eca589a547d716084d9cb33d.zip
9pfs: Fix divide by zero bug
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>
Diffstat (limited to 'hw/9pfs/9p.c')
-rw-r--r--hw/9pfs/9p.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
index 37abcdb71e..520177f40c 100644
--- a/hw/9pfs/9p.c
+++ b/hw/9pfs/9p.c
@@ -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;