From 180bdba7ac2d05ed781a163f1054e5962efda193 Mon Sep 17 00:00:00 2001 From: jsteube Date: Tue, 4 Oct 2016 23:29:15 +0200 Subject: [PATCH] Limit exec_hexify() to max 31 chars to be able to add 0 byte --- src/convert.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/convert.c b/src/convert.c index 0dfa20d78..030eef233 100644 --- a/src/convert.c +++ b/src/convert.c @@ -22,7 +22,7 @@ bool need_hexify (const u8 *buf, const int len) void exec_hexify (const u8 *buf, const int len, u8 *out) { - const int max_len = (len >= 32) ? 32 : len; + const int max_len = (len >= 31) ? 31 : len; for (int i = max_len - 1, j = i * 2; i >= 0; i -= 1, j -= 2) { @@ -39,6 +39,8 @@ void exec_hexify (const u8 *buf, const int len, u8 *out) out[j + 0] = h0; out[j + 1] = h1; } + + out[max_len * 2] = 0; } bool is_valid_hex_char (const u8 c)