public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] e2fsprogs : Add stricter checks for blocksize in ext2fs_open
@ 2008-07-11  8:49 Manish Katiyar
  2008-07-11 12:43 ` Peter Staubach
  2008-07-11 12:55 ` Theodore Tso
  0 siblings, 2 replies; 4+ messages in thread
From: Manish Katiyar @ 2008-07-11  8:49 UTC (permalink / raw)
  To: linux-ext4, Theodore Tso; +Cc: mkatiyar

Below patch adds stricter checks in ext2fs_open() so that we catch bad
block sizes earlier than later.

============================================================================

Signed-off-by: "Manish Katiyar" <mkatiyar@gmail.com>

---
 lib/ext2fs/openfs.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/lib/ext2fs/openfs.c b/lib/ext2fs/openfs.c
index fc54afe..670cc7c 100644
--- a/lib/ext2fs/openfs.c
+++ b/lib/ext2fs/openfs.c
@@ -233,7 +233,9 @@ errcode_t ext2fs_open2(const char *name, const
char *io_options,
 	}
 	
 	fs->blocksize = EXT2_BLOCK_SIZE(fs->super);
-	if (fs->blocksize == 0) {
+	if ((fs->blocksize < EXT2_MIN_BLOCK_SIZE) ||
+	    (fs->blocksize > EXT2_MAX_BLOCK_SIZE) ||
+	    (fs->blocksize % EXT2_MIN_BLOCK_SIZE != 0)) {
 		retval = EXT2_ET_CORRUPT_SUPERBLOCK;
 		goto cleanup;
 	}
-- 
1.5.4.3


============================================================================

-- 
Thanks & Regards,
********************************************
Manish Katiyar ( http://mkatiyar.googlepages.com )
3rd Floor, Fair Winds Block
EGL Software Park
Off Intermediate Ring Road
Bangalore 560071, India
***********************************************

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-07-11 21:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-11  8:49 [PATCH] e2fsprogs : Add stricter checks for blocksize in ext2fs_open Manish Katiyar
2008-07-11 12:43 ` Peter Staubach
2008-07-11 12:55 ` Theodore Tso
2008-07-11 21:46   ` Theodore Tso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox