]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
e2fsck: Fix journal replay for block sizes greater than 8k
authorTheodore Ts'o <tytso@mit.edu>
Fri, 2 Jan 2009 23:14:42 +0000 (18:14 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 2 Jan 2009 23:14:42 +0000 (18:14 -0500)
E2fsck was using a fixed-size 8k buffer for replaying blocks from the
journal.  So attempts to replay a journal on filesystems greater than
8k would cause e2fsck to crash with a segfault.

Thanks to Miao Xie <miaox@cn.fujitsu.com> for reporting this problem.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
e2fsck/jfs_user.h
e2fsck/journal.c

index 0e4f9518c196000b821c88efc29e2a4b620eea25..60cc682b503487425e1fb8f3b5146b7fb3a20e7d 100644 (file)
@@ -15,7 +15,6 @@
 #include "e2fsck.h"
 
 struct buffer_head {
-       char            b_data[8192];
        e2fsck_t        b_ctx;
        io_channel      b_io;
        int             b_size;
@@ -23,6 +22,7 @@ struct buffer_head {
        int             b_dirty;
        int             b_uptodate;
        int             b_err;
+       char            b_data[1024];
 };
 
 struct inode {
index 10f5095fdceefc2b80d25a3d2bf30f28a813ffbc..adbd3db0a7ddda6eefaaf10f13bfd11b12a7a063 100644 (file)
@@ -68,8 +68,10 @@ int journal_bmap(journal_t *journal, blk_t block, unsigned long *phys)
 struct buffer_head *getblk(kdev_t kdev, blk_t blocknr, int blocksize)
 {
        struct buffer_head *bh;
+       int bufsize = sizeof(*bh) + kdev->k_ctx->fs->blocksize -
+               sizeof(bh->b_data);
 
-       bh = e2fsck_allocate_memory(kdev->k_ctx, sizeof(*bh), "block buffer");
+       bh = e2fsck_allocate_memory(kdev->k_ctx, bufsize, "block buffer");
        if (!bh)
                return NULL;