9pfs fixes for QEMU 4.2

This fixes a potential QEMU crash if the underlying filesystem returns
 a null block size in statfs().
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEtIKLr5QxQM7yo0kQcdTV5YIvc9YFAl3ZTggACgkQcdTV5YIv
 c9YUcRAAo1eFzbVmrX3AKckYCrlOMudhEJ33V13ZmHLpP25OWCeZ1rL6Vk44fuIn
 pqaG/5eoaijWxMnh64kQKEjezo13zrQBzVuWOtJ9HqecWwE08635rpBaGCuqWahX
 Wkudy4eC6WKPdb6w62psCRXm5gWVa+YgKilVupqjuBJvPzkeBu0PpKpRKdLBJqSS
 UtcllOrJo0J0pdamABzjcNLSxf8Xz1L2TXHXRR/c6t0nznsk5Rda3EteVu/3MzJK
 zcoOK9MOfk4Szpn2+XmyAp+WN3G0zXyAuB0Gsps7FZgxyxJ7ePso+YLio0y+J3n0
 rm8q30UIMIzsmDpViP8GGBnmJ/qkovV0MK08iITnTNHvRzFnZnKdg79mWw2b5jr3
 nKg4bj6/bpQQF2rmgyFyLVQ5L0leZbq5hhLgFW+gK0p+jrAde5UR8K/ye0bcaHGa
 HxZmenb0XZtk6N6cnhOVB2FYpkxejc5bgsyzRNgisyf4DFzqDx88MPDkNlcnzALt
 0fsB2uA3pC+h/vgZkqqXiE3nTUlbNiR0T5how2txvSOc7W7+Gs2usFxyTDWMwXQd
 TLQZqJL+RGSbsMMSAQSgM57o9MF96Ihq61cnbgBowjrWkbqMxF8azrSCX/5gQ6gI
 rxTQuv/bzFied5WaeFV8+JeAh/GzKv8/12Sb1iemYkXPP6sQ2pg=
 =KiOr
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/gkurz/tags/9p-fix-2019-11-23' into staging

9pfs fixes for QEMU 4.2

This fixes a potential QEMU crash if the underlying filesystem returns
a null block size in statfs().

# gpg: Signature made Sat 23 Nov 2019 15:19:36 GMT
# gpg:                using RSA key B4828BAF943140CEF2A3491071D4D5E5822F73D6
# gpg: Good signature from "Greg Kurz <groug@kaod.org>" [full]
# gpg:                 aka "Gregory Kurz <gregory.kurz@free.fr>" [full]
# gpg:                 aka "[jpeg image of size 3330]" [full]
# Primary key fingerprint: B482 8BAF 9431 40CE F2A3  4910 71D4 D5E5 822F 73D6

* remotes/gkurz/tags/9p-fix-2019-11-23:
  9pfs: Fix divide by zero bug

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2019-11-25 13:39:45 +00:00
commit 122e6d2a9c
1 changed files with 4 additions and 2 deletions

View 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;