]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
print: Escape backslash in PrintRawUriFp
authorMaurizio Abba <mabba@lastline.com>
Thu, 11 Jan 2018 15:21:06 +0000 (15:21 +0000)
committerVictor Julien <victor@inliniac.net>
Fri, 12 Jan 2018 15:44:41 +0000 (16:44 +0100)
PrintRawUriFp does not properly escape backslash. This causes confusion
between a \ character and an hex-encoded character. PrintRawUriBuffer,
instead, correctly does backslash-encoding.
Adding proper escaping of backslash to PrintRawUriFp.

src/util-print.c

index 544728b6fb8e53616f70943546adad26de3b60ed..f654f4b5c0ca23d2724499ced04efaf64c207105 100644 (file)
@@ -99,8 +99,13 @@ void PrintRawUriFp(FILE *fp, uint8_t *buf, uint32_t buflen)
 
     for (u = 0; u < buflen; u++) {
         if (isprint(buf[u]) && buf[u] != '\"') {
-            PrintBufferData(nbuf, &offset, BUFFER_LENGTH,
-                             "%c", buf[u]);
+            if (buf[u] == '\\') {
+                PrintBufferData(nbuf, &offset, BUFFER_LENGTH,
+                                "\\\\");
+            } else {
+                PrintBufferData(nbuf, &offset, BUFFER_LENGTH,
+                                "%c", buf[u]);
+            }
         } else {
             PrintBufferData(nbuf, &offset, BUFFER_LENGTH,
                             "\\x%02X", buf[u]);