OSDN Git Service

libext2fs: set the fs block size to new_io in ext2fs_rewrite_to_io()
authorKit Westneat <kwestneat@ddn.com>
Mon, 2 Dec 2013 19:47:08 +0000 (14:47 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 2 Dec 2013 19:49:41 +0000 (14:49 -0500)
e2image manually opens a new IO channel, and then sets the file system
to use this new IO channel via ext2fs_rewrite+to_io().  We need to
make sure the IO channel is set to the file system's block size to
avoid some nasty buffer overruns.

[ Modified by tytso to use io_channel_set_blksize() ]

Signed-off-by: Kit Westneat <kwestneat@ddn.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
lib/ext2fs/openfs.c

index 9fe1645..c38b586 100644 (file)
@@ -451,8 +451,13 @@ errcode_t ext2fs_set_data_io(ext2_filsys fs, io_channel new_io)
 
 errcode_t ext2fs_rewrite_to_io(ext2_filsys fs, io_channel new_io)
 {
+       errcode_t err;
+
        if ((fs->flags & EXT2_FLAG_IMAGE_FILE) == 0)
                return EXT2_ET_NOT_IMAGE_FILE;
+       err = io_channel_set_blksize(new_io, fs->blocksize);
+       if (err)
+               return err;
        fs->io = fs->image_io = new_io;
        fs->flags |= EXT2_FLAG_DIRTY | EXT2_FLAG_RW |
                EXT2_FLAG_BB_DIRTY | EXT2_FLAG_IB_DIRTY;