From 00d2f2d627bfe3eb1245dda28033a459fb55de27 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Tue, 4 Mar 2014 12:42:16 +0100 Subject: [PATCH] Fix BytesToString indexing array using wrong index This would lead to reading past the end of the buffer and also writing past the end of the newly allocated buffer. Bug #1121 --- src/util-byte.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util-byte.c b/src/util-byte.c index 65bf35baa1..352cdeaf01 100644 --- a/src/util-byte.c +++ b/src/util-byte.c @@ -57,9 +57,9 @@ char *BytesToString(const uint8_t *bytes, size_t nbytes) /* no nulls */ memcpy(string, bytes, nbytes); } else { - /* no nulls present */ + /* nulls present */ char *dst = string; - for (u = 0; u < n; u++) { + for (u = 0; u < nbytes; u++) { if (bytes[u] == '\0') { *dst++ = '\\'; *dst++ = '0'; -- 2.47.2