From: Victor Julien Date: Sun, 14 May 2017 08:00:35 +0000 (+0200) Subject: file: fix pruning for parallel files X-Git-Tag: suricata-4.0.0-beta1~81 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cd97fa80f19b58234766963569c414601901f4af;p=thirdparty%2Fsuricata.git file: fix pruning for parallel files Allow pruning of random files, not just list head. --- diff --git a/src/util-file.c b/src/util-file.c index 6f9fdf0185..3998262db3 100644 --- a/src/util-file.c +++ b/src/util-file.c @@ -343,23 +343,26 @@ static int FilePruneFile(File *file) void FilePrune(FileContainer *ffc) { File *file = ffc->head; + File *prev = NULL; while (file) { if (FilePruneFile(file) == 0) { + prev = file; file = file->next; continue; } - BUG_ON(file != ffc->head); - SCLogDebug("removing file %p", file); File *file_next = file->next; + if (prev) + prev->next = file_next; /* update head and tail */ - ffc->head = file_next; + if (file == ffc->head) + ffc->head = file_next; if (file == ffc->tail) - ffc->tail = NULL; + ffc->tail = prev; FileFree(file); file = file_next;