[sheepdog] [PATCH] util: fix an invalid memset() of alloc_bitmap()

Liu Yuan namei.unix at gmail.com
Mon Sep 9 04:30:06 CEST 2013


On Mon, Sep 09, 2013 at 01:46:56AM +0900, Hitoshi Mitake wrote:
> Current alloc_bitmap() calls memset() with an address new_bmap + old_size. The
> expression produces an illegally large address because new_bmap is declared as a
> pointer of unsigned long, but the code seems to assume new_bmap is declared as
> char *. This patch corrects the invalid address caliculation.
> 
> Cc: Gerald Richter <richter at ecos.de>
> Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
> ---
>  include/bitops.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/bitops.h b/include/bitops.h
> index 775643c..6063af5 100644
> --- a/include/bitops.h
> +++ b/include/bitops.h
> @@ -43,7 +43,7 @@ static inline unsigned long *alloc_bitmap(unsigned long *old_bmap,
>  	unsigned long *new_bmap =  xrealloc(old_bmap, new_size);
>  
>  	if (old_bits < new_bits)
> -		memset(new_bmap + old_size, 0, new_size - old_size);
> +		memset((char *)new_bmap + old_size, 0, new_size - old_size);
>  
>  	return new_bmap;

Applied thanks

Yuan



More information about the sheepdog mailing list