From f766139159ad8c530a87047224644757074cf145 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Sun, 28 Feb 2021 09:24:35 +0100 Subject: [PATCH] detect/state: test to show reset bug --- src/detect-engine-state.c | 44 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/detect-engine-state.c b/src/detect-engine-state.c index 6a0e15b145..fa9e617a5c 100644 --- a/src/detect-engine-state.c +++ b/src/detect-engine-state.c @@ -363,6 +363,50 @@ static int DeStateTest02(void) FAIL_IF(state->dir_state[direction & STREAM_TOSERVER ? 0 : 1].head->next->store[0].sid != 155); FAIL_IF(state->dir_state[direction & STREAM_TOSERVER ? 0 : 1].head->next->store[1].sid != 166); + ResetTxState(state); + + s.num = 0; + DeStateSignatureAppend(state, &s, 0, direction); + s.num = 11; + DeStateSignatureAppend(state, &s, 0, direction); + s.num = 22; + DeStateSignatureAppend(state, &s, 0, direction); + s.num = 33; + DeStateSignatureAppend(state, &s, 0, direction); + s.num = 44; + DeStateSignatureAppend(state, &s, 0, direction); + s.num = 55; + DeStateSignatureAppend(state, &s, 0, direction); + s.num = 66; + DeStateSignatureAppend(state, &s, 0, direction); + s.num = 77; + DeStateSignatureAppend(state, &s, 0, direction); + s.num = 88; + DeStateSignatureAppend(state, &s, 0, direction); + s.num = 99; + DeStateSignatureAppend(state, &s, 0, direction); + s.num = 100; + DeStateSignatureAppend(state, &s, 0, direction); + s.num = 111; + DeStateSignatureAppend(state, &s, 0, direction); + s.num = 122; + DeStateSignatureAppend(state, &s, 0, direction); + s.num = 133; + DeStateSignatureAppend(state, &s, 0, direction); + s.num = 144; + DeStateSignatureAppend(state, &s, 0, direction); + s.num = 155; + DeStateSignatureAppend(state, &s, 0, direction); + s.num = 166; + DeStateSignatureAppend(state, &s, 0, direction); + + FAIL_IF(state->dir_state[direction & STREAM_TOSERVER ? 0 : 1].head == NULL); + FAIL_IF(state->dir_state[direction & STREAM_TOSERVER ? 0 : 1].head->store[1].sid != 11); + FAIL_IF(state->dir_state[direction & STREAM_TOSERVER ? 0 : 1].head->next == NULL); + FAIL_IF(state->dir_state[direction & STREAM_TOSERVER ? 0 : 1].head->store[14].sid != 144); + FAIL_IF(state->dir_state[direction & STREAM_TOSERVER ? 0 : 1].head->next->store[0].sid != 155); + FAIL_IF(state->dir_state[direction & STREAM_TOSERVER ? 0 : 1].head->next->store[1].sid != 166); + DetectEngineStateFree(state); PASS;