]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
umount: segfaults with inconsistent entry in /etc/fstab
authorKarel Zak <kzak@redhat.com>
Fri, 4 Mar 2011 13:44:29 +0000 (14:44 +0100)
committerKarel Zak <kzak@redhat.com>
Fri, 4 Mar 2011 13:44:29 +0000 (14:44 +0100)
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>
lib/mangle.c
mount/mount_mntent.c
mount/umount.c

index 99e8281e62eb5f43c40fac4b39b94e88b7551c6a..a5e157bc98c03e4188cd3cedc4e41c739d200bd4 100644 (file)
@@ -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)
index a1e34db02481910efe5f3a4fa335784297d4727b..d90def36b1851566661eccfbc1be9507680a42d3 100644 (file)
@@ -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++;
index 8ef342a521189d9a14e2e8452cf60bb29610f2d7..42671f465eefd42dd1391e373c9d46582de2d632 100644 (file)
@@ -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);
                }