set the isdataat keyword when previous sigmatch is either content or pcre (bug 144)

remotes/origin/master-1.0.x
Gurvinder Singh 15 years ago committed by Victor Julien
parent 8dceb2784e
commit fdc3f728af

@ -40,6 +40,7 @@
#include "util-debug.h" #include "util-debug.h"
#include "util-byte.h" #include "util-byte.h"
#include "detect-pcre.h"
/** /**
* \brief Regex for parsing our isdataat options * \brief Regex for parsing our isdataat options
@ -248,19 +249,30 @@ int DetectIsdataatSetup (DetectEngineCtx *de_ctx, Signature *s, char *isdataatst
SigMatch *pm = NULL; SigMatch *pm = NULL;
/** Search for the first previous DetectContent /** Search for the first previous DetectContent
* SigMatch (it can be the same as this one) */ * SigMatch (it can be the same as this one) */
pm = DetectContentGetLastPattern(s->pmatch_tail); pm = SigMatchGetLastSM(s->pmatch_tail, DETECT_CONTENT);
if (pm == NULL) { if (pm != NULL) {
SCLogError(SC_ERR_INVALID_SIGNATURE, "Unknown previous keyword!"); cd = (DetectContentData *)pm->ctx;
return -1; if (cd == NULL) {
} SCLogError(SC_ERR_INVALID_SIGNATURE, "Unknown previous keyword!");
return -1;
}
cd = (DetectContentData *)pm->ctx; cd->flags |= DETECT_CONTENT_RELATIVE_NEXT;
if (cd == NULL) { } else {
SCLogError(SC_ERR_INVALID_SIGNATURE, "Unknown previous keyword!"); pm = SigMatchGetLastSM(s->pmatch_tail, DETECT_PCRE);
return -1; if (pm == NULL) {
} SCLogError(SC_ERR_INVALID_SIGNATURE, "Unknown previous keyword!");
return -1;
}
cd->flags |= DETECT_CONTENT_RELATIVE_NEXT; DetectPcreData *pe = NULL;
pe = (DetectPcreData *) pm->ctx;
if (pe == NULL) {
SCLogError(SC_ERR_INVALID_SIGNATURE, "Unknown previous keyword!");
return -1;
}
pe->flags |= DETECT_PCRE_RELATIVE;
}
} }
sm = SigMatchAlloc(); sm = SigMatchAlloc();

@ -600,6 +600,7 @@ error:
static int DetectPcreSetup (DetectEngineCtx *de_ctx, Signature *s, char *regexstr) static int DetectPcreSetup (DetectEngineCtx *de_ctx, Signature *s, char *regexstr)
{ {
SCEnter();
DetectPcreData *pd = NULL; DetectPcreData *pd = NULL;
SigMatch *sm = NULL; SigMatch *sm = NULL;
@ -629,12 +630,12 @@ static int DetectPcreSetup (DetectEngineCtx *de_ctx, Signature *s, char *regexst
} }
return 0; SCReturnInt(0);
error: error:
if (pd != NULL) DetectPcreFree(pd); if (pd != NULL) DetectPcreFree(pd);
if (sm != NULL) SCFree(sm); if (sm != NULL) SCFree(sm);
return -1; SCReturnInt(-1);
} }
void DetectPcreFree(void *ptr) { void DetectPcreFree(void *ptr) {

Loading…
Cancel
Save