qemu/contrib
Stefano Garzarella 99d7c1b99a contrib/vhost-user-blk: fix overflowing expression
Coverity reported:

  >>>     CID 1549454:  Integer handling issues  (OVERFLOW_BEFORE_WIDEN)
  >>>     Potentially overflowing expression
          "le32_to_cpu(desc->num_sectors) << 9" with type "uint32_t"
          (32 bits, unsigned) is evaluated using 32-bit arithmetic, and
          then used in a context that expects an expression of type
          "uint64_t" (64 bits, unsigned).
  199                               le32_to_cpu(desc->num_sectors) << 9 };

Coverity noticed this issue after commit ab04420c3 ("contrib/vhost-user-*:
use QEMU bswap helper functions"), but it was pre-existing and introduced
from the beginning by commit caa1ee4313 ("vhost-user-blk: add
discard/write zeroes features support").

Explicitly cast the 32-bit value before the shift to fix this issue.

Fixes: Coverity CID 1549454
Fixes: 5ab04420c3 ("contrib/vhost-user-*: use QEMU bswap helper functions")
Fixes: caa1ee4313 ("vhost-user-blk: add discard/write zeroes features support")
Cc: changpeng.liu@intel.com
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Message-Id: <20240712153857.207440-1-sgarzare@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2024-07-21 14:45:56 -04:00
..
elf2dmp contrib/elf2dmp: Ensure phdrs fit in file 2024-03-11 17:06:27 +00:00
gitdm contrib/gitdm: add Daynix to domain-map 2023-11-08 15:15:23 +00:00
ivshmem-client configure, meson: rename targetos to host_os 2023-12-31 09:11:29 +01:00
ivshmem-server configure, meson: rename targetos to host_os 2023-12-31 09:11:29 +01:00
plugins plugins/lockstep: clean-up output 2024-07-05 12:34:48 +01:00
systemd contrib: add systemd unit files 2017-12-20 22:29:26 +01:00
vhost-user-blk contrib/vhost-user-blk: fix overflowing expression 2024-07-21 14:45:56 -04:00
vhost-user-gpu virtio-gpu: Correct virgl_renderer_resource_get_info() error check 2024-02-14 06:09:33 -05:00
vhost-user-input contrib/vhost-user-*: use QEMU bswap helper functions 2024-07-02 09:27:56 -04:00
vhost-user-scsi configure, meson: rename targetos to host_os 2023-12-31 09:11:29 +01:00