From: Anoop Saldanha Date: Fri, 22 Jun 2012 12:33:12 +0000 (+0530) Subject: byte_extract_id var now a non-global de_ctx specific var X-Git-Tag: suricata-1.3rc1~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5878d83174ba2bb17c292465b79caabc5586a076;p=thirdparty%2Fsuricata.git byte_extract_id var now a non-global de_ctx specific var --- diff --git a/src/detect-byte-extract.c b/src/detect-byte-extract.c index 2098b67ce5..8bbbb295cf 100644 --- a/src/detect-byte-extract.c +++ b/src/detect-byte-extract.c @@ -89,8 +89,6 @@ static pcre *parse_regex; static pcre_extra *parse_regex_study; -int byte_extract_max_local_id = 0; - int DetectByteExtractMatch(ThreadVars *, DetectEngineThreadCtx *, Packet *, Signature *, SigMatch *); int DetectByteExtractSetup(DetectEngineCtx *, Signature *, char *); @@ -568,8 +566,8 @@ int DetectByteExtractSetup(DetectEngineCtx *de_ctx, Signature *s, char *arg) } else { bed->local_id = ((DetectByteExtractData *)prev_bed_sm->ctx)->local_id + 1; } - if (bed->local_id > byte_extract_max_local_id) - byte_extract_max_local_id = bed->local_id; + if (bed->local_id > de_ctx->byte_extract_max_local_id) + de_ctx->byte_extract_max_local_id = bed->local_id; /* check bytetest modifiers against the signature alproto. In case they conflict * chuck out invalid signature */ diff --git a/src/detect-byte-extract.h b/src/detect-byte-extract.h index 3dbc39a669..eb889d7384 100644 --- a/src/detect-byte-extract.h +++ b/src/detect-byte-extract.h @@ -59,9 +59,6 @@ typedef struct DetectByteExtractData_ { } DetectByteExtractData; -/* the max local id used amongst all sigs */ -extern int byte_extract_max_local_id; - void DetectByteExtractRegister(void); int DetectByteExtractSetup(DetectEngineCtx *, Signature *, char *); void DetectByteExtractFree(void *); diff --git a/src/detect-engine.c b/src/detect-engine.c index a35eb14482..46cea5db28 100644 --- a/src/detect-engine.c +++ b/src/detect-engine.c @@ -453,7 +453,7 @@ TmEcode DetectEngineThreadCtxInit(ThreadVars *tv, void *initdata, void **data) { /* this detection engine context belongs to this thread instance */ det_ctx->tv = tv; - det_ctx->bj_values = SCMalloc(sizeof(*det_ctx->bj_values) * (byte_extract_max_local_id + 1)); + det_ctx->bj_values = SCMalloc(sizeof(*det_ctx->bj_values) * de_ctx->byte_extract_max_local_id); if (det_ctx->bj_values == NULL) { return TM_ECODE_FAILED; } diff --git a/src/detect.h b/src/detect.h index 652f07156f..eb425947c3 100644 --- a/src/detect.h +++ b/src/detect.h @@ -656,6 +656,9 @@ typedef struct DetectEngineCtx_ { int32_t sgh_mpm_context_huad; int32_t sgh_mpm_context_app_proto_detect; + /* the max local id used amongst all sigs */ + int32_t byte_extract_max_local_id; + /** sgh for signatures that match against invalid packets. In those cases * we can't lookup by proto, address, port as we don't have these */ struct SigGroupHead_ *decoder_event_sgh;