Skip to contentSkip to conversation

fix dblist size accounting (was Re: Invalid superblock after e2fsck)

PATCH New Andreas Dilger 1 participant 1 message Feb 25, 2010 5 messages not in the archive

lore
Share & tools
lore
#5 lore raw

PATCH 1/1 fix dblist size accounting (was Re: Invalid superblock after e2fsck)

In reply to a message not in the archive
Quoted 9 lines · Albert Sellarès

I already tried to check the filesystem with last e2fsprogs version (1.41.10) but with this version I did get a segfault.

I opened a bug with all the information [1]

Thank you!

[1]
http://sourceforge.net/tracker/?func=detail&aid=2956459&group_id=2406&atid=102406

I'm not sure if it is related, but I noticed that the above bug is segfaulting in ext2fs_add_dir_block(), and I have a patch in my tree that fixes the block dblist accounting in the case that realloc() fails its allocation. I'm just in the process of sending out all of the patches I've accumulated, so I may as well send this one now.

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.

Fix dblist size accounting in the case where ext2fs_resize_mem() fails to allocate a larger buffer.

lib/ext2fs/dblist.c +1 -1
Index: e2fsprogs-1.41.10/lib/ext2fs/dblist.c
===================================================================
@@ -169,7 +169,7 @@ errcode_t ext2fs_add_dir_block(ext2_dbli
 					   sizeof(struct ext2_db_entry),
 					   &dblist->list);
 		if (retval) {
-			dblist->size -= 100;
+			dblist->size = old_size / sizeof(struct ext2_db_entry);
 			return retval;
 		}
 	}