diff --git a/src/tests/detect-http-stat-msg.c b/src/tests/detect-http-stat-msg.c index 60251ec8ed..90e83271b5 100644 --- a/src/tests/detect-http-stat-msg.c +++ b/src/tests/detect-http-stat-msg.c @@ -64,7 +64,6 @@ static int DetectEngineHttpStatMsgTest01(void) "\r\n" "message"; uint32_t http_len2 = sizeof(http_buf2) - 1; - int result = 0; AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); @@ -93,7 +92,7 @@ static int DetectEngineHttpStatMsgTest01(void) de_ctx = DetectEngineCtxInit(); if (de_ctx == NULL) - goto end; + FAIL; de_ctx->flags |= DE_QUIET; @@ -102,7 +101,7 @@ static int DetectEngineHttpStatMsgTest01(void) "content:\"message\"; http_stat_msg; " "sid:1;)"); if (de_ctx->sig_list == NULL) - goto end; + FAIL; SigGroupBuild(de_ctx); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); @@ -111,15 +110,13 @@ static int DetectEngineHttpStatMsgTest01(void) NULL, alp_tctx, &f, ALPROTO_HTTP1, STREAM_TOSERVER, http_buf1, http_len1); if (r != 0) { printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r); - result = 0; - goto end; + FAIL; } http_state = f.alstate; if (http_state == NULL) { printf("no http state: \n"); - result = 0; - goto end; + FAIL; } /* do detect */ @@ -127,15 +124,14 @@ static int DetectEngineHttpStatMsgTest01(void) if ((PacketAlertCheck(p1, 1))) { printf("sid 1 matched but shouldn't have\n"); - goto end; + FAIL; } r = AppLayerParserParse( NULL, alp_tctx, &f, ALPROTO_HTTP1, STREAM_TOCLIENT, http_buf2, http_len2); if (r != 0) { printf("toserver chunk 1 returned %" PRId32 ", expected 0: \n", r); - result = 0; - goto end; + FAIL; } /* do detect */ @@ -143,22 +139,19 @@ static int DetectEngineHttpStatMsgTest01(void) if (!(PacketAlertCheck(p2, 1))) { printf("sid 1 didn't match but should have"); - goto end; + FAIL; } - result = 1; - -end: - if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); - if (de_ctx != NULL) + DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); DetectEngineCtxFree(de_ctx); - StreamTcpFreeConfig(true); - FLOW_DESTROY(&f); UTHFreePackets(&p1, 1); UTHFreePackets(&p2, 1); - return result; + FLOW_DESTROY(&f); + StreamTcpFreeConfig(true); + StatsThreadCleanup(&th_v); + PASS; } static int DetectEngineHttpStatMsgTest02(void) @@ -183,7 +176,6 @@ static int DetectEngineHttpStatMsgTest02(void) "\r\n" "xxxxABC"; uint32_t http_len2 = sizeof(http_buf2) - 1; - int result = 0; AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); @@ -207,7 +199,7 @@ static int DetectEngineHttpStatMsgTest02(void) de_ctx = DetectEngineCtxInit(); if (de_ctx == NULL) - goto end; + FAIL; de_ctx->flags |= DE_QUIET; @@ -216,7 +208,7 @@ static int DetectEngineHttpStatMsgTest02(void) "content:\"ABC\"; http_stat_msg; offset:4; " "sid:1;)"); if (de_ctx->sig_list == NULL) - goto end; + FAIL; SigGroupBuild(de_ctx); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); @@ -225,23 +217,20 @@ static int DetectEngineHttpStatMsgTest02(void) NULL, alp_tctx, &f, ALPROTO_HTTP1, STREAM_TOSERVER, http_buf1, http_len1); if (r != 0) { printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r); - result = 0; - goto end; + FAIL; } r = AppLayerParserParse( NULL, alp_tctx, &f, ALPROTO_HTTP1, STREAM_TOCLIENT, http_buf2, http_len2); if (r != 0) { printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r); - result = 0; - goto end; + FAIL; } http_state = f.alstate; if (http_state == NULL) { printf("no http state: \n"); - result = 0; - goto end; + FAIL; } /* do detect */ @@ -249,21 +238,18 @@ static int DetectEngineHttpStatMsgTest02(void) if (!(PacketAlertCheck(p1, 1))) { printf("sid 1 didn't match but should have\n"); - goto end; + FAIL; } - result = 1; - -end: - if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); - if (de_ctx != NULL) + DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); DetectEngineCtxFree(de_ctx); - StreamTcpFreeConfig(true); - FLOW_DESTROY(&f); UTHFreePackets(&p1, 1); - return result; + FLOW_DESTROY(&f); + StreamTcpFreeConfig(true); + StatsThreadCleanup(&th_v); + PASS; } static int DetectEngineHttpStatMsgTest03(void) @@ -276,12 +262,11 @@ static int DetectEngineHttpStatMsgTest03(void) DetectEngineThreadCtx *det_ctx = NULL; HtpState *http_state = NULL; Flow f; - int result = 0; - uint8_t http_buf1[] = - "GET /index.html HTTP/1.0\r\n" - "Host: www.openinfosecfoundation.org\r\n" - "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7\r\n" - "\r\n"; + uint8_t http_buf1[] = "GET /index.html HTTP/1.0\r\n" + "Host: www.openinfosecfoundation.org\r\n" + "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) " + "Gecko/20091221 Firefox/3.5.7\r\n" + "\r\n"; uint32_t http_len1 = sizeof(http_buf1) - 1; uint8_t http_buf2[] = "HTTP/1.0 200 1234567"; @@ -321,7 +306,7 @@ static int DetectEngineHttpStatMsgTest03(void) de_ctx = DetectEngineCtxInit(); if (de_ctx == NULL) - goto end; + FAIL; de_ctx->flags |= DE_QUIET; @@ -330,7 +315,7 @@ static int DetectEngineHttpStatMsgTest03(void) "content:\"ABC\"; http_stat_msg; offset:14; " "sid:1;)"); if (de_ctx->sig_list == NULL) - goto end; + FAIL; SigGroupBuild(de_ctx); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); @@ -339,15 +324,13 @@ static int DetectEngineHttpStatMsgTest03(void) NULL, alp_tctx, &f, ALPROTO_HTTP1, STREAM_TOSERVER, http_buf1, http_len1); if (r != 0) { printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r); - result = 0; - goto end; + FAIL; } http_state = f.alstate; if (http_state == NULL) { printf("no http state: \n"); - result = 0; - goto end; + FAIL; } /* do detect */ @@ -355,23 +338,21 @@ static int DetectEngineHttpStatMsgTest03(void) if (PacketAlertCheck(p1, 1)) { printf("sid 1 matched but shouldn't have\n"); - goto end; + FAIL; } r = AppLayerParserParse( NULL, alp_tctx, &f, ALPROTO_HTTP1, STREAM_TOCLIENT, http_buf2, http_len2); if (r != 0) { printf("toserver chunk 1 returned %" PRId32 ", expected 0: \n", r); - result = 0; - goto end; + FAIL; } r = AppLayerParserParse( NULL, alp_tctx, &f, ALPROTO_HTTP1, STREAM_TOCLIENT, http_buf3, http_len3); if (r != 0) { printf("toserver chunk 1 returned %" PRId32 ", expected 0: \n", r); - result = 0; - goto end; + FAIL; } /* do detect */ @@ -379,22 +360,22 @@ static int DetectEngineHttpStatMsgTest03(void) if (!(PacketAlertCheck(p2, 1))) { printf("sid 1 didn't match but should have"); - goto end; + FAIL; } - result = 1; - -end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); + DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); if (de_ctx != NULL) - DetectEngineCtxFree(de_ctx); + if (de_ctx != NULL) + DetectEngineCtxFree(de_ctx); - StreamTcpFreeConfig(true); - FLOW_DESTROY(&f); UTHFreePackets(&p1, 1); UTHFreePackets(&p2, 1); - return result; + FLOW_DESTROY(&f); + StreamTcpFreeConfig(true); + StatsThreadCleanup(&th_v); + PASS; } static int DetectEngineHttpStatMsgTest04(void) @@ -420,7 +401,6 @@ static int DetectEngineHttpStatMsgTest04(void) "\r\n" "abcdef"; uint32_t http_len2 = sizeof(http_buf2) - 1; - int result = 0; AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); @@ -449,7 +429,7 @@ static int DetectEngineHttpStatMsgTest04(void) de_ctx = DetectEngineCtxInit(); if (de_ctx == NULL) - goto end; + FAIL; de_ctx->flags |= DE_QUIET; @@ -458,7 +438,7 @@ static int DetectEngineHttpStatMsgTest04(void) "content:!\"abc\"; http_stat_msg; offset:3; " "sid:1;)"); if (de_ctx->sig_list == NULL) - goto end; + FAIL; SigGroupBuild(de_ctx); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); @@ -467,15 +447,13 @@ static int DetectEngineHttpStatMsgTest04(void) NULL, alp_tctx, &f, ALPROTO_HTTP1, STREAM_TOSERVER, http_buf1, http_len1); if (r != 0) { printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r); - result = 0; - goto end; + FAIL; } http_state = f.alstate; if (http_state == NULL) { printf("no http state: \n"); - result = 0; - goto end; + FAIL; } /* do detect */ @@ -483,15 +461,14 @@ static int DetectEngineHttpStatMsgTest04(void) if (PacketAlertCheck(p1, 1)) { printf("sid 1 matched but shouldn't have: "); - goto end; + FAIL; } r = AppLayerParserParse( NULL, alp_tctx, &f, ALPROTO_HTTP1, STREAM_TOCLIENT, http_buf2, http_len2); if (r != 0) { printf("toserver chunk 1 returned %" PRId32 ", expected 0: \n", r); - result = 0; - goto end; + FAIL; } /* do detect */ @@ -499,22 +476,21 @@ static int DetectEngineHttpStatMsgTest04(void) if (!PacketAlertCheck(p2, 1)) { printf("sid 1 didn't match but should have: "); - goto end; + FAIL; } - result = 1; - -end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); + DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); - StreamTcpFreeConfig(true); - FLOW_DESTROY(&f); UTHFreePackets(&p1, 1); UTHFreePackets(&p2, 1); - return result; + FLOW_DESTROY(&f); + StreamTcpFreeConfig(true); + StatsThreadCleanup(&th_v); + PASS; } static int DetectEngineHttpStatMsgTest05(void) @@ -540,7 +516,6 @@ static int DetectEngineHttpStatMsgTest05(void) "\r\n" "abcdef"; uint32_t http_len2 = sizeof(http_buf2) - 1; - int result = 0; AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); @@ -569,7 +544,7 @@ static int DetectEngineHttpStatMsgTest05(void) de_ctx = DetectEngineCtxInit(); if (de_ctx == NULL) - goto end; + FAIL; de_ctx->flags |= DE_QUIET; @@ -578,7 +553,7 @@ static int DetectEngineHttpStatMsgTest05(void) "content:\"abc\"; http_stat_msg; depth:3; " "sid:1;)"); if (de_ctx->sig_list == NULL) - goto end; + FAIL; SigGroupBuild(de_ctx); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); @@ -587,15 +562,13 @@ static int DetectEngineHttpStatMsgTest05(void) NULL, alp_tctx, &f, ALPROTO_HTTP1, STREAM_TOSERVER, http_buf1, http_len1); if (r != 0) { printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r); - result = 0; - goto end; + FAIL; } http_state = f.alstate; if (http_state == NULL) { printf("no http state: \n"); - result = 0; - goto end; + FAIL; } /* do detect */ @@ -603,15 +576,14 @@ static int DetectEngineHttpStatMsgTest05(void) if (PacketAlertCheck(p1, 1)) { printf("sid 1 matched but shouldn't have: "); - goto end; + FAIL; } r = AppLayerParserParse( NULL, alp_tctx, &f, ALPROTO_HTTP1, STREAM_TOCLIENT, http_buf2, http_len2); if (r != 0) { printf("toserver chunk 1 returned %" PRId32 ", expected 0: \n", r); - result = 0; - goto end; + FAIL; } /* do detect */ @@ -619,22 +591,21 @@ static int DetectEngineHttpStatMsgTest05(void) if (!PacketAlertCheck(p2, 1)) { printf("sid 1 didn't match but should have: "); - goto end; + FAIL; } - result = 1; - -end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); + DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); - StreamTcpFreeConfig(true); - FLOW_DESTROY(&f); UTHFreePackets(&p1, 1); UTHFreePackets(&p2, 1); - return result; + FLOW_DESTROY(&f); + StreamTcpFreeConfig(true); + StatsThreadCleanup(&th_v); + PASS; } static int DetectEngineHttpStatMsgTest06(void) @@ -660,7 +631,6 @@ static int DetectEngineHttpStatMsgTest06(void) "\r\n" "abcdef"; uint32_t http_len2 = sizeof(http_buf2) - 1; - int result = 0; AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); @@ -689,7 +659,7 @@ static int DetectEngineHttpStatMsgTest06(void) de_ctx = DetectEngineCtxInit(); if (de_ctx == NULL) - goto end; + FAIL; de_ctx->flags |= DE_QUIET; @@ -698,7 +668,7 @@ static int DetectEngineHttpStatMsgTest06(void) "content:!\"def\"; http_stat_msg; depth:3; " "sid:1;)"); if (de_ctx->sig_list == NULL) - goto end; + FAIL; SigGroupBuild(de_ctx); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); @@ -707,15 +677,13 @@ static int DetectEngineHttpStatMsgTest06(void) NULL, alp_tctx, &f, ALPROTO_HTTP1, STREAM_TOSERVER, http_buf1, http_len1); if (r != 0) { printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r); - result = 0; - goto end; + FAIL; } http_state = f.alstate; if (http_state == NULL) { printf("no http state: \n"); - result = 0; - goto end; + FAIL; } /* do detect */ @@ -723,15 +691,14 @@ static int DetectEngineHttpStatMsgTest06(void) if (PacketAlertCheck(p1, 1)) { printf("sid 1 matched but shouldn't have: "); - goto end; + FAIL; } r = AppLayerParserParse( NULL, alp_tctx, &f, ALPROTO_HTTP1, STREAM_TOCLIENT, http_buf2, http_len2); if (r != 0) { printf("toserver chunk 1 returned %" PRId32 ", expected 0: \n", r); - result = 0; - goto end; + FAIL; } /* do detect */ @@ -739,22 +706,21 @@ static int DetectEngineHttpStatMsgTest06(void) if (!PacketAlertCheck(p2, 1)) { printf("sid 1 didn't match but should have: "); - goto end; + FAIL; } - result = 1; - -end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); + DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); - StreamTcpFreeConfig(true); - FLOW_DESTROY(&f); UTHFreePackets(&p1, 1); UTHFreePackets(&p2, 1); - return result; + FLOW_DESTROY(&f); + StreamTcpFreeConfig(true); + StatsThreadCleanup(&th_v); + PASS; } static int DetectEngineHttpStatMsgTest07(void) @@ -780,7 +746,6 @@ static int DetectEngineHttpStatMsgTest07(void) "\r\n" "abcdef"; uint32_t http_len2 = sizeof(http_buf2) - 1; - int result = 0; AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); @@ -809,7 +774,7 @@ static int DetectEngineHttpStatMsgTest07(void) de_ctx = DetectEngineCtxInit(); if (de_ctx == NULL) - goto end; + FAIL; de_ctx->flags |= DE_QUIET; @@ -818,7 +783,7 @@ static int DetectEngineHttpStatMsgTest07(void) "content:!\"def\"; http_stat_msg; offset:3; " "sid:1;)"); if (de_ctx->sig_list == NULL) - goto end; + FAIL; SigGroupBuild(de_ctx); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); @@ -827,15 +792,13 @@ static int DetectEngineHttpStatMsgTest07(void) NULL, alp_tctx, &f, ALPROTO_HTTP1, STREAM_TOSERVER, http_buf1, http_len1); if (r != 0) { printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r); - result = 0; - goto end; + FAIL; } http_state = f.alstate; if (http_state == NULL) { printf("no http state: \n"); - result = 0; - goto end; + FAIL; } /* do detect */ @@ -843,15 +806,14 @@ static int DetectEngineHttpStatMsgTest07(void) if (PacketAlertCheck(p1, 1)) { printf("sid 1 matched but shouldn't have: "); - goto end; + FAIL; } r = AppLayerParserParse( NULL, alp_tctx, &f, ALPROTO_HTTP1, STREAM_TOCLIENT, http_buf2, http_len2); if (r != 0) { printf("toserver chunk 1 returned %" PRId32 ", expected 0: \n", r); - result = 0; - goto end; + FAIL; } /* do detect */ @@ -859,22 +821,21 @@ static int DetectEngineHttpStatMsgTest07(void) if (PacketAlertCheck(p2, 1)) { printf("sid 1 matched but shouldn't have: "); - goto end; + FAIL; } - result = 1; - -end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); + DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); - StreamTcpFreeConfig(true); - FLOW_DESTROY(&f); UTHFreePackets(&p1, 1); UTHFreePackets(&p2, 1); - return result; + FLOW_DESTROY(&f); + StreamTcpFreeConfig(true); + StatsThreadCleanup(&th_v); + PASS; } static int DetectEngineHttpStatMsgTest08(void) @@ -900,7 +861,6 @@ static int DetectEngineHttpStatMsgTest08(void) "\r\n" "abcdef"; uint32_t http_len2 = sizeof(http_buf2) - 1; - int result = 0; AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); @@ -929,7 +889,7 @@ static int DetectEngineHttpStatMsgTest08(void) de_ctx = DetectEngineCtxInit(); if (de_ctx == NULL) - goto end; + FAIL; de_ctx->flags |= DE_QUIET; @@ -938,7 +898,7 @@ static int DetectEngineHttpStatMsgTest08(void) "content:!\"abc\"; http_stat_msg; depth:3; " "sid:1;)"); if (de_ctx->sig_list == NULL) - goto end; + FAIL; SigGroupBuild(de_ctx); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); @@ -947,15 +907,13 @@ static int DetectEngineHttpStatMsgTest08(void) NULL, alp_tctx, &f, ALPROTO_HTTP1, STREAM_TOSERVER, http_buf1, http_len1); if (r != 0) { printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r); - result = 0; - goto end; + FAIL; } http_state = f.alstate; if (http_state == NULL) { printf("no http state: \n"); - result = 0; - goto end; + FAIL; } /* do detect */ @@ -963,15 +921,14 @@ static int DetectEngineHttpStatMsgTest08(void) if (PacketAlertCheck(p1, 1)) { printf("sid 1 matched but shouldn't have: "); - goto end; + FAIL; } r = AppLayerParserParse( NULL, alp_tctx, &f, ALPROTO_HTTP1, STREAM_TOCLIENT, http_buf2, http_len2); if (r != 0) { printf("toserver chunk 1 returned %" PRId32 ", expected 0: \n", r); - result = 0; - goto end; + FAIL; } /* do detect */ @@ -979,22 +936,21 @@ static int DetectEngineHttpStatMsgTest08(void) if (PacketAlertCheck(p2, 1)) { printf("sid 1 matched but shouldn't have: "); - goto end; + FAIL; } - result = 1; - -end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); + DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); - StreamTcpFreeConfig(true); - FLOW_DESTROY(&f); UTHFreePackets(&p1, 1); UTHFreePackets(&p2, 1); - return result; + FLOW_DESTROY(&f); + StreamTcpFreeConfig(true); + StatsThreadCleanup(&th_v); + PASS; } static int DetectEngineHttpStatMsgTest09(void) @@ -1020,7 +976,6 @@ static int DetectEngineHttpStatMsgTest09(void) "\r\n" "abcdef"; uint32_t http_len2 = sizeof(http_buf2) - 1; - int result = 0; AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); @@ -1049,7 +1004,7 @@ static int DetectEngineHttpStatMsgTest09(void) de_ctx = DetectEngineCtxInit(); if (de_ctx == NULL) - goto end; + FAIL; de_ctx->flags |= DE_QUIET; @@ -1059,7 +1014,7 @@ static int DetectEngineHttpStatMsgTest09(void) "content:\"def\"; http_stat_msg; within:3; " "sid:1;)"); if (de_ctx->sig_list == NULL) - goto end; + FAIL; SigGroupBuild(de_ctx); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); @@ -1068,15 +1023,13 @@ static int DetectEngineHttpStatMsgTest09(void) NULL, alp_tctx, &f, ALPROTO_HTTP1, STREAM_TOSERVER, http_buf1, http_len1); if (r != 0) { printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r); - result = 0; - goto end; + FAIL; } http_state = f.alstate; if (http_state == NULL) { printf("no http state: \n"); - result = 0; - goto end; + FAIL; } /* do detect */ @@ -1084,15 +1037,14 @@ static int DetectEngineHttpStatMsgTest09(void) if (PacketAlertCheck(p1, 1)) { printf("sid 1 matched but shouldn't have: "); - goto end; + FAIL; } r = AppLayerParserParse( NULL, alp_tctx, &f, ALPROTO_HTTP1, STREAM_TOCLIENT, http_buf2, http_len2); if (r != 0) { printf("toserver chunk 1 returned %" PRId32 ", expected 0: \n", r); - result = 0; - goto end; + FAIL; } /* do detect */ @@ -1100,22 +1052,21 @@ static int DetectEngineHttpStatMsgTest09(void) if (!PacketAlertCheck(p2, 1)) { printf("sid 1 didn't match but should have: "); - goto end; + FAIL; } - result = 1; - -end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); + DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); - StreamTcpFreeConfig(true); - FLOW_DESTROY(&f); UTHFreePackets(&p1, 1); UTHFreePackets(&p2, 1); - return result; + FLOW_DESTROY(&f); + StreamTcpFreeConfig(true); + StatsThreadCleanup(&th_v); + PASS; } static int DetectEngineHttpStatMsgTest10(void) @@ -1141,7 +1092,6 @@ static int DetectEngineHttpStatMsgTest10(void) "\r\n" "abcdef"; uint32_t http_len2 = sizeof(http_buf2) - 1; - int result = 0; AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); @@ -1170,7 +1120,7 @@ static int DetectEngineHttpStatMsgTest10(void) de_ctx = DetectEngineCtxInit(); if (de_ctx == NULL) - goto end; + FAIL; de_ctx->flags |= DE_QUIET; @@ -1180,7 +1130,7 @@ static int DetectEngineHttpStatMsgTest10(void) "content:!\"xyz\"; http_stat_msg; within:3; " "sid:1;)"); if (de_ctx->sig_list == NULL) - goto end; + FAIL; SigGroupBuild(de_ctx); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); @@ -1189,15 +1139,13 @@ static int DetectEngineHttpStatMsgTest10(void) NULL, alp_tctx, &f, ALPROTO_HTTP1, STREAM_TOSERVER, http_buf1, http_len1); if (r != 0) { printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r); - result = 0; - goto end; + FAIL; } http_state = f.alstate; if (http_state == NULL) { printf("no http state: \n"); - result = 0; - goto end; + FAIL; } /* do detect */ @@ -1205,15 +1153,14 @@ static int DetectEngineHttpStatMsgTest10(void) if (PacketAlertCheck(p1, 1)) { printf("sid 1 matched but shouldn't have: "); - goto end; + FAIL; } r = AppLayerParserParse( NULL, alp_tctx, &f, ALPROTO_HTTP1, STREAM_TOCLIENT, http_buf2, http_len2); if (r != 0) { printf("toserver chunk 1 returned %" PRId32 ", expected 0: \n", r); - result = 0; - goto end; + FAIL; } /* do detect */ @@ -1221,22 +1168,21 @@ static int DetectEngineHttpStatMsgTest10(void) if (!PacketAlertCheck(p2, 1)) { printf("sid 1 didn't match but should have: "); - goto end; + FAIL; } - result = 1; - -end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); + DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); - StreamTcpFreeConfig(true); - FLOW_DESTROY(&f); UTHFreePackets(&p1, 1); UTHFreePackets(&p2, 1); - return result; + FLOW_DESTROY(&f); + StreamTcpFreeConfig(true); + StatsThreadCleanup(&th_v); + PASS; } static int DetectEngineHttpStatMsgTest11(void) @@ -1262,7 +1208,6 @@ static int DetectEngineHttpStatMsgTest11(void) "\r\n" "abcdef"; uint32_t http_len2 = sizeof(http_buf2) - 1; - int result = 0; AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); @@ -1291,7 +1236,7 @@ static int DetectEngineHttpStatMsgTest11(void) de_ctx = DetectEngineCtxInit(); if (de_ctx == NULL) - goto end; + FAIL; de_ctx->flags |= DE_QUIET; @@ -1301,7 +1246,7 @@ static int DetectEngineHttpStatMsgTest11(void) "content:\"xyz\"; http_stat_msg; within:3; " "sid:1;)"); if (de_ctx->sig_list == NULL) - goto end; + FAIL; SigGroupBuild(de_ctx); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); @@ -1310,15 +1255,13 @@ static int DetectEngineHttpStatMsgTest11(void) NULL, alp_tctx, &f, ALPROTO_HTTP1, STREAM_TOSERVER, http_buf1, http_len1); if (r != 0) { printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r); - result = 0; - goto end; + FAIL; } http_state = f.alstate; if (http_state == NULL) { printf("no http state: \n"); - result = 0; - goto end; + FAIL; } /* do detect */ @@ -1326,15 +1269,14 @@ static int DetectEngineHttpStatMsgTest11(void) if (PacketAlertCheck(p1, 1)) { printf("sid 1 matched but shouldn't have: "); - goto end; + FAIL; } r = AppLayerParserParse( NULL, alp_tctx, &f, ALPROTO_HTTP1, STREAM_TOCLIENT, http_buf2, http_len2); if (r != 0) { printf("toserver chunk 1 returned %" PRId32 ", expected 0: \n", r); - result = 0; - goto end; + FAIL; } /* do detect */ @@ -1342,22 +1284,21 @@ static int DetectEngineHttpStatMsgTest11(void) if (PacketAlertCheck(p2, 1)) { printf("sid 1 did match but should not have: "); - goto end; + FAIL; } - result = 1; - -end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); + DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); - StreamTcpFreeConfig(true); - FLOW_DESTROY(&f); UTHFreePackets(&p1, 1); UTHFreePackets(&p2, 1); - return result; + FLOW_DESTROY(&f); + StreamTcpFreeConfig(true); + StatsThreadCleanup(&th_v); + PASS; } static int DetectEngineHttpStatMsgTest12(void) @@ -1383,7 +1324,6 @@ static int DetectEngineHttpStatMsgTest12(void) "\r\n" "abcdef"; uint32_t http_len2 = sizeof(http_buf2) - 1; - int result = 0; AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); @@ -1412,7 +1352,7 @@ static int DetectEngineHttpStatMsgTest12(void) de_ctx = DetectEngineCtxInit(); if (de_ctx == NULL) - goto end; + FAIL; de_ctx->flags |= DE_QUIET; @@ -1422,7 +1362,7 @@ static int DetectEngineHttpStatMsgTest12(void) "content:\"ef\"; http_stat_msg; distance:2; " "sid:1;)"); if (de_ctx->sig_list == NULL) - goto end; + FAIL; SigGroupBuild(de_ctx); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); @@ -1431,15 +1371,13 @@ static int DetectEngineHttpStatMsgTest12(void) NULL, alp_tctx, &f, ALPROTO_HTTP1, STREAM_TOSERVER, http_buf1, http_len1); if (r != 0) { printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r); - result = 0; - goto end; + FAIL; } http_state = f.alstate; if (http_state == NULL) { printf("no http state: \n"); - result = 0; - goto end; + FAIL; } /* do detect */ @@ -1447,15 +1385,14 @@ static int DetectEngineHttpStatMsgTest12(void) if (PacketAlertCheck(p1, 1)) { printf("sid 1 matched but shouldn't have: "); - goto end; + FAIL; } r = AppLayerParserParse( NULL, alp_tctx, &f, ALPROTO_HTTP1, STREAM_TOCLIENT, http_buf2, http_len2); if (r != 0) { printf("toserver chunk 1 returned %" PRId32 ", expected 0: \n", r); - result = 0; - goto end; + FAIL; } /* do detect */ @@ -1463,22 +1400,21 @@ static int DetectEngineHttpStatMsgTest12(void) if (!PacketAlertCheck(p2, 1)) { printf("sid 1 did not match but should have: "); - goto end; + FAIL; } - result = 1; - -end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); + DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); - StreamTcpFreeConfig(true); - FLOW_DESTROY(&f); UTHFreePackets(&p1, 1); UTHFreePackets(&p2, 1); - return result; + FLOW_DESTROY(&f); + StreamTcpFreeConfig(true); + StatsThreadCleanup(&th_v); + PASS; } static int DetectEngineHttpStatMsgTest13(void) @@ -1504,7 +1440,6 @@ static int DetectEngineHttpStatMsgTest13(void) "\r\n" "abcdef"; uint32_t http_len2 = sizeof(http_buf2) - 1; - int result = 0; AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); @@ -1533,7 +1468,7 @@ static int DetectEngineHttpStatMsgTest13(void) de_ctx = DetectEngineCtxInit(); if (de_ctx == NULL) - goto end; + FAIL; de_ctx->flags |= DE_QUIET; @@ -1543,7 +1478,7 @@ static int DetectEngineHttpStatMsgTest13(void) "content:!\"yz\"; http_stat_msg; distance:2; " "sid:1;)"); if (de_ctx->sig_list == NULL) - goto end; + FAIL; SigGroupBuild(de_ctx); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); @@ -1552,15 +1487,13 @@ static int DetectEngineHttpStatMsgTest13(void) NULL, alp_tctx, &f, ALPROTO_HTTP1, STREAM_TOSERVER, http_buf1, http_len1); if (r != 0) { printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r); - result = 0; - goto end; + FAIL; } http_state = f.alstate; if (http_state == NULL) { printf("no http state: \n"); - result = 0; - goto end; + FAIL; } /* do detect */ @@ -1568,15 +1501,14 @@ static int DetectEngineHttpStatMsgTest13(void) if (PacketAlertCheck(p1, 1)) { printf("sid 1 matched but shouldn't have: "); - goto end; + FAIL; } r = AppLayerParserParse( NULL, alp_tctx, &f, ALPROTO_HTTP1, STREAM_TOCLIENT, http_buf2, http_len2); if (r != 0) { printf("toserver chunk 1 returned %" PRId32 ", expected 0: \n", r); - result = 0; - goto end; + FAIL; } /* do detect */ @@ -1584,22 +1516,18 @@ static int DetectEngineHttpStatMsgTest13(void) if (!PacketAlertCheck(p2, 1)) { printf("sid 1 did not match but should have: "); - goto end; + FAIL; } - result = 1; - -end: - if (alp_tctx != NULL) - AppLayerParserThreadCtxFree(alp_tctx); - if (de_ctx != NULL) - DetectEngineCtxFree(de_ctx); - - StreamTcpFreeConfig(true); - FLOW_DESTROY(&f); UTHFreePackets(&p1, 1); UTHFreePackets(&p2, 1); - return result; + FLOW_DESTROY(&f); + AppLayerParserThreadCtxFree(alp_tctx); + DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); + DetectEngineCtxFree(de_ctx); + StreamTcpFreeConfig(true); + StatsThreadCleanup(&th_v); + PASS; } static int DetectEngineHttpStatMsgTest14(void) @@ -1625,7 +1553,6 @@ static int DetectEngineHttpStatMsgTest14(void) "\r\n" "abcdef"; uint32_t http_len2 = sizeof(http_buf2) - 1; - int result = 0; AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); @@ -1654,7 +1581,7 @@ static int DetectEngineHttpStatMsgTest14(void) de_ctx = DetectEngineCtxInit(); if (de_ctx == NULL) - goto end; + FAIL; de_ctx->flags |= DE_QUIET; @@ -1664,7 +1591,7 @@ static int DetectEngineHttpStatMsgTest14(void) "content:\"ef\"; http_stat_msg; distance:2; " "sid:1;)"); if (de_ctx->sig_list == NULL) - goto end; + FAIL; SigGroupBuild(de_ctx); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); @@ -1673,15 +1600,13 @@ static int DetectEngineHttpStatMsgTest14(void) NULL, alp_tctx, &f, ALPROTO_HTTP1, STREAM_TOSERVER, http_buf1, http_len1); if (r != 0) { printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r); - result = 0; - goto end; + FAIL; } http_state = f.alstate; if (http_state == NULL) { printf("no http state: \n"); - result = 0; - goto end; + FAIL; } /* do detect */ @@ -1689,15 +1614,14 @@ static int DetectEngineHttpStatMsgTest14(void) if (PacketAlertCheck(p1, 1)) { printf("sid 1 matched but shouldn't have: "); - goto end; + FAIL; } r = AppLayerParserParse( NULL, alp_tctx, &f, ALPROTO_HTTP1, STREAM_TOCLIENT, http_buf2, http_len2); if (r != 0) { printf("toserver chunk 1 returned %" PRId32 ", expected 0: \n", r); - result = 0; - goto end; + FAIL; } /* do detect */ @@ -1705,22 +1629,18 @@ static int DetectEngineHttpStatMsgTest14(void) if (!PacketAlertCheck(p2, 1)) { printf("sid 1 did not match but should have: "); - goto end; + FAIL; } - result = 1; - -end: - if (alp_tctx != NULL) - AppLayerParserThreadCtxFree(alp_tctx); - if (de_ctx != NULL) - DetectEngineCtxFree(de_ctx); - - StreamTcpFreeConfig(true); - FLOW_DESTROY(&f); UTHFreePackets(&p1, 1); UTHFreePackets(&p2, 1); - return result; + FLOW_DESTROY(&f); + AppLayerParserThreadCtxFree(alp_tctx); + DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); + DetectEngineCtxFree(de_ctx); + StreamTcpFreeConfig(true); + StatsThreadCleanup(&th_v); + PASS; } static int DetectEngineHttpStatMsgTest15(void) @@ -1746,7 +1666,6 @@ static int DetectEngineHttpStatMsgTest15(void) "\r\n" "abcdef"; uint32_t http_len2 = sizeof(http_buf2) - 1; - int result = 0; AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); memset(&th_v, 0, sizeof(th_v)); @@ -1775,7 +1694,7 @@ static int DetectEngineHttpStatMsgTest15(void) de_ctx = DetectEngineCtxInit(); if (de_ctx == NULL) - goto end; + FAIL; de_ctx->flags |= DE_QUIET; @@ -1785,7 +1704,7 @@ static int DetectEngineHttpStatMsgTest15(void) "content:!\"xyz\"; http_stat_msg; distance:0; within:3; " "sid:1;)"); if (de_ctx->sig_list == NULL) - goto end; + FAIL; SigGroupBuild(de_ctx); DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); @@ -1794,15 +1713,13 @@ static int DetectEngineHttpStatMsgTest15(void) NULL, alp_tctx, &f, ALPROTO_HTTP1, STREAM_TOSERVER, http_buf1, http_len1); if (r != 0) { printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r); - result = 0; - goto end; + FAIL; } http_state = f.alstate; if (http_state == NULL) { printf("no http state: \n"); - result = 0; - goto end; + FAIL; } /* do detect */ @@ -1810,15 +1727,14 @@ static int DetectEngineHttpStatMsgTest15(void) if (PacketAlertCheck(p1, 1)) { printf("sid 1 matched but shouldn't have: "); - goto end; + FAIL; } r = AppLayerParserParse( NULL, alp_tctx, &f, ALPROTO_HTTP1, STREAM_TOCLIENT, http_buf2, http_len2); if (r != 0) { printf("toserver chunk 1 returned %" PRId32 ", expected 0: \n", r); - result = 0; - goto end; + FAIL; } /* do detect */ @@ -1826,28 +1742,23 @@ static int DetectEngineHttpStatMsgTest15(void) if (!PacketAlertCheck(p2, 1)) { printf("sid 1 did not match but should have: "); - goto end; + FAIL; } - result = 1; - -end: - if (alp_tctx != NULL) - AppLayerParserThreadCtxFree(alp_tctx); - if (de_ctx != NULL) - DetectEngineCtxFree(de_ctx); - - StreamTcpFreeConfig(true); - FLOW_DESTROY(&f); UTHFreePackets(&p1, 1); UTHFreePackets(&p2, 1); - return result; + FLOW_DESTROY(&f); + AppLayerParserThreadCtxFree(alp_tctx); + DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); + DetectEngineCtxFree(de_ctx); + StreamTcpFreeConfig(true); + StatsThreadCleanup(&th_v); + PASS; } /** \test Check the signature working to alert when http_stat_msg is matched . */ static int DetectHttpStatMsgSigTest01(void) { - int result = 0; Flow f; uint8_t httpbuf1[] = "POST / HTTP/1.0\r\nUser-Agent: Mozilla/1.0\r\n\r\n"; uint32_t httplen1 = sizeof(httpbuf1) - 1; /* minus the \0 */ @@ -1882,7 +1793,7 @@ static int DetectHttpStatMsgSigTest01(void) DetectEngineCtx *de_ctx = DetectEngineCtxInit(); if (de_ctx == NULL) { - goto end; + FAIL; } de_ctx->flags |= DE_QUIET; @@ -1891,14 +1802,14 @@ static int DetectHttpStatMsgSigTest01(void) "\"HTTP status message\"; content:\"OK\"; " "http_stat_msg; sid:1;)"); if (s == NULL) { - goto end; + FAIL; } s->next = SigInit(de_ctx,"alert http any any -> any any (msg:\"HTTP " "Status message nocase\"; content:\"ok\"; nocase; " "http_stat_msg; sid:2;)"); if (s->next == NULL) { - goto end; + FAIL; } SigGroupBuild(de_ctx); @@ -1908,22 +1819,19 @@ static int DetectHttpStatMsgSigTest01(void) NULL, alp_tctx, &f, ALPROTO_HTTP1, STREAM_TOSERVER, httpbuf1, httplen1); if (r != 0) { printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r); - result = 0; - goto end; + FAIL; } r = AppLayerParserParse(NULL, alp_tctx, &f, ALPROTO_HTTP1, STREAM_TOCLIENT, httpbuf2, httplen2); if (r != 0) { printf("toclient chunk 1 returned %" PRId32 ", expected 0: ", r); - result = 0; - goto end; + FAIL; } http_state = f.alstate; if (http_state == NULL) { printf("no http state: "); - result = 0; - goto end; + FAIL; } /* do detect */ @@ -1931,34 +1839,30 @@ static int DetectHttpStatMsgSigTest01(void) if (!(PacketAlertCheck(p, 1))) { printf("sid 1 didn't match but should have: "); - goto end; + FAIL; } if (!(PacketAlertCheck(p, 2))) { printf("sid 2 didn't match but should have: "); - goto end; + FAIL; } - result = 1; -end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); - if (det_ctx != NULL) { - DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - } + DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); if (de_ctx != NULL) { DetectEngineCtxFree(de_ctx); } - StreamTcpFreeConfig(true); - UTHFreePackets(&p, 1); - return result; + FLOW_DESTROY(&f); + StreamTcpFreeConfig(true); + StatsThreadCleanup(&th_v); + PASS; } /** \test Check the signature working to alert when http_stat_msg is not matched . */ static int DetectHttpStatMsgSigTest02(void) { - int result = 0; Flow f; uint8_t httpbuf1[] = "POST / HTTP/1.0\r\nUser-Agent: Mozilla/1.0\r\n\r\n"; uint32_t httplen1 = sizeof(httpbuf1) - 1; /* minus the \0 */ @@ -1993,7 +1897,7 @@ static int DetectHttpStatMsgSigTest02(void) DetectEngineCtx *de_ctx = DetectEngineCtxInit(); if (de_ctx == NULL) { - goto end; + FAIL; } de_ctx->flags |= DE_QUIET; @@ -2002,7 +1906,7 @@ static int DetectHttpStatMsgSigTest02(void) "\"HTTP status message\"; content:\"no\"; " "http_stat_msg; sid:1;)"); if (s == NULL) { - goto end; + FAIL; } SigGroupBuild(de_ctx); @@ -2012,22 +1916,19 @@ static int DetectHttpStatMsgSigTest02(void) NULL, alp_tctx, &f, ALPROTO_HTTP1, STREAM_TOSERVER, httpbuf1, httplen1); if (r != 0) { printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r); - result = 0; - goto end; + FAIL; } r = AppLayerParserParse(NULL, alp_tctx, &f, ALPROTO_HTTP1, STREAM_TOCLIENT, httpbuf2, httplen2); if (r != 0) { printf("toclient chunk 1 returned %" PRId32 ", expected 0: ", r); - result = 0; - goto end; + FAIL; } http_state = f.alstate; if (http_state == NULL) { printf("no http state: "); - result = 0; - goto end; + FAIL; } /* do detect */ @@ -2035,11 +1936,9 @@ static int DetectHttpStatMsgSigTest02(void) if (PacketAlertCheck(p, 1)) { printf("sid 1 matched but shouldn't: "); - goto end; + FAIL; } - result = 1; -end: if (alp_tctx != NULL) AppLayerParserThreadCtxFree(alp_tctx); if (det_ctx != NULL) { @@ -2049,17 +1948,17 @@ end: DetectEngineCtxFree(de_ctx); } - StreamTcpFreeConfig(true); - UTHFreePackets(&p, 1); - return result; + FLOW_DESTROY(&f); + StreamTcpFreeConfig(true); + StatsThreadCleanup(&th_v); + PASS; } /** \test Check the signature working to alert when http_stat_msg is used with * negated content . */ static int DetectHttpStatMsgSigTest03(void) { - int result = 0; Flow f; uint8_t httpbuf1[] = "POST / HTTP/1.0\r\nUser-Agent: Mozilla/1.0\r\n\r\n"; uint32_t httplen1 = sizeof(httpbuf1) - 1; /* minus the \0 */ @@ -2094,7 +1993,7 @@ static int DetectHttpStatMsgSigTest03(void) DetectEngineCtx *de_ctx = DetectEngineCtxInit(); if (de_ctx == NULL) { - goto end; + FAIL; } de_ctx->flags |= DE_QUIET; @@ -2103,14 +2002,14 @@ static int DetectHttpStatMsgSigTest03(void) "\"HTTP status message\"; content:\"ok\"; " "nocase; http_stat_msg; sid:1;)"); if (s == NULL) { - goto end; + FAIL; } s->next = SigInit(de_ctx,"alert http any any -> any any (msg:\"HTTP " "Status message nocase\"; content:!\"Not\"; " "http_stat_msg; sid:2;)"); if (s->next == NULL) { - goto end; + FAIL; } SigGroupBuild(de_ctx); @@ -2120,22 +2019,19 @@ static int DetectHttpStatMsgSigTest03(void) NULL, alp_tctx, &f, ALPROTO_HTTP1, STREAM_TOSERVER, httpbuf1, httplen1); if (r != 0) { printf("toserver chunk 1 returned %" PRId32 ", expected 0: ", r); - result = 0; - goto end; + FAIL; } r = AppLayerParserParse(NULL, alp_tctx, &f, ALPROTO_HTTP1, STREAM_TOCLIENT, httpbuf2, httplen2); if (r != 0) { printf("toclient chunk 1 returned %" PRId32 ", expected 0: ", r); - result = 0; - goto end; + FAIL; } http_state = f.alstate; if (http_state == NULL) { printf("no http state: "); - result = 0; - goto end; + FAIL; } /* do detect */ @@ -2143,28 +2039,22 @@ static int DetectHttpStatMsgSigTest03(void) if (! PacketAlertCheck(p, 1)) { printf("sid 1 didn't matched but should have: "); - goto end; + FAIL; } if (! PacketAlertCheck(p, 2)) { printf("sid 2 didn't matched but should have: "); - goto end; + FAIL; } - result = 1; -end: - if (alp_tctx != NULL) - AppLayerParserThreadCtxFree(alp_tctx); - if (det_ctx != NULL) { - DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); - } - if (de_ctx != NULL) { - DetectEngineCtxFree(de_ctx); - } - - StreamTcpFreeConfig(true); + AppLayerParserThreadCtxFree(alp_tctx); + DetectEngineThreadCtxDeinit(&th_v, (void *)det_ctx); + DetectEngineCtxFree(de_ctx); UTHFreePackets(&p, 1); - return result; + FLOW_DESTROY(&f); + StreamTcpFreeConfig(true); + StatsThreadCleanup(&th_v); + PASS; } /**