From 3de77c2173e5bc8664a427ce9a8b08c68eea7c7f Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Wed, 12 Sep 2012 11:57:19 +0200 Subject: [PATCH] libmount: segfaults if neither /etc/filesystems nor/proc/filesystems exists Reported-by: Juergen Daubert Signed-off-by: Karel Zak --- libmount/src/context_mount.c | 3 +++ libmount/src/utils.c | 4 ++++ 2 files changed, 7 insertions(+) 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; -- 2.47.2