From 53ca67faf2aa1d742119c3510ef5064e0761ed90 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 11 Oct 2007 16:18:29 +0200 Subject: [PATCH] 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 --- mount/mount.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mount/mount.c b/mount/mount.c index 5bc2b30c..96776db3 100644 --- a/mount/mount.c +++ b/mount/mount.c @@ -1699,6 +1699,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 @@ -1761,7 +1764,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) @@ -1981,12 +1984,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")); -- 2.39.5