util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] libmount: plug a memory leak in exec_helper()
@ 2012-06-14 14:13 Petr Uzel
  2012-06-14 14:13 ` [PATCH 2/3] libmount: fix read before allocated buffer Petr Uzel
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Petr Uzel @ 2012-06-14 14:13 UTC (permalink / raw)
  To: util-linux

valgrind --leak-check=full ./sys-utils/mount -t cifs //127.0.0.1/users /mnt/smb -o user=root,password=linux
....
==21359== 28 bytes in 1 blocks are definitely lost in loss record 1 of 1
==21359==    at 0x4C298B2: realloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==21359==    by 0x415780: __mnt_optstr_append_option (optstr.c:188)
==21359==    by 0x415CB5: mnt_optstr_set_option (optstr.c:387)
==21359==    by 0x40D778: do_mount (context_mount.c:192)
==21359==    by 0x40E6A9: mnt_context_do_mount (context_mount.c:685)
==21359==    by 0x40EB7B: mnt_context_mount (context_mount.c:786)
==21359==    by 0x4058B0: main (mount.c:918)

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
---
 libmount/src/context_mount.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/libmount/src/context_mount.c b/libmount/src/context_mount.c
index 69b5bfc..e00fbe9 100644
--- a/libmount/src/context_mount.c
+++ b/libmount/src/context_mount.c
@@ -458,6 +458,7 @@ static int exec_helper(struct libmnt_context *cxt)
 		break;
 	}
 
+	free(o);
 	return rc;
 }
 
-- 
1.7.7


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] libmount: fix read before allocated buffer
  2012-06-14 14:13 [PATCH 1/3] libmount: plug a memory leak in exec_helper() Petr Uzel
@ 2012-06-14 14:13 ` Petr Uzel
  2012-06-15  9:54   ` Karel Zak
  2012-06-14 14:13 ` [PATCH 3/3] libmount: fix trivial typos Petr Uzel
  2012-06-15  9:53 ` [PATCH 1/3] libmount: plug a memory leak in exec_helper() Karel Zak
  2 siblings, 1 reply; 6+ messages in thread
From: Petr Uzel @ 2012-06-14 14:13 UTC (permalink / raw)
  To: util-linux

valgrind --leak-check=full ./sys-utils/mount -t cifs //127.0.0.1/users /mnt/smb -o user=root,password=linux
....
==21359== Invalid read of size 1
==21359==    at 0x415AC6: mnt_optstr_remove_option_at (optstr.c:310)
==21359==    by 0x416358: mnt_optstr_apply_flags (optstr.c:716)
==21359==    by 0x40DFBF: mnt_context_prepare_mount (context_mount.c:86)
==21359==    by 0x40EB5A: mnt_context_mount (context_mount.c:782)
==21359==    by 0x4058B0: main (mount.c:918)
==21359==  Address 0x51cd5bf is 1 bytes before a block of size 10 alloc'd
==21359==    at 0x4C297CD: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==21359==    by 0x4C29957: realloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==21359==    by 0x415780: __mnt_optstr_append_option (optstr.c:188)
==21359==    by 0x412822: mnt_fs_append_options (fs.c:764)
==21359==    by 0x409288: mnt_context_append_options (context.c:733)
==21359==    by 0x4053F0: main (mount.c:776)

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
---
 libmount/src/optstr.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/libmount/src/optstr.c b/libmount/src/optstr.c
index c8beada..2c9dd5e 100644
--- a/libmount/src/optstr.c
+++ b/libmount/src/optstr.c
@@ -307,7 +307,7 @@ int mnt_optstr_remove_option_at(char **optstr, char *begin, char *end)
 	sz = strlen(end);
 
 	memmove(begin, end, sz + 1);
-	if (!*begin && *(begin - 1) == ',')
+	if (!*begin && (begin > *optstr) && *(begin - 1) == ',')
 		*(begin - 1) = '\0';
 
 	return 0;
-- 
1.7.7


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] libmount: fix trivial typos
  2012-06-14 14:13 [PATCH 1/3] libmount: plug a memory leak in exec_helper() Petr Uzel
  2012-06-14 14:13 ` [PATCH 2/3] libmount: fix read before allocated buffer Petr Uzel
@ 2012-06-14 14:13 ` Petr Uzel
  2012-06-15  9:54   ` Karel Zak
  2012-06-15  9:53 ` [PATCH 1/3] libmount: plug a memory leak in exec_helper() Karel Zak
  2 siblings, 1 reply; 6+ messages in thread
From: Petr Uzel @ 2012-06-14 14:13 UTC (permalink / raw)
  To: util-linux


Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
---
 libmount/src/context_mount.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libmount/src/context_mount.c b/libmount/src/context_mount.c
index e00fbe9..36dc414 100644
--- a/libmount/src/context_mount.c
+++ b/libmount/src/context_mount.c
@@ -168,7 +168,7 @@ done:
 }
 
 /*
- * Converts already evalulated and fixed options to the form that is compatible
+ * Converts already evaluated and fixed options to the form that is compatible
  * with /sbin/mount.type helpers.
  */
 static int generate_helper_optstr(struct libmnt_context *cxt, char **optstr)
@@ -182,7 +182,7 @@ static int generate_helper_optstr(struct libmnt_context *cxt, char **optstr)
 	assert(cxt->fs);
 	assert(optstr);
 
-	DBG(CXT, mnt_debug_h(cxt, "mount: generate heper mount options"));
+	DBG(CXT, mnt_debug_h(cxt, "mount: generate helper mount options"));
 
 	*optstr = mnt_fs_strdup_options(cxt->fs);
 	if (!*optstr)
-- 
1.7.7


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/3] libmount: plug a memory leak in exec_helper()
  2012-06-14 14:13 [PATCH 1/3] libmount: plug a memory leak in exec_helper() Petr Uzel
  2012-06-14 14:13 ` [PATCH 2/3] libmount: fix read before allocated buffer Petr Uzel
  2012-06-14 14:13 ` [PATCH 3/3] libmount: fix trivial typos Petr Uzel
@ 2012-06-15  9:53 ` Karel Zak
  2 siblings, 0 replies; 6+ messages in thread
From: Karel Zak @ 2012-06-15  9:53 UTC (permalink / raw)
  To: Petr Uzel; +Cc: util-linux

On Thu, Jun 14, 2012 at 04:13:01PM +0200, Petr Uzel wrote:
>  libmount/src/context_mount.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)

 Applied, thanks.

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/3] libmount: fix read before allocated buffer
  2012-06-14 14:13 ` [PATCH 2/3] libmount: fix read before allocated buffer Petr Uzel
@ 2012-06-15  9:54   ` Karel Zak
  0 siblings, 0 replies; 6+ messages in thread
From: Karel Zak @ 2012-06-15  9:54 UTC (permalink / raw)
  To: Petr Uzel; +Cc: util-linux

On Thu, Jun 14, 2012 at 04:13:02PM +0200, Petr Uzel wrote:
>  libmount/src/optstr.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)

 Applied, thanks.

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 3/3] libmount: fix trivial typos
  2012-06-14 14:13 ` [PATCH 3/3] libmount: fix trivial typos Petr Uzel
@ 2012-06-15  9:54   ` Karel Zak
  0 siblings, 0 replies; 6+ messages in thread
From: Karel Zak @ 2012-06-15  9:54 UTC (permalink / raw)
  To: Petr Uzel; +Cc: util-linux

On Thu, Jun 14, 2012 at 04:13:03PM +0200, Petr Uzel wrote:
>  libmount/src/context_mount.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)

 Applied, thanks.

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-06-15  9:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-14 14:13 [PATCH 1/3] libmount: plug a memory leak in exec_helper() Petr Uzel
2012-06-14 14:13 ` [PATCH 2/3] libmount: fix read before allocated buffer Petr Uzel
2012-06-15  9:54   ` Karel Zak
2012-06-14 14:13 ` [PATCH 3/3] libmount: fix trivial typos Petr Uzel
2012-06-15  9:54   ` Karel Zak
2012-06-15  9:53 ` [PATCH 1/3] libmount: plug a memory leak in exec_helper() Karel Zak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).