From 334cc089c91ff41423e2b7ded5b65cf20c79b616 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Wed, 6 May 2015 22:41:40 +0200 Subject: [PATCH 1/1] CHG: clearing a char array before using. --- client/util.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/client/util.c b/client/util.c index 5bb98fd7..382c85c6 100644 --- a/client/util.c +++ b/client/util.c @@ -108,15 +108,16 @@ void print_hex(const uint8_t * data, const size_t len) printf("\n"); } -char * sprint_hex(const uint8_t * data, const size_t len) { +char *sprint_hex(const uint8_t *data, const size_t len) { int maxLen = ( len > 1024/3) ? 1024/3 : len; static char buf[1024]; - char * tmp = buf; + memset(buf, 0x00, 1024); + char *tmp = buf; size_t i; for (i=0; i < maxLen; ++i, tmp += 3) - sprintf(tmp, "%02x ", data[i]); + sprintf(tmp, "%02X ", data[i]); return buf; } @@ -125,6 +126,7 @@ char *sprint_bin_break(const uint8_t *data, const size_t len, const uint8_t brea int maxLen = ( len > 1024) ? 1024 : len; static char buf[1024]; + memset(buf, 0x00, 1024); char *tmp = buf; for (size_t i=0; i < maxLen; ++i){ -- 2.39.5