summaryrefslogtreecommitdiffstats
path: root/src/detect-filestore.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/detect-filestore.c')
-rw-r--r--src/detect-filestore.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/src/detect-filestore.c b/src/detect-filestore.c
index c53a93d..c905f9b 100644
--- a/src/detect-filestore.c
+++ b/src/detect-filestore.c
@@ -118,7 +118,8 @@ static int FilestorePostMatchWithOptions(Packet *p, Flow *f, const DetectFilesto
switch (filestore->direction) {
case FILESTORE_DIR_DEFAULT:
rule_dir = 1;
- break;
+ // will use both sides if scope is not default
+ // fallthrough
case FILESTORE_DIR_BOTH:
toserver_dir = 1;
toclient_dir = 1;
@@ -160,16 +161,28 @@ static int FilestorePostMatchWithOptions(Packet *p, Flow *f, const DetectFilesto
AppLayerTxData *txd = AppLayerParserGetTxData(f->proto, f->alproto, txv);
DEBUG_VALIDATE_BUG_ON(txd == NULL);
if (txd != NULL) {
- txd->file_flags |= FLOWFILE_STORE;
+ if (toclient_dir) {
+ txd->file_flags |= FLOWFILE_STORE_TC;
+ }
+ if (toserver_dir) {
+ txd->file_flags |= FLOWFILE_STORE_TS;
+ }
}
}
} else if (this_flow) {
/* set in flow and AppLayerStateData */
- f->file_flags |= FLOWFILE_STORE;
-
AppLayerStateData *sd = AppLayerParserGetStateData(f->proto, f->alproto, f->alstate);
- if (sd != NULL) {
- sd->file_flags |= FLOWFILE_STORE;
+ if (toclient_dir) {
+ f->file_flags |= FLOWFILE_STORE_TC;
+ if (sd != NULL) {
+ sd->file_flags |= FLOWFILE_STORE_TC;
+ }
+ }
+ if (toserver_dir) {
+ f->file_flags |= FLOWFILE_STORE_TS;
+ if (sd != NULL) {
+ sd->file_flags |= FLOWFILE_STORE_TS;
+ }
}
} else {
FileStoreFileById(fc, file_id);
@@ -333,6 +346,11 @@ static int DetectFilestoreSetup (DetectEngineCtx *de_ctx, Signature *s, const ch
static bool warn_not_configured = false;
static uint32_t de_version = 0;
+ if (de_ctx->filestore_cnt == UINT16_MAX) {
+ SCLogError("Cannot have more than 65535 filestore signatures");
+ return -1;
+ }
+
/* Check on first-time loads (includes following a reload) */
if (!warn_not_configured || (de_ctx->version != de_version)) {
if (de_version != de_ctx->version) {
@@ -476,6 +494,7 @@ static int DetectFilestoreSetup (DetectEngineCtx *de_ctx, Signature *s, const ch
SigMatchAppendSMToList(s, sm, DETECT_SM_LIST_POSTMATCH);
s->flags |= SIG_FLAG_FILESTORE;
+ de_ctx->filestore_cnt++;
if (match)
pcre2_match_data_free(match);