From: Karel Zak Date: Fri, 4 Mar 2011 13:44:29 +0000 (+0100) Subject: umount: segfaults with inconsistent entry in /etc/fstab X-Git-Tag: v2.20-rc1~489 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6c7f688b1f46c6fb31aa8a4a27d493c90e9ded37;p=thirdparty%2Futil-linux.git umount: segfaults with inconsistent entry in /etc/fstab Addresses: https://bugs.launchpad.net/ubuntu/+source/util-linux/+bug/726283 Reported-by: Greg Brockman Signed-off-by: Karel Zak --- diff --git a/lib/mangle.c b/lib/mangle.c index 99e8281e62..a5e157bc98 100644 --- a/lib/mangle.c +++ b/lib/mangle.c @@ -94,6 +94,8 @@ char *unmangle(const char *s, char **end) if (end) *end = e; + if (e == s) + return NULL; /* empty string */ buf = malloc(sz); if (!buf) diff --git a/mount/mount_mntent.c b/mount/mount_mntent.c index a1e34db024..d90def36b1 100644 --- a/mount/mount_mntent.c +++ b/mount/mount_mntent.c @@ -128,6 +128,9 @@ my_getmntent (mntFILE *mfp) { me.mnt_opts = unmangle(s, &s); s = skip_spaces(s); + if (!me.mnt_fsname || !me.mnt_dir || !me.mnt_type) + goto err; + if (isdigit(*s)) { me.mnt_freq = atoi(s); while(isdigit(*s)) s++; diff --git a/mount/umount.c b/mount/umount.c index 8ef342a521..42671f465e 100644 --- a/mount/umount.c +++ b/mount/umount.c @@ -608,7 +608,7 @@ umount_file (char *arg) { file); /* spec could be a file which is loop mounted */ - if (fs && !is_valid_loop(mc, fs)) + if (!fs || !is_valid_loop(mc, fs)) die (2, _("umount: %s mount disagrees with " "the fstab"), file); }