From: Karel Zak Date: Wed, 12 Sep 2012 09:57:19 +0000 (+0200) Subject: libmount: segfaults if neither /etc/filesystems nor/proc/filesystems exists X-Git-Tag: v2.23-rc1~700 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3de77c2173e5bc8664a427ce9a8b08c68eea7c7f;p=thirdparty%2Futil-linux.git libmount: segfaults if neither /etc/filesystems nor/proc/filesystems exists Reported-by: Juergen Daubert Signed-off-by: Karel Zak --- diff --git a/libmount/src/context_mount.c b/libmount/src/context_mount.c index f3d8ff103b..fdb459c323 100644 --- a/libmount/src/context_mount.c +++ b/libmount/src/context_mount.c @@ -587,6 +587,9 @@ static int do_mount_by_pattern(struct libmnt_context *cxt, const char *pattern) if (rc) return rc; + if (filesystems == NULL) + return -MNT_ERR_NOFSTYPE; + for (fp = filesystems; *fp; fp++) { rc = do_mount(cxt, *fp); if (mnt_context_get_status(cxt)) diff --git a/libmount/src/utils.c b/libmount/src/utils.c index 245a3b25d3..0cfefb3474 100644 --- a/libmount/src/utils.c +++ b/libmount/src/utils.c @@ -473,6 +473,10 @@ static int get_filesystems(const char *filename, char ***filesystems, const char return rc; } +/* + * Returns zero also if not found any matching filesystem. Always check + * @filesystems pointer! + */ int mnt_get_filesystems(char ***filesystems, const char *pattern) { int rc;