]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
Fix BytesToString indexing array using wrong index 870/head
authorVictor Julien <victor@inliniac.net>
Tue, 4 Mar 2014 11:42:16 +0000 (12:42 +0100)
committerVictor Julien <victor@inliniac.net>
Tue, 4 Mar 2014 11:42:16 +0000 (12:42 +0100)
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

index 65bf35baa13446cc9a488572a7e0fb0865a5de66..352cdeaf01fc473d5fadae8a37b0257ed11c86bc 100644 (file)
@@ -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';