util-file: change file size computation

The file size returned by FileSize is invalid if file store is not
used so we introduce a new size field in File structure that is used
to store the size.
pull/2514/head
Eric Leblond 8 years ago
parent 187a6f392c
commit fbc2dbac28

@ -565,6 +565,8 @@ int FileAppendData(FileContainer *ffc, const uint8_t *data, uint32_t data_len)
SCReturnInt(-1);
}
ffc->tail->size += data_len;
if (ffc->tail->state != FILE_STATE_OPENED) {
if (ffc->tail->flags & FILE_NOSTORE) {
SCReturnInt(-2);
@ -699,6 +701,7 @@ File *FileOpenFile(FileContainer *ffc, const StreamingBufferConfig *sbcfg,
FileContainerAdd(ffc, ff);
if (data != NULL) {
ff->size += data_len;
if (AppendData(ff, data, data_len) != 0) {
ff->state = FILE_STATE_ERROR;
SCReturnPtr(NULL, "File");
@ -723,6 +726,7 @@ static int FileCloseFilePtr(File *ff, const uint8_t *data,
}
if (data != NULL) {
ff->size += data_len;
if (ff->flags & FILE_NOSTORE) {
#ifdef HAVE_NSS
/* no storage but hashing */

@ -82,6 +82,7 @@ typedef struct File_ {
uint64_t content_inspected; /**< used in pruning if FILE_USE_DETECT
* flag is set */
uint64_t content_stored;
uint64_t size;
} File;
typedef struct FileContainer_ {

Loading…
Cancel
Save