Whamcloud - gitweb
dupfs.c (ext2fs_dup_handle): Make sure the new filesystem handle
authorTheodore Ts'o <tytso@mit.edu>
Wed, 5 Jan 2005 08:16:09 +0000 (03:16 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 5 Jan 2005 08:16:09 +0000 (03:16 -0500)
has its own copy of the orig_super data structure.  (This
is a better way of fixing a double-free problem in
resize2fs which Fedora attempted to fix in
e2fsprogs-1.35-double_free.patch.   Addresses Red Hat
Bugzilla #132707.)

lib/ext2fs/ChangeLog
lib/ext2fs/dupfs.c

index 3d8f435..048bb4f 100644 (file)
@@ -1,3 +1,12 @@
+2005-01-05  Theodore Ts'o  <tytso@mit.edu>
+
+       * dupfs.c (ext2fs_dup_handle): Make sure the new filesystem handle
+               has its own copy of the orig_super data structure.  (This
+               is a better way of fixing a double-free problem in
+               resize2fs which Fedora attempted to fix in 
+               e2fsprogs-1.35-double_free.patch.   Addresses Red Hat
+               Bugzilla #132707.)
+       
 2004-12-23  Theodore Ts'o  <tytso@mit.edu>
 
        * inode.c (ext2fs_flush_icache): When flushing the icache, clear
index 5c1c6f3..f8919c2 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * dupfs.c --- duplicate a ext2 filesystem handle
  * 
- * Copyright (C) 1997 Theodore Ts'o.
+ * Copyright (C) 1997, 1998, 2001, 2003, 2005 by Theodore Ts'o.
  *
  * %Begin-Header%
  * This file may be redistributed under the terms of the GNU Public
@@ -33,6 +33,7 @@ errcode_t ext2fs_dup_handle(ext2_filsys src, ext2_filsys *dest)
        *fs = *src;
        fs->device_name = 0;
        fs->super = 0;
+       fs->orig_super = 0;
        fs->group_desc = 0;
        fs->inode_map = 0;
        fs->block_map = 0;
@@ -53,6 +54,11 @@ errcode_t ext2fs_dup_handle(ext2_filsys src, ext2_filsys *dest)
                goto errout;
        memcpy(fs->super, src->super, SUPERBLOCK_SIZE);
 
+       retval = ext2fs_get_mem(SUPERBLOCK_SIZE, &fs->orig_super);
+       if (retval)
+               goto errout;
+       memcpy(fs->orig_super, src->orig_super, SUPERBLOCK_SIZE);
+
        retval = ext2fs_get_mem((size_t) fs->desc_blocks * fs->blocksize,
                                &fs->group_desc);
        if (retval)