[sheepdog] [PATCH stable-0.7] util: fix an invalid memset() of alloc_bitmap()
Hitoshi Mitake
mitake.hitoshi at lab.ntt.co.jp
Mon Sep 9 05:06:49 CEST 2013
From: Hitoshi Mitake <mitake.hitoshi at gmail.com>
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>
Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
include/bitops.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/bitops.h b/include/bitops.h
index 309469e..e93c14f 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.7.10.4
More information about the sheepdog
mailing list