Skip to content

Commit

Permalink
vhdx: Check for 4 GB maximum log size on creation
Browse files Browse the repository at this point in the history
It's unclear what the real maximum is, but we use an uint32_t to store
the log size in vhdx_co_create(), so we should check that the given
value fits in 32 bits.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Jeff Cody <jcody@redhat.com>
  • Loading branch information
kevmw committed Mar 26, 2018
1 parent 0fcc38e commit 6f16f7c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions block/vhdx.c
Expand Up @@ -1829,6 +1829,10 @@ static int coroutine_fn vhdx_co_create(BlockdevCreateOptions *opts,
if (!vhdx_opts->has_log_size) {
log_size = DEFAULT_LOG_SIZE;
} else {
if (vhdx_opts->log_size > UINT32_MAX) {
error_setg(errp, "Log size must be smaller than 4 GB");
return -EINVAL;
}
log_size = vhdx_opts->log_size;
}
if (log_size < MiB || (log_size % MiB) != 0) {
Expand Down

0 comments on commit 6f16f7c

Please sign in to comment.