From b476e41fa4ed1e75988a4dd755e220bca2b2b984 Mon Sep 17 00:00:00 2001 From: Dan Pasanen Date: Thu, 5 Mar 2015 16:08:44 -0600 Subject: [PATCH] mount: address a couple crashes Change-Id: I3f978f40eb77d7679decf4a33b5c655ebb74d979 --- util-linux/mount.c | 5 ++--- util-linux/volume_id/get_devname.c | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/util-linux/mount.c b/util-linux/mount.c index 410d028aa..6f1ce6734 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c @@ -1790,13 +1790,12 @@ static int singlemount(struct mntent *mp, int ignore_busy) // Treat fstype "auto" as unspecified if (mp->mnt_type && !strcmp(mp->mnt_type, "auto")) mp->mnt_type = NULL; - } else { + } else if (mp->mnt_type) { // If user didn't specify an fstype and blkid disagrees or the // fstype is "auto", trust blkid's determination of the fstype. - detected_fstype = get_fstype_from_devname(mp->mnt_fsname); - if ((mp->mnt_type && !strcmp(mp->mnt_type, "auto")) || + if (!strcmp(mp->mnt_type, "auto") || (detected_fstype && strcmp(detected_fstype, mp->mnt_type))) mp->mnt_type = detected_fstype; } diff --git a/util-linux/volume_id/get_devname.c b/util-linux/volume_id/get_devname.c index 138a0ceed..85b0fad7b 100644 --- a/util-linux/volume_id/get_devname.c +++ b/util-linux/volume_id/get_devname.c @@ -281,7 +281,7 @@ char *get_fstype_from_devname(const char *device) add_to_uuid_cache(device); uc = uuidcache_init(0); - return (char*)uc->type; + return (uc != NULL ? (char*)uc->type : NULL); #else return NULL; #endif