summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak2011-03-04 14:44:29 +0100
committerKarel Zak2011-03-04 14:44:29 +0100
commit6c7f688b1f46c6fb31aa8a4a27d493c90e9ded37 (patch)
treef35b1f59e5f760c287af5e13a7dc4e8ada5c67f9
parentdocs: update TODO (diff)
downloadkernel-qcow2-util-linux-6c7f688b1f46c6fb31aa8a4a27d493c90e9ded37.tar.gz
kernel-qcow2-util-linux-6c7f688b1f46c6fb31aa8a4a27d493c90e9ded37.tar.xz
kernel-qcow2-util-linux-6c7f688b1f46c6fb31aa8a4a27d493c90e9ded37.zip
umount: segfaults with inconsistent entry in /etc/fstab
Addresses: https://bugs.launchpad.net/ubuntu/+source/util-linux/+bug/726283 Reported-by: Greg Brockman <gdb@gregbrockman.com> Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r--lib/mangle.c2
-rw-r--r--mount/mount_mntent.c3
-rw-r--r--mount/umount.c2
3 files changed, 6 insertions, 1 deletions
diff --git a/lib/mangle.c b/lib/mangle.c
index 99e8281e6..a5e157bc9 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 a1e34db02..d90def36b 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 8ef342a52..42671f465 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);
}