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

Hitoshi Mitake mitake.hitoshi at gmail.com
Sun Sep 8 18:46:56 CEST 2013


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;
 }
-- 
1.8.1.2




More information about the sheepdog mailing list