[PATCH 3/4] libmount: Set each optstr's to NULL if failed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When mnt_split_optstr() failed in the middle, vfs, fs, user optstr's
are freed but not reset.  It can lead to double frees at the end of
mnt_fs_{ap,pre}pend_options().

Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxx>
---
 libmount/src/optstr.c |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/libmount/src/optstr.c b/libmount/src/optstr.c
index 5e9e708..17b129d 100644
--- a/libmount/src/optstr.c
+++ b/libmount/src/optstr.c
@@ -567,12 +567,18 @@ int mnt_split_optstr(const char *optstr, char **user, char **vfs,
 			rc = __mnt_optstr_append_option(fs, name, namesz,
 								val, valsz);
 		if (rc) {
-			if (vfs)
+			if (vfs) {
 				free(*vfs);
-			if (fs)
+				*vfs = NULL;
+			}
+			if (fs) {
 				free(*fs);
-			if (user)
+				*fs = NULL;
+			}
+			if (user) {
 				free(*user);
+				*user = NULL;
+			}
 			return rc;
 		}
 	}
-- 
1.7.9.2

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux