]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
file: consistently track size of gaps
authorVictor Julien <vjulien@oisf.net>
Mon, 13 Jun 2022 10:55:52 +0000 (12:55 +0200)
committerVictor Julien <vjulien@oisf.net>
Mon, 13 Jun 2022 18:15:29 +0000 (20:15 +0200)
Until now only the size of gaps counted in the regular append, not
close and open.

Bug: #5392.
(cherry picked from commit 71ef62bfc5ee8ffe4798467935f4f9386178565e)

src/util-file.c

index ce7958dd37137caf80324881f4d17eae1b942e5e..f41c1b075047fa548aee3728e093075cbfa749e6 100644 (file)
@@ -913,8 +913,8 @@ static File *FileOpenFile(FileContainer *ffc, const StreamingBufferConfig *sbcfg
 
     FileContainerAdd(ffc, ff);
 
+    ff->size += data_len;
     if (data != NULL) {
-        ff->size += data_len;
         if (AppendData(ff, data, data_len) != 0) {
             ff->state = FILE_STATE_ERROR;
             SCReturnPtr(NULL, "File");
@@ -955,8 +955,8 @@ int FileCloseFilePtr(File *ff, const uint8_t *data,
         SCReturnInt(-1);
     }
 
+    ff->size += data_len;
     if (data != NULL) {
-        ff->size += data_len;
         if (ff->flags & FILE_NOSTORE) {
 #ifdef HAVE_NSS
             /* no storage but hashing */