diff mbox

[1/3] block: Fix nb_sectors check in bdrv_check_byte_request()

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

Commit Message

Kevin Wolf April 16, 2014, 1:08 p.m. UTC
nb_sectors is signed, check for negative values.

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

Comments

Max Reitz April 16, 2014, 10:16 p.m. UTC | #1
On 16.04.2014 15:08, Kevin Wolf wrote:
> nb_sectors is signed, check for negative values.
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>   block.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Okay, why not.

Reviewed-by: Max Reitz <mreitz@redhat.com>
diff mbox

Patch

diff --git a/block.c b/block.c
index 75c3948..8be40bb 100644
--- a/block.c
+++ b/block.c
@@ -2609,7 +2609,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;
     }