From 52a285bf4e8d3a78d7211694977f5894a748bdac Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Mon, 25 Mar 2013 09:17:52 +0100 Subject: [PATCH] libmount: umount crashes when trying to umount a non-mountpoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reported-by: Mantas Mikulėnas Signed-off-by: Karel Zak --- libmount/src/context_umount.c | 4 ++-- libmount/src/fs.c | 3 +++ libmount/src/libmount.h.in | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/libmount/src/context_umount.c b/libmount/src/context_umount.c index 113c53e..96ae87a 100644 --- a/libmount/src/context_umount.c +++ b/libmount/src/context_umount.c @@ -183,7 +183,7 @@ err: static int lookup_umount_fs(struct libmnt_context *cxt) { const char *tgt; - struct libmnt_fs *fs; + struct libmnt_fs *fs = NULL; int rc; assert(cxt); @@ -198,7 +198,7 @@ static int lookup_umount_fs(struct libmnt_context *cxt) rc = mnt_context_find_umount_fs(cxt, tgt, &fs); if (rc < 0) return rc; - if (!fs) { + if (rc == 1 || !fs) { DBG(CXT, mnt_debug_h(cxt, "umount: cannot find %s in mtab", tgt)); return 0; } diff --git a/libmount/src/fs.c b/libmount/src/fs.c index 96c13d3..bb9006d 100644 --- a/libmount/src/fs.c +++ b/libmount/src/fs.c @@ -129,6 +129,9 @@ struct libmnt_fs *mnt_copy_fs(struct libmnt_fs *dest, { const struct libmnt_fs *org = dest; + if (!src) + return NULL; + if (!dest) { dest = mnt_new_fs(); if (!dest) diff --git a/libmount/src/libmount.h.in b/libmount/src/libmount.h.in index ccd260d..bb18ba1 100644 --- a/libmount/src/libmount.h.in +++ b/libmount/src/libmount.h.in @@ -318,7 +318,7 @@ extern void mnt_reset_fs(struct libmnt_fs *fs) __ul_attribute__((nonnull)); extern struct libmnt_fs *mnt_copy_fs(struct libmnt_fs *dest, const struct libmnt_fs *src) - __ul_attribute__((nonnull(2), warn_unused_result)); + __ul_attribute__((warn_unused_result)); extern void *mnt_fs_get_userdata(struct libmnt_fs *fs) __ul_attribute__((nonnull)); extern int mnt_fs_set_userdata(struct libmnt_fs *fs, void *data); -- 1.8.1.4