suricata
util-file.c
Go to the documentation of this file.
1 /* Copyright (C) 2007-2012 Open Information Security Foundation
2  *
3  * You can copy, redistribute or modify this Program under the terms of
4  * the GNU General Public License version 2 as published by the Free
5  * Software Foundation.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * version 2 along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15  * 02110-1301, USA.
16  */
17 
18 /**
19  * \file
20  *
21  * \author Victor Julien <victor@inliniac.net>
22  * \author Pablo Rincon <pablo.rincon.crespo@gmail.com>
23  *
24  */
25 
26 #include "suricata-common.h"
27 #include "suricata.h"
28 #include "debug.h"
29 #include "flow.h"
30 #include "stream.h"
31 #include "stream-tcp.h"
32 #include "runmodes.h"
33 #include "util-hash.h"
34 #include "util-debug.h"
35 #include "util-memcmp.h"
36 #include "util-print.h"
37 #include "app-layer-parser.h"
38 #include "util-validate.h"
39 
40 /** \brief switch to force filestore on all files
41  * regardless of the rules.
42  */
43 static int g_file_force_filestore = 0;
44 
45 /** \brief switch to force magic checks on all files
46  * regardless of the rules.
47  */
48 static int g_file_force_magic = 0;
49 
50 /** \brief switch to force md5 calculation on all files
51  * regardless of the rules.
52  */
53 static int g_file_force_md5 = 0;
54 
55 /** \brief switch to force sha1 calculation on all files
56  * regardless of the rules.
57  */
58 static int g_file_force_sha1 = 0;
59 
60 /** \brief switch to force sha256 calculation on all files
61  * regardless of the rules.
62  */
63 static int g_file_force_sha256 = 0;
64 
65 /** \brief switch to force tracking off all files
66  * regardless of the rules.
67  */
68 static int g_file_force_tracking = 0;
69 
70 /** \brief switch to use g_file_store_reassembly_depth
71  * to reassembly files
72  */
73 static int g_file_store_enable = 0;
74 
75 /** \brief stream_config.reassembly_depth equivalent
76  * for files
77  */
78 static uint32_t g_file_store_reassembly_depth = 0;
79 
80 /* prototypes */
81 static void FileFree(File *);
82 #ifdef HAVE_NSS
83 static void FileEndSha256(File *ff);
84 #endif
85 
87 {
88  g_file_force_filestore = 1;
89 }
90 
92 {
93  g_file_force_magic = 1;
94 }
95 
97 {
98  g_file_force_md5 = 1;
99 }
100 
102 {
103  g_file_force_sha1 = 1;
104 }
105 
107 {
108  g_file_force_sha256 = 1;
109 }
110 
112 {
113  return g_file_force_filestore;
114 }
115 
116 void FileReassemblyDepthEnable(uint32_t size)
117 {
118  g_file_store_enable = 1;
119  g_file_store_reassembly_depth = size;
120 }
121 
122 uint32_t FileReassemblyDepth(void)
123 {
124  if (g_file_store_enable == 1)
125  return g_file_store_reassembly_depth;
126  else
128 }
129 
130 int FileForceMagic(void)
131 {
132  return g_file_force_magic;
133 }
134 
135 int FileForceMd5(void)
136 {
137  return g_file_force_md5;
138 }
139 
140 int FileForceSha1(void)
141 {
142  return g_file_force_sha1;
143 }
144 
146 {
147  return g_file_force_sha256;
148 }
149 
151 {
152  g_file_force_tracking = 1;
153 }
154 
155 /**
156  * \brief Function to parse forced file hashing configuration.
157  */
159 {
160  BUG_ON(conf == NULL);
161 
162  ConfNode *forcehash_node = NULL;
163 
164  /* legacy option */
165  const char *force_md5 = ConfNodeLookupChildValue(conf, "force-md5");
166  if (force_md5 != NULL) {
167  SCLogWarning(SC_ERR_DEPRECATED_CONF, "deprecated 'force-md5' option "
168  "found. Please use 'force-hash: [md5]' instead");
169 
170  if (ConfValIsTrue(force_md5)) {
171 #ifdef HAVE_NSS
173  SCLogInfo("forcing md5 calculation for logged files");
174 #else
175  SCLogInfo("md5 calculation requires linking against libnss");
176 #endif
177  }
178  }
179 
180  if (conf != NULL)
181  forcehash_node = ConfNodeLookupChild(conf, "force-hash");
182 
183  if (forcehash_node != NULL) {
184  ConfNode *field = NULL;
185 
186  TAILQ_FOREACH(field, &forcehash_node->head, next) {
187  if (strcasecmp("md5", field->val) == 0) {
188 #ifdef HAVE_NSS
190  SCLogConfig("forcing md5 calculation for logged or stored files");
191 #else
192  SCLogInfo("md5 calculation requires linking against libnss");
193 #endif
194  }
195 
196  if (strcasecmp("sha1", field->val) == 0) {
197 #ifdef HAVE_NSS
199  SCLogConfig("forcing sha1 calculation for logged or stored files");
200 #else
201  SCLogInfo("sha1 calculation requires linking against libnss");
202 #endif
203  }
204 
205  if (strcasecmp("sha256", field->val) == 0) {
206 #ifdef HAVE_NSS
208  SCLogConfig("forcing sha256 calculation for logged or stored files");
209 #else
210  SCLogInfo("sha256 calculation requires linking against libnss");
211 #endif
212  }
213  }
214  }
215 }
216 
217 uint16_t FileFlowToFlags(const Flow *flow, uint8_t direction)
218 {
219  uint16_t flags = 0;
220 
221  if (direction == STREAM_TOSERVER) {
222  if (flow->file_flags & FLOWFILE_NO_STORE_TS) {
223  flags |= FILE_NOSTORE;
224  }
225 
226  if (flow->file_flags & FLOWFILE_NO_MAGIC_TS) {
227  flags |= FILE_NOMAGIC;
228  }
229 
230  if (flow->file_flags & FLOWFILE_NO_MD5_TS) {
231  flags |= FILE_NOMD5;
232  }
233 
234  if (flow->file_flags & FLOWFILE_NO_SHA1_TS) {
235  flags |= FILE_NOSHA1;
236  }
237 
238  if (flow->file_flags & FLOWFILE_NO_SHA256_TS) {
239  flags |= FILE_NOSHA256;
240  }
241  } else {
242  if (flow->file_flags & FLOWFILE_NO_STORE_TC) {
243  flags |= FILE_NOSTORE;
244  }
245 
246  if (flow->file_flags & FLOWFILE_NO_MAGIC_TC) {
247  flags |= FILE_NOMAGIC;
248  }
249 
250  if (flow->file_flags & FLOWFILE_NO_MD5_TC) {
251  flags |= FILE_NOMD5;
252  }
253 
254  if (flow->file_flags & FLOWFILE_NO_SHA1_TC) {
255  flags |= FILE_NOSHA1;
256  }
257 
258  if (flow->file_flags & FLOWFILE_NO_SHA256_TC) {
259  flags |= FILE_NOSHA256;
260  }
261  }
262  return flags;
263 }
264 
265 static int FileMagicSize(void)
266 {
267  /** \todo make this size configurable */
268  return 512;
269 }
270 
271 /**
272  * \brief get the size of the file data
273  *
274  * This doesn't reflect how much of the file we have in memory, just the
275  * total size of filedata so far.
276  */
277 uint64_t FileDataSize(const File *file)
278 {
279  if (file != NULL && file->sb != NULL) {
280  SCLogDebug("returning %"PRIu64,
281  file->sb->stream_offset + file->sb->buf_offset);
282  return file->sb->stream_offset + file->sb->buf_offset;
283  }
284  SCLogDebug("returning 0 (default)");
285  return 0;
286 }
287 
288 /**
289  * \brief get the size of the file
290  *
291  * This doesn't reflect how much of the file we have in memory, just the
292  * total size of file so far.
293  */
294 uint64_t FileTrackedSize(const File *file)
295 {
296  if (file != NULL) {
297  return file->size;
298  }
299  return 0;
300 }
301 
302 static int FilePruneFile(File *file)
303 {
304  SCEnter();
305 #ifdef HAVE_MAGIC
306  if (!(file->flags & FILE_NOMAGIC)) {
307  /* need magic but haven't set it yet, bail out */
308  if (file->magic == NULL)
309  SCReturnInt(0);
310  else
311  SCLogDebug("file->magic %s", file->magic);
312  } else {
313  SCLogDebug("file->flags & FILE_NOMAGIC == true");
314  }
315 #endif
316  uint64_t left_edge = file->content_stored;
317  if (file->flags & FILE_NOSTORE) {
318  left_edge = FileDataSize(file);
319  }
320  if (file->flags & FILE_USE_DETECT) {
321  left_edge = MIN(left_edge, file->content_inspected);
322  }
323 
324  if (left_edge) {
325  StreamingBufferSlideToOffset(file->sb, left_edge);
326  }
327 
328  if (left_edge != FileDataSize(file)) {
329  SCReturnInt(0);
330  }
331 
332  SCLogDebug("file->state %d. Is >= FILE_STATE_CLOSED: %s", file->state, (file->state >= FILE_STATE_CLOSED) ? "yes" : "no");
333 
334  /* file is done when state is closed+, logging/storing is done (if any) */
335  if (file->state >= FILE_STATE_CLOSED &&
336  (!RunModeOutputFileEnabled() || (file->flags & FILE_LOGGED)) &&
338  {
339  SCReturnInt(1);
340  } else {
341  SCReturnInt(0);
342  }
343 }
344 
346 {
347  File *file = ffc->head;
348  File *prev = NULL;
349 
350  while (file) {
351  if (FilePruneFile(file) == 0) {
352  prev = file;
353  file = file->next;
354  continue;
355  }
356 
357  SCLogDebug("removing file %p", file);
358 
359  File *file_next = file->next;
360 
361  if (prev)
362  prev->next = file_next;
363  /* update head and tail */
364  if (file == ffc->head)
365  ffc->head = file_next;
366  if (file == ffc->tail)
367  ffc->tail = prev;
368 
369  FileFree(file);
370  file = file_next;
371  }
372 }
373 
374 /**
375  * \brief allocate a FileContainer
376  *
377  * \retval new newly allocated FileContainer
378  * \retval NULL error
379  */
381 {
382  FileContainer *new = SCMalloc(sizeof(FileContainer));
383  if (unlikely(new == NULL)) {
384  SCLogError(SC_ERR_MEM_ALLOC, "Error allocating mem");
385  return NULL;
386  }
387  memset(new, 0, sizeof(FileContainer));
388  new->head = new->tail = NULL;
389  return new;
390 }
391 
392 /**
393  * \brief Recycle a FileContainer
394  *
395  * \param ffc FileContainer
396  */
398 {
399  if (ffc == NULL)
400  return;
401 
402  File *cur = ffc->head;
403  File *next = NULL;
404  for (;cur != NULL; cur = next) {
405  next = cur->next;
406  FileFree(cur);
407  }
408  ffc->head = ffc->tail = NULL;
409 }
410 
411 /**
412  * \brief Free a FileContainer
413  *
414  * \param ffc FileContainer
415  */
417 {
418  if (ffc == NULL)
419  return;
420 
421  File *ptr = ffc->head;
422  File *next = NULL;
423  for (;ptr != NULL; ptr = next) {
424  next = ptr->next;
425  FileFree(ptr);
426  }
427  ffc->head = ffc->tail = NULL;
428  SCFree(ffc);
429 }
430 
431 /**
432  * \brief Alloc a new File
433  *
434  * \param name character array containing the name (not a string)
435  * \param name_len length in bytes of the name
436  *
437  * \retval new File object or NULL on error
438  */
439 static File *FileAlloc(const uint8_t *name, uint16_t name_len)
440 {
441  File *new = SCMalloc(sizeof(File));
442  if (unlikely(new == NULL)) {
443  SCLogError(SC_ERR_MEM_ALLOC, "Error allocating mem");
444  return NULL;
445  }
446  memset(new, 0, sizeof(File));
447 
448  new->name = SCMalloc(name_len);
449  if (new->name == NULL) {
450  SCFree(new);
451  return NULL;
452  }
453 
454  new->name_len = name_len;
455  memcpy(new->name, name, name_len);
456 
457  new->sid_cnt = 0;
458  new->sid_max = 8;
459  /* SCMalloc() is allowed to fail here because sid well be checked later on */
460  new->sid = SCMalloc(sizeof(uint32_t) * new->sid_max);
461  if (new->sid == NULL)
462  new->sid_max = 0;
463 
464  return new;
465 }
466 
467 static void FileFree(File *ff)
468 {
469  if (ff == NULL)
470  return;
471 
472  if (ff->name != NULL)
473  SCFree(ff->name);
474  if (ff->sid != NULL)
475  SCFree(ff->sid);
476 #ifdef HAVE_MAGIC
477  /* magic returned by libmagic is strdup'd by MagicLookup. */
478  if (ff->magic != NULL)
479  SCFree(ff->magic);
480 #endif
481  if (ff->sb != NULL) {
482  StreamingBufferFree(ff->sb);
483  }
484 
485 #ifdef HAVE_NSS
486  if (ff->md5_ctx)
487  HASH_Destroy(ff->md5_ctx);
488  if (ff->sha1_ctx)
489  HASH_Destroy(ff->sha1_ctx);
490  if (ff->sha256_ctx)
491  HASH_Destroy(ff->sha256_ctx);
492 #endif
493  SCFree(ff);
494 }
495 
497 {
498  if (ffc->head == NULL || ffc->tail == NULL) {
499  ffc->head = ffc->tail = ff;
500  } else {
501  ffc->tail->next = ff;
502  ffc->tail = ff;
503  }
504 }
505 
506 /**
507  * \brief Tag a file for storing
508  *
509  * \param ff The file to store
510  */
511 int FileStore(File *ff)
512 {
513  ff->flags |= FILE_STORE;
514  SCReturnInt(0);
515 }
516 
517 /**
518  * \brief Set the TX id for a file
519  *
520  * \param ff The file to store
521  * \param txid the tx id
522  */
523 int FileSetTx(File *ff, uint64_t txid)
524 {
525  SCLogDebug("ff %p txid %"PRIu64, ff, txid);
526  if (ff != NULL)
527  ff->txid = txid;
528  SCReturnInt(0);
529 }
530 
532 {
533  if (ffc && ffc->tail) {
534  (void)FileSetTx(ffc->tail, tx_id);
535  }
536 }
537 
538 /**
539  * \brief check if we have stored enough
540  *
541  * \param ff file
542  *
543  * \retval 0 limit not reached yet
544  * \retval 1 limit reached
545  */
546 static int FileStoreNoStoreCheck(File *ff)
547 {
548  SCEnter();
549 
550  if (ff == NULL) {
551  SCReturnInt(0);
552  }
553 
554  if (ff->flags & FILE_NOSTORE) {
555  if (ff->state == FILE_STATE_OPENED &&
556  FileDataSize(ff) >= (uint64_t)FileMagicSize())
557  {
558  SCReturnInt(1);
559  }
560  }
561 
562  SCReturnInt(0);
563 }
564 
565 static int AppendData(File *file, const uint8_t *data, uint32_t data_len)
566 {
567  if (StreamingBufferAppendNoTrack(file->sb, data, data_len) != 0) {
568  SCReturnInt(-1);
569  }
570 
571 #ifdef HAVE_NSS
572  if (file->md5_ctx) {
573  HASH_Update(file->md5_ctx, data, data_len);
574  }
575  if (file->sha1_ctx) {
576  HASH_Update(file->sha1_ctx, data, data_len);
577  }
578  if (file->sha256_ctx) {
579  HASH_Update(file->sha256_ctx, data, data_len);
580  }
581 #endif
582  SCReturnInt(0);
583 }
584 
585 /** \internal
586  * \brief Store/handle a chunk of file data in the File structure
587  *
588  * \param ff the file
589  * \param data data chunk
590  * \param data_len data chunk len
591  *
592  * \retval 0 ok
593  * \retval -1 error
594  * \retval -2 no store for this file
595  */
596 static int FileAppendDataDo(File *ff, const uint8_t *data, uint32_t data_len)
597 {
598  SCEnter();
599 #ifdef DEBUG_VALIDATION
600  BUG_ON(ff == NULL);
601 #endif
602 
603  ff->size += data_len;
604 
605  if (ff->state != FILE_STATE_OPENED) {
606  if (ff->flags & FILE_NOSTORE) {
607  SCReturnInt(-2);
608  }
609  SCReturnInt(-1);
610  }
611 
612  if (FileStoreNoStoreCheck(ff) == 1) {
613 #ifdef HAVE_NSS
614  int hash_done = 0;
615  /* no storage but forced hashing */
616  if (ff->md5_ctx) {
617  HASH_Update(ff->md5_ctx, data, data_len);
618  hash_done = 1;
619  }
620  if (ff->sha1_ctx) {
621  HASH_Update(ff->sha1_ctx, data, data_len);
622  hash_done = 1;
623  }
624  if (ff->sha256_ctx) {
625  HASH_Update(ff->sha256_ctx, data, data_len);
626  hash_done = 1;
627  }
628 
629  if (hash_done)
630  SCReturnInt(0);
631 #endif
632  if (g_file_force_tracking || (!(ff->flags & FILE_NOTRACK)))
633  SCReturnInt(0);
634 
636  SCLogDebug("flowfile state transitioned to FILE_STATE_TRUNCATED");
637  SCReturnInt(-2);
638  }
639 
640  SCLogDebug("appending %"PRIu32" bytes", data_len);
641 
642  int r = AppendData(ff, data, data_len);
643  if (r != 0) {
644  ff->state = FILE_STATE_ERROR;
645  SCReturnInt(r);
646  }
647 
648  SCReturnInt(0);
649 }
650 
651 /**
652  * \brief Store/handle a chunk of file data in the File structure
653  * The last file in the FileContainer will be used.
654  *
655  * \param ffc FileContainer used to append to
656  * \param data data chunk
657  * \param data_len data chunk len
658  *
659  * \retval 0 ok
660  * \retval -1 error
661  * \retval -2 no store for this file
662  */
663 int FileAppendData(FileContainer *ffc, const uint8_t *data, uint32_t data_len)
664 {
665  SCEnter();
666 
667  if (ffc == NULL || ffc->tail == NULL || data == NULL || data_len == 0) {
668  SCReturnInt(-1);
669  }
670  int r = FileAppendDataDo(ffc->tail, data, data_len);
671  SCReturnInt(r);
672 }
673 
674 /**
675  * \brief Store/handle a chunk of file data in the File structure
676  * The file with 'track_id' in the FileContainer will be used.
677  *
678  * \param ffc FileContainer used to append to
679  * \param track_id id to lookup the file
680  * \param data data chunk
681  * \param data_len data chunk len
682  *
683  * \retval 0 ok
684  * \retval -1 error
685  * \retval -2 no store for this file
686  */
687 int FileAppendDataById(FileContainer *ffc, uint32_t track_id,
688  const uint8_t *data, uint32_t data_len)
689 {
690  SCEnter();
691 
692  if (ffc == NULL || ffc->tail == NULL || data == NULL || data_len == 0) {
693  SCReturnInt(-1);
694  }
695  File *ff = ffc->head;
696  for ( ; ff != NULL; ff = ff->next) {
697  if (track_id == ff->file_track_id) {
698  int r = FileAppendDataDo(ff, data, data_len);
699  SCReturnInt(r);
700  }
701  }
702  SCReturnInt(-1);
703 }
704 
705 /**
706  * \brief Store/handle a chunk of file data in the File structure
707  * The file with 'track_id' in the FileContainer will be used.
708  *
709  * \param ffc FileContainer used to append to
710  * \param track_id id to lookup the file
711  * \param data data chunk
712  * \param data_len data chunk len
713  *
714  * \retval 0 ok
715  * \retval -1 error
716  * \retval -2 no store for this file
717  */
718 int FileAppendGAPById(FileContainer *ffc, uint32_t track_id,
719  const uint8_t *data, uint32_t data_len)
720 {
721  SCEnter();
722 
723  if (ffc == NULL || ffc->tail == NULL || data == NULL || data_len == 0) {
724  SCReturnInt(-1);
725  }
726  File *ff = ffc->head;
727  for ( ; ff != NULL; ff = ff->next) {
728  if (track_id == ff->file_track_id) {
729  ff->flags |= FILE_HAS_GAPS;
732  SCLogDebug("FILE_HAS_GAPS set");
733 
734  int r = FileAppendDataDo(ff, data, data_len);
735  SCReturnInt(r);
736  }
737  }
738  SCReturnInt(-1);
739 }
740 
741 /**
742  * \brief Sets the offset range for a file.
743  *
744  * \param ffc the container
745  * \param start start offset
746  * \param end end offset
747  *
748  * \retval 0 ok
749  * \retval -1 error
750  */
751 int FileSetRange(FileContainer *ffc, uint64_t start, uint64_t end)
752 {
753  SCEnter();
754 
755  if (ffc == NULL || ffc->tail == NULL) {
756  SCReturnInt(-1);
757  }
758  ffc->tail->start = start;
759  ffc->tail->end = end;
760  SCReturnInt(0);
761 }
762 
763 /**
764  * \brief Open a new File
765  *
766  * \param ffc flow container
767  * \param sbcfg buffer config
768  * \param name filename character array
769  * \param name_len filename len
770  * \param data initial data
771  * \param data_len initial data len
772  * \param flags open flags
773  *
774  * \retval ff flowfile object
775  *
776  * \note filename is not a string, so it's not nul terminated.
777  */
778 static File *FileOpenFile(FileContainer *ffc, const StreamingBufferConfig *sbcfg,
779  const uint8_t *name, uint16_t name_len,
780  const uint8_t *data, uint32_t data_len, uint16_t flags)
781 {
782  SCEnter();
783 
784  //PrintRawDataFp(stdout, name, name_len);
785 
786  File *ff = FileAlloc(name, name_len);
787  if (ff == NULL) {
788  SCReturnPtr(NULL, "File");
789  }
790 
791  ff->sb = StreamingBufferInit(sbcfg);
792  if (ff->sb == NULL) {
793  FileFree(ff);
794  SCReturnPtr(NULL, "File");
795  }
796  SCLogDebug("ff->sb %p", ff->sb);
797 
798  if (flags & FILE_STORE || g_file_force_filestore) {
799  FileStore(ff);
800  } else if (flags & FILE_NOSTORE) {
801  SCLogDebug("not storing this file");
802  ff->flags |= FILE_NOSTORE;
803  }
804  if (flags & FILE_NOMAGIC) {
805  SCLogDebug("not doing magic for this file");
806  ff->flags |= FILE_NOMAGIC;
807  }
808  if (flags & FILE_NOMD5) {
809  SCLogDebug("not doing md5 for this file");
810  ff->flags |= FILE_NOMD5;
811  }
812  if (flags & FILE_NOSHA1) {
813  SCLogDebug("not doing sha1 for this file");
814  ff->flags |= FILE_NOSHA1;
815  }
816  if (flags & FILE_NOSHA256) {
817  SCLogDebug("not doing sha256 for this file");
818  ff->flags |= FILE_NOSHA256;
819  }
820  if (flags & FILE_USE_DETECT) {
821  SCLogDebug("considering content_inspect tracker when pruning");
822  ff->flags |= FILE_USE_DETECT;
823  }
824 
825 #ifdef HAVE_NSS
826  if (!(ff->flags & FILE_NOMD5) || g_file_force_md5) {
827  ff->md5_ctx = HASH_Create(HASH_AlgMD5);
828  if (ff->md5_ctx != NULL) {
829  HASH_Begin(ff->md5_ctx);
830  }
831  }
832  if (!(ff->flags & FILE_NOSHA1) || g_file_force_sha1) {
833  ff->sha1_ctx = HASH_Create(HASH_AlgSHA1);
834  if (ff->sha1_ctx != NULL) {
835  HASH_Begin(ff->sha1_ctx);
836  }
837  }
838  if (!(ff->flags & FILE_NOSHA256) || g_file_force_sha256) {
839  ff->sha256_ctx = HASH_Create(HASH_AlgSHA256);
840  if (ff->sha256_ctx != NULL) {
841  HASH_Begin(ff->sha256_ctx);
842  }
843  }
844 #endif
845 
846  ff->state = FILE_STATE_OPENED;
847  SCLogDebug("flowfile state transitioned to FILE_STATE_OPENED");
848 
849  ff->fd = -1;
850 
851  FileContainerAdd(ffc, ff);
852 
853  if (data != NULL) {
854  ff->size += data_len;
855  if (AppendData(ff, data, data_len) != 0) {
856  ff->state = FILE_STATE_ERROR;
857  SCReturnPtr(NULL, "File");
858  }
859  SCLogDebug("file size is now %"PRIu64, FileTrackedSize(ff));
860  }
861 
862  SCReturnPtr(ff, "File");
863 }
864 
865 /**
866  * \retval 0 ok
867  * \retval -1 failed */
869  uint32_t track_id, const uint8_t *name, uint16_t name_len,
870  const uint8_t *data, uint32_t data_len, uint16_t flags)
871 {
872  File *ff = FileOpenFile(ffc, sbcfg, name, name_len, data, data_len, flags);
873  if (ff == NULL)
874  return -1;
875 
876  ff->file_track_id = track_id;
877  ff->flags |= FILE_USE_TRACKID;
878  return 0;
879 }
880 
881 int FileCloseFilePtr(File *ff, const uint8_t *data,
882  uint32_t data_len, uint16_t flags)
883 {
884  SCEnter();
885 
886  if (ff == NULL) {
887  SCReturnInt(-1);
888  }
889 
890  if (ff->state != FILE_STATE_OPENED) {
891  SCReturnInt(-1);
892  }
893 
894  if (data != NULL) {
895  ff->size += data_len;
896  if (ff->flags & FILE_NOSTORE) {
897 #ifdef HAVE_NSS
898  /* no storage but hashing */
899  if (ff->md5_ctx)
900  HASH_Update(ff->md5_ctx, data, data_len);
901  if (ff->sha1_ctx)
902  HASH_Update(ff->sha1_ctx, data, data_len);
903  if (ff->sha256_ctx)
904  HASH_Update(ff->sha256_ctx, data, data_len);
905 #endif
906  } else {
907  if (AppendData(ff, data, data_len) != 0) {
908  ff->state = FILE_STATE_ERROR;
909  SCReturnInt(-1);
910  }
911  }
912  }
913 
914  if ((flags & FILE_TRUNCATED) || (ff->flags & FILE_HAS_GAPS)) {
916  SCLogDebug("flowfile state transitioned to FILE_STATE_TRUNCATED");
917 
918  if (flags & FILE_NOSTORE) {
919  SCLogDebug("not storing this file");
920  ff->flags |= FILE_NOSTORE;
921  } else {
922 #ifdef HAVE_NSS
923  if (g_file_force_sha256 && ff->sha256_ctx) {
924  FileEndSha256(ff);
925  }
926 #endif
927  }
928  } else {
929  ff->state = FILE_STATE_CLOSED;
930  SCLogDebug("flowfile state transitioned to FILE_STATE_CLOSED");
931 
932 #ifdef HAVE_NSS
933  if (ff->md5_ctx) {
934  unsigned int len = 0;
935  HASH_End(ff->md5_ctx, ff->md5, &len, sizeof(ff->md5));
936  ff->flags |= FILE_MD5;
937  }
938  if (ff->sha1_ctx) {
939  unsigned int len = 0;
940  HASH_End(ff->sha1_ctx, ff->sha1, &len, sizeof(ff->sha1));
941  ff->flags |= FILE_SHA1;
942  }
943  if (ff->sha256_ctx) {
944  FileEndSha256(ff);
945  }
946 #endif
947  }
948 
949  SCReturnInt(0);
950 }
951 
952 /**
953  * \brief Close a File
954  *
955  * \param ffc the container
956  * \param data final data if any
957  * \param data_len data len if any
958  * \param flags flags
959  *
960  * \retval 0 ok
961  * \retval -1 error
962  */
963 int FileCloseFile(FileContainer *ffc, const uint8_t *data,
964  uint32_t data_len, uint16_t flags)
965 {
966  SCEnter();
967 
968  if (ffc == NULL || ffc->tail == NULL) {
969  SCReturnInt(-1);
970  }
971 
972  if (FileCloseFilePtr(ffc->tail, data, data_len, flags) == -1) {
973  SCReturnInt(-1);
974  }
975 
976  SCReturnInt(0);
977 }
978 
979 int FileCloseFileById(FileContainer *ffc, uint32_t track_id,
980  const uint8_t *data, uint32_t data_len, uint16_t flags)
981 {
982  SCEnter();
983 
984  if (ffc == NULL || ffc->tail == NULL) {
985  SCReturnInt(-1);
986  }
987 
988  File *ff = ffc->head;
989  for ( ; ff != NULL; ff = ff->next) {
990  if (track_id == ff->file_track_id) {
991  int r = FileCloseFilePtr(ff, data, data_len, flags);
992  SCReturnInt(r);
993  }
994  }
995  SCReturnInt(-1);
996 }
997 
998 /**
999  * \brief disable file storage for a flow
1000  *
1001  * \param f *LOCKED* flow
1002  * \param direction flow direction
1003  */
1004 void FileDisableStoring(Flow *f, uint8_t direction)
1005 {
1006  File *ptr = NULL;
1007 
1008  SCEnter();
1009 
1011 
1012  if (direction == STREAM_TOSERVER)
1014  else
1016 
1017  FileContainer *ffc = AppLayerParserGetFiles(f->proto, f->alproto, f->alstate, direction);
1018  if (ffc != NULL) {
1019  for (ptr = ffc->head; ptr != NULL; ptr = ptr->next) {
1020  /* if we're already storing, we'll continue */
1021  if (!(ptr->flags & FILE_STORE)) {
1022  SCLogDebug("not storing this file");
1023  ptr->flags |= FILE_NOSTORE;
1024  }
1025  }
1026  }
1027  SCReturn;
1028 }
1029 
1030 /**
1031  * \brief disable file magic lookups for this flow
1032  *
1033  * \param f *LOCKED* flow
1034  * \param direction flow direction
1035  */
1036 void FileDisableMagic(Flow *f, uint8_t direction)
1037 {
1038  File *ptr = NULL;
1039 
1040  SCEnter();
1041 
1043 
1044  if (direction == STREAM_TOSERVER)
1046  else
1048 
1049  FileContainer *ffc = AppLayerParserGetFiles(f->proto, f->alproto, f->alstate, direction);
1050  if (ffc != NULL) {
1051  for (ptr = ffc->head; ptr != NULL; ptr = ptr->next) {
1052  SCLogDebug("disabling magic for file %p from direction %s",
1053  ptr, direction == STREAM_TOSERVER ? "toserver":"toclient");
1054  ptr->flags |= FILE_NOMAGIC;
1055  }
1056  }
1057 
1058  SCReturn;
1059 }
1060 
1061 /**
1062  * \brief disable file md5 calc for this flow
1063  *
1064  * \param f *LOCKED* flow
1065  * \param direction flow direction
1066  */
1067 void FileDisableMd5(Flow *f, uint8_t direction)
1068 {
1069  File *ptr = NULL;
1070 
1071  SCEnter();
1072 
1074 
1075  if (direction == STREAM_TOSERVER)
1077  else
1079 
1080  FileContainer *ffc = AppLayerParserGetFiles(f->proto, f->alproto, f->alstate, direction);
1081  if (ffc != NULL) {
1082  for (ptr = ffc->head; ptr != NULL; ptr = ptr->next) {
1083  SCLogDebug("disabling md5 for file %p from direction %s",
1084  ptr, direction == STREAM_TOSERVER ? "toserver":"toclient");
1085  ptr->flags |= FILE_NOMD5;
1086 
1087 #ifdef HAVE_NSS
1088  /* destroy any ctx we may have so far */
1089  if (ptr->md5_ctx != NULL) {
1090  HASH_Destroy(ptr->md5_ctx);
1091  ptr->md5_ctx = NULL;
1092  }
1093 #endif
1094  }
1095  }
1096 
1097  SCReturn;
1098 }
1099 
1100 /**
1101  * \brief disable file sha1 calc for this flow
1102  *
1103  * \param f *LOCKED* flow
1104  * \param direction flow direction
1105 */
1106 void FileDisableSha1(Flow *f, uint8_t direction)
1107 {
1108  File *ptr = NULL;
1109 
1110  SCEnter();
1111 
1113 
1114  if (direction == STREAM_TOSERVER)
1116  else
1118 
1119  FileContainer *ffc = AppLayerParserGetFiles(f->proto, f->alproto, f->alstate, direction);
1120  if (ffc != NULL) {
1121  for (ptr = ffc->head; ptr != NULL; ptr = ptr->next) {
1122  SCLogDebug("disabling sha1 for file %p from direction %s",
1123  ptr, direction == STREAM_TOSERVER ? "toserver":"toclient");
1124  ptr->flags |= FILE_NOSHA1;
1125 
1126 #ifdef HAVE_NSS
1127  /* destroy any ctx we may have so far */
1128  if (ptr->sha1_ctx != NULL) {
1129  HASH_Destroy(ptr->sha1_ctx);
1130  ptr->sha1_ctx = NULL;
1131  }
1132 #endif
1133  }
1134  }
1135 
1136  SCReturn;
1137 }
1138 
1139 /**
1140  * \brief disable file sha256 calc for this flow
1141  *
1142  * \param f *LOCKED* flow
1143  * \param direction flow direction
1144  */
1145 void FileDisableSha256(Flow *f, uint8_t direction)
1146 {
1147  File *ptr = NULL;
1148 
1149  SCEnter();
1150 
1152 
1153  if (direction == STREAM_TOSERVER)
1155  else
1157 
1158  FileContainer *ffc = AppLayerParserGetFiles(f->proto, f->alproto, f->alstate, direction);
1159  if (ffc != NULL) {
1160  for (ptr = ffc->head; ptr != NULL; ptr = ptr->next) {
1161  SCLogDebug("disabling sha256 for file %p from direction %s",
1162  ptr, direction == STREAM_TOSERVER ? "toserver":"toclient");
1163  ptr->flags |= FILE_NOSHA256;
1164 
1165 #ifdef HAVE_NSS
1166  /* destroy any ctx we may have so far */
1167  if (ptr->sha256_ctx != NULL) {
1168  HASH_Destroy(ptr->sha256_ctx);
1169  ptr->sha256_ctx = NULL;
1170  }
1171 #endif
1172  }
1173  }
1174 
1175  SCReturn;
1176 }
1177 
1178 /**
1179  * \brief disable file size tracking for this flow
1180  *
1181  * \param f *LOCKED* flow
1182  * \param direction flow direction
1183  */
1184 void FileDisableFilesize(Flow *f, uint8_t direction)
1185 {
1186  File *ptr = NULL;
1187 
1188  SCEnter();
1189 
1191 
1192  if (direction == STREAM_TOSERVER)
1194  else
1196 
1197  FileContainer *ffc = AppLayerParserGetFiles(f->proto, f->alproto, f->alstate, direction);
1198  if (ffc != NULL) {
1199  for (ptr = ffc->head; ptr != NULL; ptr = ptr->next) {
1200  SCLogDebug("disabling size tracking for file %p from direction %s",
1201  ptr, direction == STREAM_TOSERVER ? "toserver":"toclient");
1202  ptr->flags |= FILE_NOTRACK;
1203  }
1204  }
1205 
1206  SCReturn;
1207 }
1208 
1209 
1210 /**
1211  * \brief set no store flag, close file if needed
1212  *
1213  * \param ff file
1214  */
1215 static void FileDisableStoringForFile(File *ff)
1216 {
1217  SCEnter();
1218 
1219  if (ff == NULL) {
1220  SCReturn;
1221  }
1222 
1223  SCLogDebug("not storing this file");
1224  ff->flags |= FILE_NOSTORE;
1225 
1226  if (ff->state == FILE_STATE_OPENED && FileDataSize(ff) >= (uint64_t)FileMagicSize()) {
1227  if (g_file_force_md5 == 0 && g_file_force_sha1 == 0 && g_file_force_sha256 == 0
1228  && g_file_force_tracking == 0) {
1229  (void)FileCloseFilePtr(ff, NULL, 0,
1231  }
1232  }
1233 }
1234 
1235 /**
1236  * \brief disable file storing for files in a transaction
1237  *
1238  * \param f *LOCKED* flow
1239  * \param direction flow direction
1240  * \param tx_id transaction id
1241  */
1242 void FileDisableStoringForTransaction(Flow *f, uint8_t direction, uint64_t tx_id)
1243 {
1244  File *ptr = NULL;
1245 
1247 
1248  SCEnter();
1249 
1250  FileContainer *ffc = AppLayerParserGetFiles(f->proto, f->alproto, f->alstate, direction);
1251  if (ffc != NULL) {
1252  for (ptr = ffc->head; ptr != NULL; ptr = ptr->next) {
1253  if (ptr->txid == tx_id) {
1254  if (ptr->flags & FILE_STORE) {
1255  /* weird, already storing -- let it continue*/
1256  SCLogDebug("file is already being stored");
1257  } else {
1258  FileDisableStoringForFile(ptr);
1259  }
1260  }
1261  }
1262  }
1263 
1264  SCReturn;
1265 }
1266 
1267 /**
1268  * \brief flag a file with id "file_id" to be stored.
1269  *
1270  * \param fc file store
1271  * \param file_id the file's id
1272  */
1273 void FileStoreFileById(FileContainer *fc, uint32_t file_id)
1274 {
1275  File *ptr = NULL;
1276 
1277  SCEnter();
1278 
1279  if (fc != NULL) {
1280  for (ptr = fc->head; ptr != NULL; ptr = ptr->next) {
1281  if (ptr->file_track_id == file_id) {
1282  FileStore(ptr);
1283  }
1284  }
1285  }
1286 }
1287 
1289 {
1290  File *ptr = NULL;
1291 
1292  SCEnter();
1293 
1294  if (fc != NULL) {
1295  for (ptr = fc->head; ptr != NULL; ptr = ptr->next) {
1296  if (ptr->txid == tx_id) {
1297  FileStore(ptr);
1298  }
1299  }
1300  }
1301 }
1302 
1304 {
1305  File *ptr = NULL;
1306 
1307  SCEnter();
1308 
1309  if (fc != NULL) {
1310  for (ptr = fc->head; ptr != NULL; ptr = ptr->next) {
1311  FileStore(ptr);
1312  }
1313  }
1314 }
1315 
1317 {
1318  File *ptr = NULL;
1319 
1320  SCEnter();
1321 
1322  if (fc != NULL) {
1323  for (ptr = fc->head; ptr != NULL; ptr = ptr->next) {
1324  if (ptr->state == FILE_STATE_OPENED) {
1325  FileCloseFilePtr(ptr, NULL, 0, FILE_TRUNCATED);
1326  }
1327  }
1328  }
1329 }
1330 
1331 /**
1332  * \brief Finish the SHA256 calculation.
1333  */
1334 #ifdef HAVE_NSS
1335 static void FileEndSha256(File *ff)
1336 {
1337  if (!(ff->flags & FILE_SHA256) && ff->sha256_ctx) {
1338  unsigned int len = 0;
1339  HASH_End(ff->sha256_ctx, ff->sha256, &len, sizeof(ff->sha256));
1340  ff->flags |= FILE_SHA256;
1341  }
1342 }
1343 #endif
uint16_t flags
void FileDisableStoringForTransaction(Flow *f, uint8_t direction, uint64_t tx_id)
disable file storing for files in a transaction
Definition: util-file.c:1242
#define SCLogDebug(...)
Definition: util-debug.h:335
StreamingBuffer * StreamingBufferInit(const StreamingBufferConfig *cfg)
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:350
struct HtpBodyChunk_ * next
int FileForceSha256(void)
Definition: util-file.c:145
TcpStreamCnf stream_config
Definition: stream-tcp.h:106
#define BUG_ON(x)
uint8_t proto
Definition: flow.h:344
FileContainer * FileContainerAlloc(void)
allocate a FileContainer
Definition: util-file.c:380
#define FLOWFILE_NO_SHA256_TS
Definition: flow.h:126
int RunModeOutputFileEnabled(void)
Definition: runmodes.c:481
#define unlikely(expr)
Definition: util-optimize.h:35
#define FILE_SHA256
Definition: util-file.h:43
uint64_t size
Definition: util-file.h:91
void FileDisableFilesize(Flow *f, uint8_t direction)
disable file size tracking for this flow
Definition: util-file.c:1184
void FileDisableSha1(Flow *f, uint8_t direction)
disable file sha1 calc for this flow
Definition: util-file.c:1106
void FileDisableMd5(Flow *f, uint8_t direction)
disable file md5 calc for this flow
Definition: util-file.c:1067
uint64_t FileDataSize(const File *file)
get the size of the file data
Definition: util-file.c:277
#define FILE_NOTRACK
Definition: util-file.h:48
#define MIN(x, y)
uint64_t content_inspected
Definition: util-file.h:88
#define FILE_STORE
Definition: util-file.h:46
#define FILE_NOMAGIC
Definition: util-file.h:37
int fd
Definition: util-file.h:73
char * val
Definition: conf.h:34
void FileContainerSetTx(FileContainer *ffc, uint64_t tx_id)
Definition: util-file.c:531
ConfNode * ConfNodeLookupChild(const ConfNode *node, const char *name)
Lookup a child configuration node by name.
Definition: conf.c:815
struct File_ * next
Definition: util-file.h:79
int FileCloseFileById(FileContainer *ffc, uint32_t track_id, const uint8_t *data, uint32_t data_len, uint16_t flags)
Definition: util-file.c:979
void FileReassemblyDepthEnable(uint32_t size)
Definition: util-file.c:116
StreamingBuffer * sb
Definition: util-file.h:68
void FileForceSha1Enable(void)
Definition: util-file.c:101
int FileForceMd5(void)
Definition: util-file.c:135
#define FILE_NOSHA1
Definition: util-file.h:40
void FileForceTrackingEnable(void)
Definition: util-file.c:150
uint64_t start
Definition: util-file.h:92
#define FLOWFILE_NO_MAGIC_TS
Definition: flow.h:111
uint32_t FileReassemblyDepth(void)
Definition: util-file.c:122
void * alstate
Definition: flow.h:438
#define FLOWFILE_NO_MD5_TS
Definition: flow.h:118
void StreamingBufferFree(StreamingBuffer *sb)
#define FILE_LOGGED
Definition: util-file.h:44
#define FLOWFILE_NO_MAGIC_TC
Definition: flow.h:112
#define FILE_USE_TRACKID
Definition: util-file.h:50
const char * ConfNodeLookupChildValue(const ConfNode *node, const char *name)
Lookup the value of a child configuration node by name.
Definition: conf.c:843
int FileStore(File *ff)
Tag a file for storing.
Definition: util-file.c:511
uint16_t flags
Definition: util-file.h:65
void FileStoreAllFilesForTx(FileContainer *fc, uint64_t tx_id)
Definition: util-file.c:1288
#define FLOWFILE_NO_SIZE_TS
Definition: flow.h:130
uint64_t end
Definition: util-file.h:93
uint32_t * sid
Definition: util-file.h:95
void FileStoreFileById(FileContainer *fc, uint32_t file_id)
flag a file with id "file_id" to be stored.
Definition: util-file.c:1273
void FileDisableMagic(Flow *f, uint8_t direction)
disable file magic lookups for this flow
Definition: util-file.c:1036
void StreamingBufferSlideToOffset(StreamingBuffer *sb, uint64_t offset)
slide to absolute offset
#define FILE_HAS_GAPS
Definition: util-file.h:51
#define SCLogError(err_code,...)
Macro used to log ERROR messages.
Definition: util-debug.h:294
void FileForceHashParseCfg(ConfNode *conf)
Function to parse forced file hashing configuration.
Definition: util-file.c:158
void FileContainerFree(FileContainer *ffc)
Free a FileContainer.
Definition: util-file.c:416
void FileForceMagicEnable(void)
Definition: util-file.c:91
#define DEBUG_ASSERT_FLOW_LOCKED(f)
uint64_t txid
Definition: util-file.h:69
#define SCEnter(...)
Definition: util-debug.h:337
int FileSetRange(FileContainer *ffc, uint64_t start, uint64_t end)
Sets the offset range for a file.
Definition: util-file.c:751
#define FLOWFILE_NO_MD5_TC
Definition: flow.h:119
void FileForceFilestoreEnable(void)
Definition: util-file.c:86
void FileDisableStoring(Flow *f, uint8_t direction)
disable file storage for a flow
Definition: util-file.c:1004
#define SCReturnInt(x)
Definition: util-debug.h:341
#define FILE_MD5
Definition: util-file.h:39
void FilePrune(FileContainer *ffc)
Definition: util-file.c:345
void FileStoreAllFiles(FileContainer *fc)
Definition: util-file.c:1303
#define SCLogWarning(err_code,...)
Macro used to log WARNING messages.
Definition: util-debug.h:281
uint32_t reassembly_depth
Definition: stream-tcp.h:60
int ConfValIsTrue(const char *val)
Check if a value is true.
Definition: conf.c:566
#define FILE_SHA1
Definition: util-file.h:41
int FileForceFilestore(void)
Definition: util-file.c:111
int FileForceMagic(void)
Definition: util-file.c:130
#define FILE_STORED
Definition: util-file.h:47
Definition: conf.h:32
#define FILE_NOSHA256
Definition: util-file.h:42
#define SCMalloc(a)
Definition: util-mem.h:222
int FileAppendGAPById(FileContainer *ffc, uint32_t track_id, const uint8_t *data, uint32_t data_len)
Store/handle a chunk of file data in the File structure The file with &#39;track_id&#39; in the FileContainer...
Definition: util-file.c:718
#define FILE_USE_DETECT
Definition: util-file.h:49
void FileContainerAdd(FileContainer *ffc, File *ff)
Definition: util-file.c:496
void FileForceSha256Enable(void)
Definition: util-file.c:106
int RunModeOutputFiledataEnabled(void)
Definition: runmodes.c:486
#define SCLogInfo(...)
Macro used to log INFORMATIONAL messages.
Definition: util-debug.h:254
void FileContainerRecycle(FileContainer *ffc)
Recycle a FileContainer.
Definition: util-file.c:397
#define SCFree(a)
Definition: util-mem.h:322
#define FLOWFILE_NO_SHA1_TS
Definition: flow.h:122
#define FLOWFILE_NO_STORE_TS
Definition: flow.h:115
uint16_t tx_id
#define FLOWFILE_NO_SIZE_TC
Definition: flow.h:131
#define STREAM_TOSERVER
Definition: stream.h:31
#define SCReturnPtr(x, type)
Definition: util-debug.h:353
FileState state
Definition: util-file.h:67
int FileOpenFileWithId(FileContainer *ffc, const StreamingBufferConfig *sbcfg, uint32_t track_id, const uint8_t *name, uint16_t name_len, const uint8_t *data, uint32_t data_len, uint16_t flags)
Open a new File.
Definition: util-file.c:868
int StreamingBufferAppendNoTrack(StreamingBuffer *sb, const uint8_t *data, uint32_t data_len)
add data w/o tracking a segment
int FileCloseFile(FileContainer *ffc, const uint8_t *data, uint32_t data_len, uint16_t flags)
Close a File.
Definition: util-file.c:963
int FileSetTx(File *ff, uint64_t txid)
Set the TX id for a file.
Definition: util-file.c:523
uint16_t FileFlowToFlags(const Flow *flow, uint8_t direction)
Definition: util-file.c:217
uint64_t content_stored
Definition: util-file.h:90
uint32_t file_track_id
Definition: util-file.h:70
#define FILE_TRUNCATED
Definition: util-file.h:36
int FileForceSha1(void)
Definition: util-file.c:140
int FileAppendDataById(FileContainer *ffc, uint32_t track_id, const uint8_t *data, uint32_t data_len)
Store/handle a chunk of file data in the File structure The file with &#39;track_id&#39; in the FileContainer...
Definition: util-file.c:687
uint64_t FileTrackedSize(const File *file)
get the size of the file
Definition: util-file.c:294
void FileForceMd5Enable(void)
Definition: util-file.c:96
#define SCReturn
Definition: util-debug.h:339
#define FLOWFILE_NO_SHA1_TC
Definition: flow.h:123
uint8_t len
void FileDisableSha256(Flow *f, uint8_t direction)
disable file sha256 calc for this flow
Definition: util-file.c:1145
uint16_t file_flags
Definition: flow.h:381
AppProto alproto
application level protocol
Definition: flow.h:409
FileContainer * AppLayerParserGetFiles(uint8_t ipproto, AppProto alproto, void *alstate, uint8_t direction)
int FileAppendData(FileContainer *ffc, const uint8_t *data, uint32_t data_len)
Store/handle a chunk of file data in the File structure The last file in the FileContainer will be us...
Definition: util-file.c:663
struct SCLogConfig_ SCLogConfig
Holds the config state used by the logging api.
#define FLOWFILE_NO_SHA256_TC
Definition: flow.h:127
#define FILE_NOSTORE
Definition: util-file.h:45
#define FLOWFILE_NO_STORE_TC
Definition: flow.h:116
int FileCloseFilePtr(File *ff, const uint8_t *data, uint32_t data_len, uint16_t flags)
Definition: util-file.c:881
Flow data structure.
Definition: flow.h:325
uint8_t * name
Definition: util-file.h:75
void FileTruncateAllOpenFiles(FileContainer *fc)
Definition: util-file.c:1316
#define FILE_NOMD5
Definition: util-file.h:38