Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
block-backend: blk_check_byte_request(): int64_t bytes
Rename size and make it int64_t to correspond to modern block layer,
which always uses int64_t for offset and bytes (not in blk layer yet,
which is a task for following commits).

All callers pass int or unsigned int.

So, for bytes in [0, INT_MAX] nothing is changed, for negative bytes we
now fail on "bytes < 0" check instead of "bytes > INT_MAX" check.

Note, that blk_check_byte_request() still doesn't allow requests
exceeding INT_MAX.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20211006131718.214235-2-vsementsov@virtuozzo.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
  • Loading branch information
Vladimir Sementsov-Ogievskiy authored and ebblake committed Oct 15, 2021
1 parent e7e588d commit 7242db6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions block/block-backend.c
Expand Up @@ -1161,11 +1161,11 @@ void blk_set_disable_request_queuing(BlockBackend *blk, bool disable)
}

static int blk_check_byte_request(BlockBackend *blk, int64_t offset,
size_t size)
int64_t bytes)
{
int64_t len;

if (size > INT_MAX) {
if (bytes < 0 || bytes > INT_MAX) {
return -EIO;
}

Expand All @@ -1183,7 +1183,7 @@ static int blk_check_byte_request(BlockBackend *blk, int64_t offset,
return len;
}

if (offset > len || len - offset < size) {
if (offset > len || len - offset < bytes) {
return -EIO;
}
}
Expand Down

0 comments on commit 7242db6

Please sign in to comment.