static int DetectFilestoreMatch (ThreadVars *, DetectEngineThreadCtx *,
Flow *, uint8_t, File *, const Signature *, const SigMatchCtx *);
+static int DetectFilestorePostMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx,
+ Packet *p, const Signature *s, const SigMatchCtx *ctx);
static int DetectFilestoreSetup (DetectEngineCtx *, Signature *, const char *);
static void DetectFilestoreFree(void *);
static void DetectFilestoreRegisterTests(void);
sigmatch_table[DETECT_FILESTORE].RegisterTests = DetectFilestoreRegisterTests;
sigmatch_table[DETECT_FILESTORE].flags = SIGMATCH_OPTIONAL_OPT;
+ sigmatch_table[DETECT_FILESTORE_POSTMATCH].name = "__filestore__postmatch__";
+ sigmatch_table[DETECT_FILESTORE_POSTMATCH].Match = DetectFilestorePostMatch;
+ sigmatch_table[DETECT_FILESTORE_POSTMATCH].Free = DetectFilestoreFree;
+
DetectSetupParseRegexes(PARSE_REGEX, &parse_regex, &parse_regex_study);
g_file_match_list_id = DetectBufferTypeRegister("files");
* When we are sure all parts of the signature matched, we run this function
* to finalize the filestore.
*/
-int DetectFilestorePostMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet *p, const Signature *s)
+static int DetectFilestorePostMatch(ThreadVars *t, DetectEngineThreadCtx *det_ctx,
+ Packet *p, const Signature *s, const SigMatchCtx *ctx)
{
uint8_t flags = 0;
/* filestore for single files only */
if (s->filestore_ctx == NULL) {
- uint16_t u;
- for (u = 0; u < det_ctx->filestore_cnt; u++) {
+ for (uint16_t u = 0; u < det_ctx->filestore_cnt; u++) {
FileStoreFileById(ffc, det_ctx->filestore[u].file_id);
}
} else {
- uint16_t u;
-
- for (u = 0; u < det_ctx->filestore_cnt; u++) {
+ for (uint16_t u = 0; u < det_ctx->filestore_cnt; u++) {
FilestorePostMatchWithOptions(p, p->flow, s->filestore_ctx, ffc,
det_ctx->filestore[u].file_id, det_ctx->filestore[u].tx_id);
}
SigMatchAppendSMToList(s, sm, g_file_match_list_id);
s->filestore_ctx = (const DetectFilestoreData *)sm->ctx;
+ sm = SigMatchAlloc();
+ if (unlikely(sm == NULL))
+ goto error;
+ sm->type = DETECT_FILESTORE_POSTMATCH;
+ sm->ctx = NULL;
+ SigMatchAppendSMToList(s, sm, DETECT_SM_LIST_POSTMATCH);
+
+
s->flags |= SIG_FLAG_FILESTORE;
return 0;