isdataat: fix coverity issue

During keyword setup there was a path that in theory could lead to
indexing an array with a negative int.

Coverity 400608
pull/851/head
Victor Julien 12 years ago
parent aa8918abd1
commit 3c9a135c0f

@ -257,7 +257,7 @@ int DetectIsdataatSetup (DetectEngineCtx *de_ctx, Signature *s, char *isdataatst
idad = DetectIsdataatParse(isdataatstr, &offset); idad = DetectIsdataatParse(isdataatstr, &offset);
if (idad == NULL) if (idad == NULL)
goto end; return -1;
int sm_list; int sm_list;
if (s->list != DETECT_SM_LIST_NOTSET) { if (s->list != DETECT_SM_LIST_NOTSET) {
@ -365,8 +365,11 @@ int DetectIsdataatSetup (DetectEngineCtx *de_ctx, Signature *s, char *isdataatst
DETECT_ISDATAAT, s->sm_lists_tail[DETECT_SM_LIST_HRHHDMATCH]); DETECT_ISDATAAT, s->sm_lists_tail[DETECT_SM_LIST_HRHHDMATCH]);
if (prev_pm == NULL) if (prev_pm == NULL)
sm_list = DETECT_SM_LIST_PMATCH; sm_list = DETECT_SM_LIST_PMATCH;
else else {
sm_list = SigMatchListSMBelongsTo(s, prev_pm); sm_list = SigMatchListSMBelongsTo(s, prev_pm);
if (sm_list < 0)
goto end;
}
} else { } else {
sm_list = DETECT_SM_LIST_PMATCH; sm_list = DETECT_SM_LIST_PMATCH;
} }
@ -411,6 +414,8 @@ int DetectIsdataatSetup (DetectEngineCtx *de_ctx, Signature *s, char *isdataatst
ret = 0; ret = 0;
end: end:
if (ret != 0)
DetectIsdataatFree(idad);
return ret; return ret;
} }

Loading…
Cancel
Save