From: Victor Julien Date: Tue, 4 Mar 2014 11:42:16 +0000 (+0100) Subject: Fix BytesToString indexing array using wrong index X-Git-Tag: suricata-2.0rc2~12 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F870%2Fhead;p=thirdparty%2Fsuricata.git 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 --- 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';