Skip to contentSkip to conversation

fsck: don't free fstab table on parse failure

PATCH Applied Dave Reisner 2 participants 3 messages Mar 27, 2012 – Apr 10, 2012 Util-Linux package

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fsck: don't free fstab table on parse failure

Even if we fail parsing, fstab gets referenced later in the code (and will subsequently crash via heap corruption). Take the easy way out and simply avoid deallocating this table, as it will be freed for us on program exit regardless.

---
Crash reproducible with 'FSTAB_FILE=/dev/null fsck <any-blockdev>'

 disk-utils/fsck.c |    1 -
 1 file changed, 1 deletion(-)
disk-utils/fsck.c +0 -1
index a019a69..44200d0 100644
@@ -430,7 +430,6 @@ static void load_fs_info(void)
 	path = getenv("FSTAB_FILE");
 
 	if (mnt_table_parse_fstab(fstab, path)) {
-		mnt_free_table(fstab);
 		if (!path)
 			path = mnt_get_fstab_path();
 		if (errno)
Signature · 1 line
1.7.9.4
#1 lore raw
Quoted 7 lines · Dave Reisner

Even if we fail parsing, fstab gets referenced later in the code (and will subsequently crash via heap corruption). Take the easy way out and simply avoid deallocating this table, as it will be freed for us on program exit regardless.

---

Pinging this, as it doesn't seem it was merged...

d

Quoted 20 lines

Crash reproducible with 'FSTAB_FILE=/dev/null fsck <any-blockdev>'

 disk-utils/fsck.c |    1 -
 1 file changed, 1 deletion(-)
disk-utils/fsck.c +0 -1
index a019a69..44200d0 100644
@@ -430,7 +430,6 @@ static void load_fs_info(void)
 	path = getenv("FSTAB_FILE");
 
 	if (mnt_table_parse_fstab(fstab, path)) {
-		mnt_free_table(fstab);
 		if (!path)
 			path = mnt_get_fstab_path();
 		if (errno)
Signature · 1 line
1.7.9.4
maintainer Applied
#2 lore raw
Quoted 10 lines · Dave Reisner
Quoted 7 lines · Dave Reisner

Even if we fail parsing, fstab gets referenced later in the code (and will subsequently crash via heap corruption). Take the easy way out and simply avoid deallocating this table, as it will be freed for us on program exit regardless.

---

Pinging this, as it doesn't seem it was merged...

Sorry, somehow marked as applied in my u-l mail folder, but not applied in git.

Applied, thanks.

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com