aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2014-04-04 17:07:19 +0200
committerKevin Wolf <kwolf@redhat.com>2014-04-04 19:35:52 +0200
commitf187743acd39747cc8cc32111518142c924963b9 (patch)
treec18367ac0c08081cf9ab8a43763faa707f4da350
parentb998875dcf2b21678cffa8b9a83c09930523861f (diff)
block: Check bdrv_getlength() return value in bdrv_append_temp_snapshot()
Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com>
-rw-r--r--block.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/block.c b/block.c
index d89c344a13..990a7542a9 100644
--- a/block.c
+++ b/block.c
@@ -1184,7 +1184,12 @@ void bdrv_append_temp_snapshot(BlockDriverState *bs, Error **errp)
instead of opening 'filename' directly */
/* Get the required size from the image */
- total_size = bdrv_getlength(bs) & BDRV_SECTOR_MASK;
+ total_size = bdrv_getlength(bs);
+ if (total_size < 0) {
+ error_setg_errno(errp, -total_size, "Could not get image size");
+ return;
+ }
+ total_size &= BDRV_SECTOR_MASK;
/* Create the temporary image */
ret = get_tmp_filename(tmp_filename, sizeof(tmp_filename));