]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #1011 in SNORT/snort3 from file_lib_fix to master
authorMichael Altizer (mialtize) <mialtize@cisco.com>
Mon, 11 Sep 2017 21:05:14 +0000 (17:05 -0400)
committerMichael Altizer (mialtize) <mialtize@cisco.com>
Mon, 11 Sep 2017 21:05:14 +0000 (17:05 -0400)
Squashed commit of the following:

commit e23f9254f747db77ad1263800810cb2cd3ae9715
Author: Steven Baigal <sbaigal@cisco.com>
Date:   Mon Sep 11 15:08:58 2017 -0400

    Fixed a valgrind error -- null terminator overwritten when length equals 8

src/file_api/file_lib.cc

index cbfc80089395b616cb56313999ed4378e51bdafd..00418d820a8ec34cf8db13e7b863f33f439d2c46 100644 (file)
@@ -602,7 +602,6 @@ void FileContext::print_file_data(FILE* fp, const uint8_t* data, int len, int ma
     }
     if (pos)
     {
-        str[pos] = 0;
         for (; pos < 17; pos++)
         {
             if (pos == 8)
@@ -616,6 +615,7 @@ void FileContext::print_file_data(FILE* fp, const uint8_t* data, int len, int ma
                 fprintf(fp, "%s", "   ");
             }
         }
+        str[pos] = 0;
         fprintf(fp, "  %s\n", str);
     }
 }