From 03a107bedcd42f9a93faa46408c8dd8dd7525dac Mon Sep 17 00:00:00 2001
From: Daniel Salzman <daniel.salzman@nic.cz>
Date: Tue, 14 May 2013 11:08:43 +0200
Subject: [PATCH] utils: add initialization to buffer allocation

Uninitialized buffer caused problems during blank rrset processing.

refs #2137

Change-Id: Iabc95f2561bb8a0215eddc67ba8121c54561454c
---
 src/utils/common/exec.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/utils/common/exec.c b/src/utils/common/exec.c
index 8efdf8aa8d..54cb5f2147 100644
--- a/src/utils/common/exec.c
+++ b/src/utils/common/exec.c
@@ -195,7 +195,7 @@ static void print_section_question(const knot_dname_t *owner,
                                    const style_t      *style)
 {
 	size_t buflen = 8192;
-	char   *buf = malloc(buflen);
+	char   *buf = calloc(buflen, 1);
 
 	knot_rrset_t *question = knot_rrset_new((knot_dname_t *)owner, qtype,
 	                                        qclass, 0);
@@ -216,7 +216,7 @@ static void print_section_full(const knot_rrset_t **rrsets,
                                const style_t      *style)
 {
 	size_t buflen = 8192;
-	char   *buf = malloc(buflen);
+	char   *buf = calloc(buflen, 1);
 
 	for (size_t i = 0; i < count; i++) {
 		while (knot_rrset_txt_dump(rrsets[i], buf, buflen,
@@ -242,7 +242,7 @@ static void print_section_dig(const knot_rrset_t **rrsets,
                               const style_t      *style)
 {
 	size_t buflen = 8192;
-	char   *buf = malloc(buflen);
+	char   *buf = calloc(buflen, 1);
 
 	for (size_t i = 0; i < count; i++) {
 		const knot_rrset_t *rrset = rrsets[i];
@@ -271,7 +271,7 @@ static void print_section_host(const knot_rrset_t **rrsets,
                                const style_t      *style)
 {
 	size_t buflen = 8192;
-	char   *buf = malloc(buflen);
+	char   *buf = calloc(buflen, 1);
 
 	for (size_t i = 0; i < count; i++) {
 		const knot_rrset_t  *rrset = rrsets[i];
-- 
GitLab