util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hexdump: fix segfault due to uninitialized memory
@ 2011-08-10 13:32 Petr Uzel
  2011-08-15 12:36 ` Karel Zak
  0 siblings, 1 reply; 2+ messages in thread
From: Petr Uzel @ 2011-08-10 13:32 UTC (permalink / raw)
  To: util-linux

[-- Attachment #1: Type: text/plain, Size: 1875 bytes --]

util-linux commit 85bf44b714ab184907eb448eba389218956d6a51
replaced all calls to emalloc() with xmalloc(), whose semantics
is however different - it does not zero allocated memory. This
made hexdump segfault if MALLOC_PERTURB_ was set.

Reported-by: Kyrill Detinov <lazy.kent@opensuse.org>
Addresses: https://bugzilla.novell.com/show_bug.cgi?id=710877

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
---
 text-utils/display.c |    4 ++--
 text-utils/parse.c   |    6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/text-utils/display.c b/text-utils/display.c
index c700b02..ad638e7 100644
--- a/text-utils/display.c
+++ b/text-utils/display.c
@@ -233,8 +233,8 @@ get(void)
 	u_char *tmpp;
 
 	if (!curp) {
-		curp = xmalloc(blocksize);
-		savp = xmalloc(blocksize);
+		curp = xcalloc(1, blocksize);
+		savp = xcalloc(1, blocksize);
 	} else {
 		tmpp = curp;
 		curp = savp;
diff --git a/text-utils/parse.c b/text-utils/parse.c
index 7168aad..e41b4a0 100644
--- a/text-utils/parse.c
+++ b/text-utils/parse.c
@@ -86,7 +86,7 @@ void add(const char *fmt)
 	const char *savep;
 
 	/* Start new linked list of format units. */
-	tfs = xmalloc(sizeof(FS));
+	tfs = xcalloc(1, sizeof(FS));
 	if (!fshead)
 		fshead = tfs;
 	else
@@ -102,7 +102,7 @@ void add(const char *fmt)
 			break;
 
 		/* Allocate a new format unit and link it in. */
-		tfu = xmalloc(sizeof(FU));
+		tfu = xcalloc(1, sizeof(FU));
 		*nextfu = tfu;
 		nextfu = &tfu->nextfu;
 		tfu->reps = 1;
@@ -219,7 +219,7 @@ void rewrite(FS *fs)
 		 * conversion character gets its own.
 		 */
 		for (nconv = 0, fmtp = fu->fmt; *fmtp; nextpr = &pr->nextpr) {
-			pr = xmalloc(sizeof(PR));
+			pr = xcalloc(1, sizeof(PR));
 			if (!fu->nextpr)
 				fu->nextpr = pr;
 			else
-- 
1.7.3.4


Petr

--
Petr Uzel
IRC: ptr_uzl @ freenode

[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [PATCH] hexdump: fix segfault due to uninitialized memory
  2011-08-10 13:32 [PATCH] hexdump: fix segfault due to uninitialized memory Petr Uzel
@ 2011-08-15 12:36 ` Karel Zak
  0 siblings, 0 replies; 2+ messages in thread
From: Karel Zak @ 2011-08-15 12:36 UTC (permalink / raw)
  To: util-linux

On Wed, Aug 10, 2011 at 03:32:28PM +0200, Petr Uzel wrote:
>  text-utils/display.c |    4 ++--
>  text-utils/parse.c   |    6 +++---
>  2 files changed, 5 insertions(+), 5 deletions(-)

 Applied, thanks.

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

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

end of thread, other threads:[~2011-08-15 12:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-10 13:32 [PATCH] hexdump: fix segfault due to uninitialized memory Petr Uzel
2011-08-15 12:36 ` 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).