From 0a91d824bfd0751f08916b41a77ef76b038186ce Mon Sep 17 00:00:00 2001 From: Anoop Saldanha Date: Tue, 7 Feb 2012 00:52:45 +0530 Subject: [PATCH] Fix bug in ac-bs search function --- src/util-mpm-ac-bs.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/util-mpm-ac-bs.c b/src/util-mpm-ac-bs.c index ce7e99b23d..9e08a2344c 100644 --- a/src/util-mpm-ac-bs.c +++ b/src/util-mpm-ac-bs.c @@ -1430,9 +1430,12 @@ uint32_t SCACBSSearch(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, state = *(ascii_codes + no_of_entries);; } else { state = zero_state[buf_local]; - continue; } } else { + if (no_of_entries == 0) { + state = zero_state[u8_tolower(buf[i])]; + goto match_u16; + } buf_local = u8_tolower(buf[i]); ascii_codes = state_table_mod_pointers[state & 0x7FFF] + 1; int low = 0; @@ -1451,7 +1454,6 @@ uint32_t SCACBSSearch(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, } } /* while */ state = zero_state[buf_local]; - continue; } /* else - if (no_of_entires == 1) */ } @@ -1502,7 +1504,6 @@ uint32_t SCACBSSearch(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, for (i = 0; i < buflen; i++) { if (state == 0) { state = zero_state[u8_tolower(buf[i])]; - continue; } else { no_of_entries = *(state_table_mod_pointers[state & 0x00FFFFFF]); if (no_of_entries == 1) { @@ -1512,9 +1513,12 @@ uint32_t SCACBSSearch(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, state = *(ascii_codes + no_of_entries);; } else { state = zero_state[buf_local];; - continue; } } else { + if (no_of_entries == 0) { + state = zero_state[u8_tolower(buf[i])]; + goto match_u32; + } buf_local = u8_tolower(buf[i]); ascii_codes = state_table_mod_pointers[state & 0x00FFFFFF] + 1; int low = 0; @@ -1533,7 +1537,6 @@ uint32_t SCACBSSearch(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx, } } /* while */ state = zero_state[buf_local]; - continue; } /* else - if (no_of_entires == 1) */ }