From 3656879aa0fa2fb90aeaa813f019bae0906cf959 Mon Sep 17 00:00:00 2001 From: Anoop Saldanha Date: Thu, 11 Nov 2010 13:57:46 +0530 Subject: [PATCH] fix some dce opnum/stub tests that would have shown success always irrespective of test results --- src/detect-dce-opnum.c | 39 ++++++++++++++++++++++++-------------- src/detect-dce-stub-data.c | 4 +++- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/detect-dce-opnum.c b/src/detect-dce-opnum.c index 4f99093dd0..51a8de3e02 100644 --- a/src/detect-dce-opnum.c +++ b/src/detect-dce-opnum.c @@ -380,7 +380,7 @@ static int DetectDceOpnumTestParse01(void) result &= (DetectDceOpnumSetup(NULL, s, "12,26,62,61,6513--") == -1); result &= (DetectDceOpnumSetup(NULL, s, "12-14,12,121,62-8") == -1); - if (s->match != NULL) { + if (s->amatch != NULL) { SigFree(s); result &= 1; } @@ -400,14 +400,16 @@ static int DetectDceOpnumTestParse02(void) result = (DetectDceOpnumSetup(NULL, s, "12") == 0); - if (s->match != NULL) { - temp = s->match; + if (s->amatch != NULL) { + temp = s->amatch; dod = temp->ctx; if (dod == NULL) goto end; dor = dod->range; result &= (dor->range1 == 12 && dor->range2 == DCE_OPNUM_RANGE_UNINITIALIZED); result &= (dor->next == NULL); + } else { + result = 0; } end: @@ -427,14 +429,16 @@ static int DetectDceOpnumTestParse03(void) result = (DetectDceOpnumSetup(NULL, s, "12-24") == 0); - if (s->match != NULL) { - temp = s->match; + if (s->amatch != NULL) { + temp = s->amatch; dod = temp->ctx; if (dod == NULL) goto end; dor = dod->range; result &= (dor->range1 == 12 && dor->range2 == 24); result &= (dor->next == NULL); + } else { + result = 0; } end: @@ -454,8 +458,8 @@ static int DetectDceOpnumTestParse04(void) result = (DetectDceOpnumSetup(NULL, s, "12-24,24,62-72,623-635,62,25,213-235") == 0); - if (s->match != NULL) { - temp = s->match; + if (s->amatch != NULL) { + temp = s->amatch; dod = temp->ctx; if (dod == NULL) goto end; @@ -499,6 +503,8 @@ static int DetectDceOpnumTestParse04(void) result &= (dor->range1 == 213 && dor->range2 == 235); if (result == 0) goto end; + } else { + result = 0; } end: @@ -518,8 +524,8 @@ static int DetectDceOpnumTestParse05(void) result = (DetectDceOpnumSetup(NULL, s, "1,2,3,4,5,6,7") == 0); - if (s->match != NULL) { - temp = s->match; + if (s->amatch != NULL) { + temp = s->amatch; dod = temp->ctx; if (dod == NULL) goto end; @@ -563,6 +569,8 @@ static int DetectDceOpnumTestParse05(void) result &= (dor->range1 == 7 && dor->range2 == DCE_OPNUM_RANGE_UNINITIALIZED); if (result == 0) goto end; + } else { + result = 0; } end: @@ -582,8 +590,8 @@ static int DetectDceOpnumTestParse06(void) result = (DetectDceOpnumSetup(NULL, s, "1-2,3-4,5-6,7-8") == 0); - if (s->match != NULL) { - temp = s->match; + if (s->amatch != NULL) { + temp = s->amatch; dod = temp->ctx; if (dod == NULL) goto end; @@ -609,7 +617,8 @@ static int DetectDceOpnumTestParse06(void) result &= (dor->range1 == 7 && dor->range2 == 8); if (result == 0) goto end; - + } else { + result = 0; } end: @@ -629,8 +638,8 @@ static int DetectDceOpnumTestParse07(void) result = (DetectDceOpnumSetup(NULL, s, "1-2,3-4,5-6,7-8,9") == 0); - if (s->match != NULL) { - temp = s->match; + if (s->amatch != NULL) { + temp = s->amatch; dod = temp->ctx; if (dod == NULL) goto end; @@ -661,6 +670,8 @@ static int DetectDceOpnumTestParse07(void) result &= (dor->range1 == 9 && dor->range2 == DCE_OPNUM_RANGE_UNINITIALIZED); if (result == 0) goto end; + } else { + result = 0; } end: diff --git a/src/detect-dce-stub-data.c b/src/detect-dce-stub-data.c index c11bd91b71..963821c996 100644 --- a/src/detect-dce-stub-data.c +++ b/src/detect-dce-stub-data.c @@ -161,8 +161,10 @@ static int DetectDceStubDataTestParse01(void) result = (DetectDceStubDataSetup(NULL, &s, NULL) == 0); - if (s.match != NULL) { + if (s.amatch != NULL) { result = 1; + } else { + result = 0; } return result;