summaryrefslogtreecommitdiffstats
path: root/text-utils/parse.c
diff options
context:
space:
mode:
authorPetr Uzel2011-08-10 15:32:28 +0200
committerKarel Zak2011-08-15 14:28:21 +0200
commitc53c38b90b9ca117fdf052c49934f6f2191bec63 (patch)
treee686659c01840b6ff6b42557132d4cebe31478d7 /text-utils/parse.c
parentdmesg: avoid mess at the end of dmesg output (diff)
downloadkernel-qcow2-util-linux-c53c38b90b9ca117fdf052c49934f6f2191bec63.tar.gz
kernel-qcow2-util-linux-c53c38b90b9ca117fdf052c49934f6f2191bec63.tar.xz
kernel-qcow2-util-linux-c53c38b90b9ca117fdf052c49934f6f2191bec63.zip
hexdump: fix segfault due to uninitialized memory
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>
Diffstat (limited to 'text-utils/parse.c')
-rw-r--r--text-utils/parse.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/text-utils/parse.c b/text-utils/parse.c
index 7168aadb3..e41b4a0c7 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