diff options
author | Karel Zak | 2007-10-11 16:18:29 +0200 |
---|---|---|
committer | Karel Zak | 2007-10-12 00:38:22 +0200 |
commit | 031a4a7ab1b8ebab2f88f41bc98965855dbd1c62 (patch) | |
tree | f0b7b04fe9508aa5639995ed9d9a979f58d2a86d /mount | |
parent | tests: exactly define a time format in ls -l output (diff) | |
download | kernel-qcow2-util-linux-031a4a7ab1b8ebab2f88f41bc98965855dbd1c62.tar.gz kernel-qcow2-util-linux-031a4a7ab1b8ebab2f88f41bc98965855dbd1c62.tar.xz kernel-qcow2-util-linux-031a4a7ab1b8ebab2f88f41bc98965855dbd1c62.zip |
mount: -L|-U segfault when label or uuid doesn't exist
# mount -L foo
Segmentation fault
mount(8) calls strcmp() with NULL argument.
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'mount')
-rw-r--r-- | mount/mount.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/mount/mount.c b/mount/mount.c index 2e458cad0..b65ee62ce 100644 --- a/mount/mount.c +++ b/mount/mount.c @@ -1702,6 +1702,9 @@ getfs(const char *spec, const char *uuid, const char *label) struct mntentchn *mc = NULL; const char *devname = NULL; + if (!spec && !uuid && !label) + return NULL; + /* * A) 99% of all cases, the spec on cmdline matches * with spec in fstab @@ -1764,7 +1767,7 @@ getfs(const char *spec, const char *uuid, const char *label) * Earlier mtab was tried first, but this would sometimes try the * wrong mount in case mtab had the root device entry wrong. */ - if (!mc) + if (!mc && (devname || spec)) mc = getmntfile (devname ? devname : spec); if (devname) @@ -1984,12 +1987,17 @@ main(int argc, char *argv[]) { case 1: /* mount [-nfrvw] [-o options] special | node + * mount -L label (or -U uuid) * (/etc/fstab is necessary) */ if (types != NULL) usage (stderr, EX_USAGE); - mc = getfs(*argv, uuid, label); + if (uuid || label) + mc = getfs(NULL, uuid, label); + else + mc = getfs(*argv, NULL, NULL); + if (!mc) { if (uuid || label) die (EX_USAGE, _("mount: no such partition found")); |