+88
+-- tweaked allocation of pmd.last_check
+
87
-- renamed api function typedefs to camel case for consistency and to match
style guide
* option via the content option processing since only not
* contents that are not relative in any way will have this
* flag set */
- if (dup_content_option_data.exception_flag)
+ if (dup_content_option_data.last_check)
{
PmdLastCheck* last_check =
dup_content_option_data.last_check + get_instance_id();
PMX *neg_pmx = (PMX *)ncl->pmx;
PatternMatchData *neg_pmd = (PatternMatchData *)neg_pmx->PatternMatchData;
+ assert(neg_pmd->last_check);
+
PmdLastCheck* last_check =
neg_pmd->last_check + get_instance_id();
last_check->ts.tv_sec = eval_data.p->pkth->ts.tv_sec;
last_check->ts.tv_usec = eval_data.p->pkth->ts.tv_usec;
- last_check->packet_number = (rule_eval_pkt_count + (PacketManager::get_rebuilt_packet_count()));
+ last_check->packet_number = (rule_eval_pkt_count
+ + (PacketManager::get_rebuilt_packet_count()));
last_check->rebuild_flag = (eval_data.p->packet_flags & PKT_REBUILT_STREAM);
}
// private helpers
//-------------------------------------------------------------------------
-static PatternMatchData* NewNode()
+static PatternMatchData* new_pmd()
{
PatternMatchData *pmd = (PatternMatchData*)SnortAlloc(sizeof(PatternMatchData));
- pmd->last_check = (PmdLastCheck*)SnortAlloc(get_instance_max() * sizeof(*pmd->last_check));
/* Set any non-zero default values here. */
pmd->offset_var = BYTE_EXTRACT_NO_VAR;
return pmd;
}
+static void update_pmd(PatternMatchData* pmd)
+{
+ if ( pmd->exception_flag )
+ pmd->last_check = (PmdLastCheck*)SnortAlloc(get_instance_max() * sizeof(*pmd->last_check));
+}
+
static int HasFastPattern(OptTreeNode *otn, int list_type)
{
OptFpList* fpl = otn ? otn->opt_func : nullptr;
* return 0 for not found
* return -1 for error (search out of bounds)
*/
+// FIXIT PMD
static int uniSearchReal(const char *data, int dlen, PatternMatchData *pmd, int nocase)
{
/*
return 1;
}
+// FIXIT PMD
//-------------------------------------------------------------------------
// suboption handlers
int opt_len = 0;
char *next_opt;
- pmd = NewNode();
+ pmd = new_pmd();
if (!data)
ParseError("No content pattern specified!");
opt_data = PayloadExtractParameter(data_dup, &opt_len);
content_parse(opt_data, pmd);
+ update_pmd(pmd);
next_opt = opt_data + opt_len;
pmd->http_buffer = HTTP_BUFFER_NONE;
int* replace_depth; /* >=0 is offset to start of replace */
- // FIXIT last_check REALLY shouldn't be in the PMD
+ // FIXIT wasting some memory here:
// - this is not used by content option logic directly
// - and only used on current eval (not across packets)
- // so wasting a lot memory
+ // (partly mitigated by only allocating if excpetion_flag is set)
+ //
/* Set if fast pattern matcher found a content in the packet,
but the rule option specifies a negated content. Only
applies to negative contents that are not relative */