Whamcloud - gitweb
Fix byte swapping bug in get_next_inode_full()
authorKalpak Shah <kalpak@clusterfs.com>
Sat, 30 Jun 2007 01:40:19 +0000 (21:40 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 30 Jun 2007 01:40:19 +0000 (21:40 -0400)
On big-endian systems, while swapping, ext2fs_swap_inode_full() swaps
only 128+extra_isize bytes and the EAs if they are present. Now if inode
N has EAs, (and this is the inode in the "scratch inode") then inode N+1
also carries seems to have them since the "scratch inode" was never
zeroed.

Signed-off-by: Kalpak Shah <kalpak@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lib/ext2fs/ChangeLog
lib/ext2fs/inode.c

index f7ef59d..08a1689 100644 (file)
@@ -1,3 +1,10 @@
+2007-06-29  Theodore Tso  <tytso@mit.edu>
+
+       * inode.c (ext2fs_get_next_inode_full): Whe byte swapping, make
+               sure the inode buffer is cleared first so that the
+               previous contents don't get mistaken as part of the new
+               (next) inode.
+
 2006-06-24  Theodore Ts'o  <tytso@mit.edu>
 
        * Release of E2fsprogs 1.40
index 03d1be0..49d012c 100644 (file)
@@ -454,6 +454,7 @@ errcode_t ext2fs_get_next_inode_full(ext2_inode_scan scan, ext2_ino_t *ino,
                scan->bytes_left -= scan->inode_size - extra_bytes;
 
 #ifdef EXT2FS_ENABLE_SWAPFS
+               memset(inode, 0, bufsize);
                if ((scan->fs->flags & EXT2_FLAG_SWAP_BYTES) ||
                    (scan->fs->flags & EXT2_FLAG_SWAP_BYTES_READ))
                        ext2fs_swap_inode_full(scan->fs, 
@@ -468,6 +469,7 @@ errcode_t ext2fs_get_next_inode_full(ext2_inode_scan scan, ext2_ino_t *ino,
                scan->scan_flags &= ~EXT2_SF_BAD_EXTRA_BYTES;
        } else {
 #ifdef EXT2FS_ENABLE_SWAPFS
+               memset(inode, 0, bufsize);
                if ((scan->fs->flags & EXT2_FLAG_SWAP_BYTES) ||
                    (scan->fs->flags & EXT2_FLAG_SWAP_BYTES_READ))
                        ext2fs_swap_inode_full(scan->fs,