diff mbox

[PULL,01/16] block: Fix nb_sectors check in bdrv_check_byte_request()

Message ID 1398247491-13985-2-git-send-email-kwolf@redhat.com
State New
Headers show

Commit Message

Kevin Wolf April 23, 2014, 10:04 a.m. UTC
nb_sectors is signed, check for negative values.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
 block.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox

Patch

diff --git a/block.c b/block.c
index 990a754..3b7951e 100644
--- a/block.c
+++ b/block.c
@@ -2601,7 +2601,7 @@  static int bdrv_check_byte_request(BlockDriverState *bs, int64_t offset,
 static int bdrv_check_request(BlockDriverState *bs, int64_t sector_num,
                               int nb_sectors)
 {
-    if (nb_sectors > INT_MAX / BDRV_SECTOR_SIZE) {
+    if (nb_sectors < 0 || nb_sectors > INT_MAX / BDRV_SECTOR_SIZE) {
         return -EIO;
     }