From: Karel Zak Date: Thu, 11 Oct 2007 14:18:29 +0000 (+0200) Subject: mount: -L|-U segfault when label or uuid doesn't exist X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=031a4a7ab1b8ebab2f88f41bc98965855dbd1c62;p=util-linux 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 --- diff --git a/mount/mount.c b/mount/mount.c index 2e458cad..b65ee62c 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"));