From a0a4f1c4f7d9d23d733cf3ae9685452364a58a70 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Wed, 23 May 2012 02:29:58 +0200 Subject: Fix bit shift validity * ext2fs/balloc.c (ext2_new_block): When J & 31 is 31, replace 32bit right shift with 0; --- ext2fs/balloc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'ext2fs') diff --git a/ext2fs/balloc.c b/ext2fs/balloc.c index 7333123c..8ad29cec 100644 --- a/ext2fs/balloc.c +++ b/ext2fs/balloc.c @@ -197,8 +197,11 @@ repeat: * The goal was occupied; search forward for a free * block within the next 32 blocks */ - lmap = ((((unsigned long *) bh)[j >> 5]) >> - ((j & 31) + 1)); + if (j & 31 == 31) + lmap = 0; + else + lmap = ((((unsigned long *) bh)[j >> 5]) >> + ((j & 31) + 1)); if (j < sblock->s_blocks_per_group - 32) lmap |= (((unsigned long *) bh)[(j >> 5) + 1]) << (31 - (j & 31)); -- cgit v1.2.3