[Sheepdog] [PATCH 1/5] collie vdi read: do not try to read beyond end of vdi

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Sat Aug 13 17:29:41 CEST 2011


At Sat, 13 Aug 2011 11:56:18 +0100,
Chris Webb wrote:
> 
> Signed-off-by: Chris Webb <chris at arachsys.com>
> ---
>  collie/vdi.c |    9 ++++++++-
>  1 files changed, 8 insertions(+), 1 deletions(-)

Really nice work!  I've pushed the patches to the main git repository.

Thanks,

Kazutaka

> 
> diff --git a/collie/vdi.c b/collie/vdi.c
> index 070539c..e6c32fc 100644
> --- a/collie/vdi.c
> +++ b/collie/vdi.c
> @@ -1012,8 +1012,15 @@ static int vdi_read(int argc, char **argv)
>  		goto out;
>  	}
>  
> +	if (inode->vdi_size < offset) {
> +		fprintf(stderr, "offset beyond end of vdi\n");
> +		ret = EXIT_FAILURE;
> +		goto out;
> +	}
> +
> +	total = min(total, inode->vdi_size - offset);
>  	idx = offset / SD_DATA_OBJ_SIZE;
> -	while (done != total) {
> +	while (done < total) {
>  		len = min(total - done, SD_DATA_OBJ_SIZE - offset);
>  
>  		if (inode->data_vdi_id[idx]) {
> -- 
> 1.7.5.4
> 
> -- 
> sheepdog mailing list
> sheepdog at lists.wpkg.org
> http://lists.wpkg.org/mailman/listinfo/sheepdog



More information about the sheepdog mailing list