libmount: Get rid of an unnecessary check
PATCH 1/4 libmount: Get rid of an unnecessary check
libmount_debug_mask was OR'ed to MNT_DEBUG_INIT so it should be non-null. Thus the check is pointless.
--- libmount/src/init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libmount/src/init.c +1 -1
@@ -40,7 +40,7 @@ void mnt_init_debug(int mask) libmount_debug_mask |=MNT_DEBUG_INIT ; -if (libmount_debug_mask && libmount_debug_mask !=MNT_DEBUG_INIT ) { +if (libmount_debug_mask !=MNT_DEBUG_INIT ) {const char *ver =NULL ;const char **features =NULL , **p;
Signature · 1 line
1.7.9.2
PATCH 2/4 libmount: Free splitted optstr's when error occurred
When strdup() failed, u, v and f optstr's should be freed.
--- libmount/src/fs.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
libmount/src/fs.c +5 -1
@@ -774,8 +774,12 @@ int mnt_fs_set_options(struct libmnt_fs *fs, const char *optstr)if (rc)return rc; n =strdup (optstr); -if (!n) +if (!n) { +free (u); +free (v); +free (f);return -ENOMEM ; + } }free (fs->fs_optstr);
Signature · 1 line
1.7.9.2
Re: [PATCH 2/4] libmount: Free splitted optstr's when error occurred
Quoted 2 lines · Namhyung Kim
libmount/src/fs.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
Applied, thanks.
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
PATCH 3/4 libmount: Set each optstr's to NULL if failed
In reply to Namhyung KimWhen 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().
--- libmount/src/optstr.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
libmount/src/optstr.c +9 -3
@@ -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; } }
Signature · 1 line
1.7.9.2
Karel Zak
maintainerRe: [PATCH 3/4] libmount: Set each optstr's to NULL if failed
Quoted 3 lines · Namhyung Kim
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().
It's bug that mnt_fs_{ap,pre}pend_options() functions use the pointers after failed mnt_split_optstr().
Anyway, it's probably better to be robust here so applied and also fixed mnt_fs_{ap,pre}pend_options().
Thanks!
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
PATCH 4/4 libmount: Remove stale comment on mnt_context_mount()
In reply to Namhyung KimThe commit f9906424 ("libmount: add post-mount checks to detect ro/rw") added necessary check so the comment is not valid anymore.
--- libmount/src/context_mount.c | 5 ----- 1 file changed, 5 deletions(-)
libmount/src/context_mount.c +0 -5
@@ -973,11 +973,6 @@ int mnt_context_mount(struct libmnt_context *cxt) rc =mnt_context_prepare_update (cxt);if (!rc) rc =mnt_context_do_mount (cxt); - -/* TODO: if mtab update is expected then check if the -* target is really mounted read-write to avoid 'ro' in -* mtab and 'rw' in /proc/mounts. -*/ if (!rc) rc =mnt_context_update_tabs (cxt);return rc;
Signature · 1 line
1.7.9.2
Re: [PATCH 4/4] libmount: Remove stale comment on mnt_context_mount()
Quoted 2 lines · Namhyung Kim
libmount/src/context_mount.c | 5 ----- 1 file changed, 5 deletions(-)
Applied, thanks.
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
Quoted 2 lines · Namhyung Kim
libmount/src/init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied, thanks. (The same code we had in libblkid, fixed too.)
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com