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>
#include "e2fsck.h"
struct buffer_head {
- char b_data[8192];
e2fsck_t b_ctx;
io_channel b_io;
int b_size;
int b_dirty;
int b_uptodate;
int b_err;
+ char b_data[1024];
};
struct inode {
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;