Advertisement
Guest User

Untitled

a guest
Jul 11th, 2014
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 1.03 KB | None | 0 0
  1. diff --git a/block.c b/block.c
  2. index 80d55ff..3e252a2 100644
  3. --- a/block.c
  4. +++ b/block.c
  5. @@ -3056,13 +3056,16 @@ static int coroutine_fn bdrv_aligned_preadv(BlockDriverState *bs,
  6.                                    align >> BDRV_SECTOR_BITS);
  7.          if (max_nb_sectors > 0) {
  8.              QEMUIOVector local_qiov;
  9. +            size_t local_sectors;
  10. +
  11. +            max_nb_sectors = MIN(max_nb_sectors, SIZE_MAX / BDRV_SECTOR_BITS);
  12. +            local_sectors = MIN(max_nb_sectors, nb_sectors);
  13.  
  14.              qemu_iovec_init(&local_qiov, qiov->niov);
  15.              qemu_iovec_concat(&local_qiov, qiov, 0,
  16. -                              max_nb_sectors * BDRV_SECTOR_SIZE);
  17. +                              local_sectors * BDRV_SECTOR_SIZE);
  18.  
  19. -            ret = drv->bdrv_co_readv(bs, sector_num,
  20. -                                     MIN(nb_sectors, max_nb_sectors),
  21. +            ret = drv->bdrv_co_readv(bs, sector_num, local_sectors,
  22.                                       &local_qiov);
  23.  
  24.              qemu_iovec_destroy(&local_qiov);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement