vmdk: Fix error handling/reporting of vmdk_check
Errors from the callees must be captured and propagated to our caller, ensure this for both find_extent() and bdrv_getlength(). Reported-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Fam Zheng <famz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
809eb70ed6
commit
0e51b9b7c7
26
block/vmdk.c
26
block/vmdk.c
@ -2236,6 +2236,7 @@ static int vmdk_check(BlockDriverState *bs, BdrvCheckResult *result,
|
|||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"ERROR: could not find extent for sector %" PRId64 "\n",
|
"ERROR: could not find extent for sector %" PRId64 "\n",
|
||||||
sector_num);
|
sector_num);
|
||||||
|
ret = -EINVAL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ret = get_cluster_offset(bs, extent, NULL,
|
ret = get_cluster_offset(bs, extent, NULL,
|
||||||
@ -2247,19 +2248,28 @@ static int vmdk_check(BlockDriverState *bs, BdrvCheckResult *result,
|
|||||||
PRId64 "\n", sector_num);
|
PRId64 "\n", sector_num);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (ret == VMDK_OK &&
|
if (ret == VMDK_OK) {
|
||||||
cluster_offset >= bdrv_getlength(extent->file->bs))
|
int64_t extent_len = bdrv_getlength(extent->file->bs);
|
||||||
{
|
if (extent_len < 0) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"ERROR: cluster offset for sector %"
|
"ERROR: could not get extent file length for sector %"
|
||||||
PRId64 " points after EOF\n", sector_num);
|
PRId64 "\n", sector_num);
|
||||||
break;
|
ret = extent_len;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (cluster_offset >= extent_len) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"ERROR: cluster offset for sector %"
|
||||||
|
PRId64 " points after EOF\n", sector_num);
|
||||||
|
ret = -EINVAL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sector_num += extent->cluster_sectors;
|
sector_num += extent->cluster_sectors;
|
||||||
}
|
}
|
||||||
|
|
||||||
result->corruptions++;
|
result->corruptions++;
|
||||||
return 0;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ImageInfoSpecific *vmdk_get_specific_info(BlockDriverState *bs)
|
static ImageInfoSpecific *vmdk_get_specific_info(BlockDriverState *bs)
|
||||||
|
Loading…
Reference in New Issue
Block a user