Remove case_state usage

The case_state in MPMs was just to track when a pid could have no-case and
case-sensitive matches for the same PID. Now that can't happen after fixing
bug 1110, so remove the code and storage for case_state.
pull/852/merge
Ken Steele 12 years ago committed by Victor Julien
parent c41041a9c7
commit 6b1517c0b8

@ -1202,16 +1202,7 @@ int SCACBSPreparePatterns(MpmCtx *mpm_ctx)
memset(ctx->pid_pat_list, 0, (ctx->max_pat_id + 1) * sizeof(SCACBSPatternList)); memset(ctx->pid_pat_list, 0, (ctx->max_pat_id + 1) * sizeof(SCACBSPatternList));
for (i = 0; i < mpm_ctx->pattern_cnt; i++) { for (i = 0; i < mpm_ctx->pattern_cnt; i++) {
if (ctx->parray[i]->flags & MPM_PATTERN_FLAG_NOCASE) { if (!(ctx->parray[i]->flags & MPM_PATTERN_FLAG_NOCASE)) {
if (ctx->pid_pat_list[ctx->parray[i]->id].case_state == 0)
ctx->pid_pat_list[ctx->parray[i]->id].case_state = 1;
else if (ctx->pid_pat_list[ctx->parray[i]->id].case_state == 1)
ctx->pid_pat_list[ctx->parray[i]->id].case_state = 1;
else
ctx->pid_pat_list[ctx->parray[i]->id].case_state = 3;
} else {
//if (memcmp(ctx->parray[i]->original_pat, ctx->parray[i]->ci,
// ctx->parray[i]->len) != 0) {
ctx->pid_pat_list[ctx->parray[i]->id].cs = SCMalloc(ctx->parray[i]->len); ctx->pid_pat_list[ctx->parray[i]->id].cs = SCMalloc(ctx->parray[i]->len);
if (ctx->pid_pat_list[ctx->parray[i]->id].cs == NULL) { if (ctx->pid_pat_list[ctx->parray[i]->id].cs == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory"); SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
@ -1220,14 +1211,6 @@ int SCACBSPreparePatterns(MpmCtx *mpm_ctx)
memcpy(ctx->pid_pat_list[ctx->parray[i]->id].cs, memcpy(ctx->pid_pat_list[ctx->parray[i]->id].cs,
ctx->parray[i]->original_pat, ctx->parray[i]->len); ctx->parray[i]->original_pat, ctx->parray[i]->len);
ctx->pid_pat_list[ctx->parray[i]->id].patlen = ctx->parray[i]->len; ctx->pid_pat_list[ctx->parray[i]->id].patlen = ctx->parray[i]->len;
if (ctx->pid_pat_list[ctx->parray[i]->id].case_state == 0)
ctx->pid_pat_list[ctx->parray[i]->id].case_state = 2;
else if (ctx->pid_pat_list[ctx->parray[i]->id].case_state == 2)
ctx->pid_pat_list[ctx->parray[i]->id].case_state = 2;
else
ctx->pid_pat_list[ctx->parray[i]->id].case_state = 3;
//}
} }
} }
@ -1495,10 +1478,8 @@ uint32_t SCACBSSearch(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx,
buf + i - pid_pat_list[pids[k] & 0x0000FFFF].patlen + 1, buf + i - pid_pat_list[pids[k] & 0x0000FFFF].patlen + 1,
pid_pat_list[pids[k] & 0x0000FFFF].patlen) != 0) { pid_pat_list[pids[k] & 0x0000FFFF].patlen) != 0) {
/* inside loop */ /* inside loop */
if (pid_pat_list[pids[k] & 0x0000FFFF].case_state != 3) {
continue; continue;
} }
}
if (pmq->pattern_id_bitarray[(pids[k] & 0x0000FFFF) / 8] & (1 << ((pids[k] & 0x0000FFFF) % 8))) { if (pmq->pattern_id_bitarray[(pids[k] & 0x0000FFFF) / 8] & (1 << ((pids[k] & 0x0000FFFF) % 8))) {
; ;
} else { } else {
@ -1578,10 +1559,8 @@ uint32_t SCACBSSearch(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx,
buf + i - pid_pat_list[pids[k] & 0x0000FFFF].patlen + 1, buf + i - pid_pat_list[pids[k] & 0x0000FFFF].patlen + 1,
pid_pat_list[pids[k] & 0x0000FFFF].patlen) != 0) { pid_pat_list[pids[k] & 0x0000FFFF].patlen) != 0) {
/* inside loop */ /* inside loop */
if (pid_pat_list[pids[k] & 0x0000FFFF].case_state != 3) {
continue; continue;
} }
}
if (pmq->pattern_id_bitarray[(pids[k] & 0x0000FFFF) / 8] & (1 << ((pids[k] & 0x0000FFFF) % 8))) { if (pmq->pattern_id_bitarray[(pids[k] & 0x0000FFFF) / 8] & (1 << ((pids[k] & 0x0000FFFF) % 8))) {
; ;
} else { } else {

@ -1,4 +1,4 @@
/* Copyright (C) 2007-2010 Open Information Security Foundation /* Copyright (C) 2007-2014 Open Information Security Foundation
* *
* You can copy, redistribute or modify this Program under the terms of * You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free * the GNU General Public License version 2 as published by the Free
@ -45,7 +45,6 @@ typedef struct SCACBSPattern_ {
typedef struct SCACBSPatternList_ { typedef struct SCACBSPatternList_ {
uint8_t *cs; uint8_t *cs;
uint16_t patlen; uint16_t patlen;
uint16_t case_state;
} SCACBSPatternList; } SCACBSPatternList;
typedef struct SCACBSOutputTable_ { typedef struct SCACBSOutputTable_ {

@ -1073,14 +1073,7 @@ int SCACGfbsPreparePatterns(MpmCtx *mpm_ctx)
memset(ctx->pid_pat_list, 0, (ctx->max_pat_id + 1) * sizeof(SCACGfbsPatternList)); memset(ctx->pid_pat_list, 0, (ctx->max_pat_id + 1) * sizeof(SCACGfbsPatternList));
for (i = 0; i < mpm_ctx->pattern_cnt; i++) { for (i = 0; i < mpm_ctx->pattern_cnt; i++) {
if (ctx->parray[i]->flags & MPM_PATTERN_FLAG_NOCASE) { if (!(ctx->parray[i]->flags & MPM_PATTERN_FLAG_NOCASE)) {
if (ctx->pid_pat_list[ctx->parray[i]->id].case_state == 0)
ctx->pid_pat_list[ctx->parray[i]->id].case_state = 1;
else if (ctx->pid_pat_list[ctx->parray[i]->id].case_state == 1)
ctx->pid_pat_list[ctx->parray[i]->id].case_state = 1;
else
ctx->pid_pat_list[ctx->parray[i]->id].case_state = 3;
} else {
ctx->pid_pat_list[ctx->parray[i]->id].cs = SCMalloc(ctx->parray[i]->len); ctx->pid_pat_list[ctx->parray[i]->id].cs = SCMalloc(ctx->parray[i]->len);
if (ctx->pid_pat_list[ctx->parray[i]->id].cs == NULL) { if (ctx->pid_pat_list[ctx->parray[i]->id].cs == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory"); SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
@ -1089,13 +1082,6 @@ int SCACGfbsPreparePatterns(MpmCtx *mpm_ctx)
memcpy(ctx->pid_pat_list[ctx->parray[i]->id].cs, memcpy(ctx->pid_pat_list[ctx->parray[i]->id].cs,
ctx->parray[i]->original_pat, ctx->parray[i]->len); ctx->parray[i]->original_pat, ctx->parray[i]->len);
ctx->pid_pat_list[ctx->parray[i]->id].patlen = ctx->parray[i]->len; ctx->pid_pat_list[ctx->parray[i]->id].patlen = ctx->parray[i]->len;
if (ctx->pid_pat_list[ctx->parray[i]->id].case_state == 0)
ctx->pid_pat_list[ctx->parray[i]->id].case_state = 2;
else if (ctx->pid_pat_list[ctx->parray[i]->id].case_state == 2)
ctx->pid_pat_list[ctx->parray[i]->id].case_state = 2;
else
ctx->pid_pat_list[ctx->parray[i]->id].case_state = 3;
} }
} }
@ -1404,10 +1390,8 @@ uint32_t SCACGfbsSearch(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx,
buf + i - pid_pat_list[pids[k] & 0x0000FFFF].patlen + 1, buf + i - pid_pat_list[pids[k] & 0x0000FFFF].patlen + 1,
pid_pat_list[pids[k] & 0x0000FFFF].patlen) != 0) { pid_pat_list[pids[k] & 0x0000FFFF].patlen) != 0) {
/* inside loop */ /* inside loop */
if (pid_pat_list[pids[k] & 0x0000FFFF].case_state != 3) {
continue; continue;
} }
}
if (pmq->pattern_id_bitarray[(pids[k] & 0x0000FFFF) / 8] & (1 << ((pids[k] & 0x0000FFFF) % 8))) { if (pmq->pattern_id_bitarray[(pids[k] & 0x0000FFFF) / 8] & (1 << ((pids[k] & 0x0000FFFF) % 8))) {
; ;
@ -1531,9 +1515,6 @@ uint32_t SCACGfbsSearch(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx,
buf + i - pid_pat_list[pids[k] & 0x0000FFFF].patlen + 1, buf + i - pid_pat_list[pids[k] & 0x0000FFFF].patlen + 1,
pid_pat_list[pids[k] & 0x0000FFFF].patlen) != 0) { pid_pat_list[pids[k] & 0x0000FFFF].patlen) != 0) {
/* inside loop */ /* inside loop */
if (pid_pat_list[pids[k] & 0x0000FFFF].case_state != 3) {
continue;
}
continue; continue;
} }

@ -1,4 +1,4 @@
/* Copyright (C) 2007-2010 Open Information Security Foundation /* Copyright (C) 2007-2014 Open Information Security Foundation
* *
* You can copy, redistribute or modify this Program under the terms of * You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free * the GNU General Public License version 2 as published by the Free
@ -45,7 +45,6 @@ typedef struct SCACGfbsPattern_ {
typedef struct SCACGfbsPatternList_ { typedef struct SCACGfbsPatternList_ {
uint8_t *cs; uint8_t *cs;
uint16_t patlen; uint16_t patlen;
uint16_t case_state;
} SCACGfbsPatternList; } SCACGfbsPatternList;
typedef struct SCACGfbsOutputTable_ { typedef struct SCACGfbsOutputTable_ {

@ -1202,14 +1202,7 @@ int SCACTilePreparePatterns(MpmCtx *mpm_ctx)
memset(ctx->pid_pat_list, 0, (ctx->max_pat_id + 1) * sizeof(SCACTilePatternList)); memset(ctx->pid_pat_list, 0, (ctx->max_pat_id + 1) * sizeof(SCACTilePatternList));
for (i = 0; i < mpm_ctx->pattern_cnt; i++) { for (i = 0; i < mpm_ctx->pattern_cnt; i++) {
if (ctx->parray[i]->flags & MPM_PATTERN_FLAG_NOCASE) { if (!(ctx->parray[i]->flags & MPM_PATTERN_FLAG_NOCASE)) {
if (ctx->pid_pat_list[ctx->parray[i]->id].case_state == 0)
ctx->pid_pat_list[ctx->parray[i]->id].case_state = 1;
else if (ctx->pid_pat_list[ctx->parray[i]->id].case_state == 1)
ctx->pid_pat_list[ctx->parray[i]->id].case_state = 1;
else
ctx->pid_pat_list[ctx->parray[i]->id].case_state = 3;
} else {
ctx->pid_pat_list[ctx->parray[i]->id].cs = SCMalloc(ctx->parray[i]->len); ctx->pid_pat_list[ctx->parray[i]->id].cs = SCMalloc(ctx->parray[i]->len);
if (ctx->pid_pat_list[ctx->parray[i]->id].cs == NULL) { if (ctx->pid_pat_list[ctx->parray[i]->id].cs == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory"); SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
@ -1218,13 +1211,6 @@ int SCACTilePreparePatterns(MpmCtx *mpm_ctx)
memcpy(ctx->pid_pat_list[ctx->parray[i]->id].cs, memcpy(ctx->pid_pat_list[ctx->parray[i]->id].cs,
ctx->parray[i]->original_pat, ctx->parray[i]->len); ctx->parray[i]->original_pat, ctx->parray[i]->len);
ctx->pid_pat_list[ctx->parray[i]->id].patlen = ctx->parray[i]->len; ctx->pid_pat_list[ctx->parray[i]->id].patlen = ctx->parray[i]->len;
if (ctx->pid_pat_list[ctx->parray[i]->id].case_state == 0)
ctx->pid_pat_list[ctx->parray[i]->id].case_state = 2;
else if (ctx->pid_pat_list[ctx->parray[i]->id].case_state == 2)
ctx->pid_pat_list[ctx->parray[i]->id].case_state = 2;
else
ctx->pid_pat_list[ctx->parray[i]->id].case_state = 3;
} }
} }
@ -1436,11 +1422,9 @@ int CheckMatch(SCACTileSearchCtx *ctx, PatternMatcherQueue *pmq,
uint16_t patlen = pid_pat_list[lower_pid].patlen; uint16_t patlen = pid_pat_list[lower_pid].patlen;
if (SCMemcmp(pid_pat_list[lower_pid].cs, buf_offset - patlen, patlen) != 0) { if (SCMemcmp(pid_pat_list[lower_pid].cs, buf_offset - patlen, patlen) != 0) {
/* inside loop */ /* inside loop */
if (pid_pat_list[lower_pid].case_state != 3) {
continue; continue;
} }
} }
}
if (bitarray[(lower_pid) / 8] & (1 << ((lower_pid) % 8))) { if (bitarray[(lower_pid) / 8] & (1 << ((lower_pid) % 8))) {
; ;
} else { } else {
@ -1507,10 +1491,8 @@ uint32_t SCACTileSearchLarge(SCACTileSearchCtx *ctx, MpmThreadCtx *mpm_thread_ct
buf + i - pid_pat_list[pids[k] & 0x0000FFFF].patlen + 1, buf + i - pid_pat_list[pids[k] & 0x0000FFFF].patlen + 1,
pid_pat_list[pids[k] & 0x0000FFFF].patlen) != 0) { pid_pat_list[pids[k] & 0x0000FFFF].patlen) != 0) {
/* inside loop */ /* inside loop */
if (pid_pat_list[pids[k] & 0x0000FFFF].case_state != 3) {
continue; continue;
} }
}
if (pmq->pattern_id_bitarray[(pids[k] & 0x0000FFFF) / 8] & if (pmq->pattern_id_bitarray[(pids[k] & 0x0000FFFF) / 8] &
(1 << ((pids[k] & 0x0000FFFF) % 8))) { (1 << ((pids[k] & 0x0000FFFF) % 8))) {
; ;

@ -1,4 +1,4 @@
/* Copyright (C) 2013 Open Information Security Foundation /* Copyright (C) 2013-2014 Open Information Security Foundation
* *
* You can copy, redistribute or modify this Program under the terms of * You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free * the GNU General Public License version 2 as published by the Free
@ -46,7 +46,6 @@ typedef struct SCACTilePattern_ {
typedef struct SCACTilePatternList_ { typedef struct SCACTilePatternList_ {
uint8_t *cs; uint8_t *cs;
uint16_t patlen; uint16_t patlen;
uint16_t case_state;
} SCACTilePatternList; } SCACTilePatternList;
typedef struct SCACTileOutputTable_ { typedef struct SCACTileOutputTable_ {

@ -1,4 +1,4 @@
/* Copyright (C) 2007-2010 Open Information Security Foundation /* Copyright (C) 2007-2014 Open Information Security Foundation
* *
* You can copy, redistribute or modify this Program under the terms of * You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free * the GNU General Public License version 2 as published by the Free
@ -1006,16 +1006,7 @@ int SCACPreparePatterns(MpmCtx *mpm_ctx)
memset(ctx->pid_pat_list, 0, (ctx->max_pat_id + 1) * sizeof(SCACPatternList)); memset(ctx->pid_pat_list, 0, (ctx->max_pat_id + 1) * sizeof(SCACPatternList));
for (i = 0; i < mpm_ctx->pattern_cnt; i++) { for (i = 0; i < mpm_ctx->pattern_cnt; i++) {
if (ctx->parray[i]->flags & MPM_PATTERN_FLAG_NOCASE) { if (!(ctx->parray[i]->flags & MPM_PATTERN_FLAG_NOCASE)) {
if (ctx->pid_pat_list[ctx->parray[i]->id].case_state == 0)
ctx->pid_pat_list[ctx->parray[i]->id].case_state = 1;
else if (ctx->pid_pat_list[ctx->parray[i]->id].case_state == 1)
ctx->pid_pat_list[ctx->parray[i]->id].case_state = 1;
else
ctx->pid_pat_list[ctx->parray[i]->id].case_state = 3;
} else {
//if (memcmp(ctx->parray[i]->original_pat, ctx->parray[i]->ci,
// ctx->parray[i]->len) != 0) {
ctx->pid_pat_list[ctx->parray[i]->id].cs = SCMalloc(ctx->parray[i]->len); ctx->pid_pat_list[ctx->parray[i]->id].cs = SCMalloc(ctx->parray[i]->len);
if (ctx->pid_pat_list[ctx->parray[i]->id].cs == NULL) { if (ctx->pid_pat_list[ctx->parray[i]->id].cs == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory"); SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
@ -1024,14 +1015,6 @@ int SCACPreparePatterns(MpmCtx *mpm_ctx)
memcpy(ctx->pid_pat_list[ctx->parray[i]->id].cs, memcpy(ctx->pid_pat_list[ctx->parray[i]->id].cs,
ctx->parray[i]->original_pat, ctx->parray[i]->len); ctx->parray[i]->original_pat, ctx->parray[i]->len);
ctx->pid_pat_list[ctx->parray[i]->id].patlen = ctx->parray[i]->len; ctx->pid_pat_list[ctx->parray[i]->id].patlen = ctx->parray[i]->len;
if (ctx->pid_pat_list[ctx->parray[i]->id].case_state == 0)
ctx->pid_pat_list[ctx->parray[i]->id].case_state = 2;
else if (ctx->pid_pat_list[ctx->parray[i]->id].case_state == 2)
ctx->pid_pat_list[ctx->parray[i]->id].case_state = 2;
else
ctx->pid_pat_list[ctx->parray[i]->id].case_state = 3;
//}
} }
} }
@ -1264,10 +1247,8 @@ uint32_t SCACSearch(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx,
buf + i - pid_pat_list[pids[k] & 0x0000FFFF].patlen + 1, buf + i - pid_pat_list[pids[k] & 0x0000FFFF].patlen + 1,
pid_pat_list[pids[k] & 0x0000FFFF].patlen) != 0) { pid_pat_list[pids[k] & 0x0000FFFF].patlen) != 0) {
/* inside loop */ /* inside loop */
if (pid_pat_list[pids[k] & 0x0000FFFF].case_state != 3) {
continue; continue;
} }
}
if (pmq->pattern_id_bitarray[(pids[k] & 0x0000FFFF) / 8] & (1 << ((pids[k] & 0x0000FFFF) % 8))) { if (pmq->pattern_id_bitarray[(pids[k] & 0x0000FFFF) / 8] & (1 << ((pids[k] & 0x0000FFFF) % 8))) {
; ;
} else { } else {
@ -1305,10 +1286,8 @@ uint32_t SCACSearch(MpmCtx *mpm_ctx, MpmThreadCtx *mpm_thread_ctx,
buf + i - pid_pat_list[pids[k] & 0x0000FFFF].patlen + 1, buf + i - pid_pat_list[pids[k] & 0x0000FFFF].patlen + 1,
pid_pat_list[pids[k] & 0x0000FFFF].patlen) != 0) { pid_pat_list[pids[k] & 0x0000FFFF].patlen) != 0) {
/* inside loop */ /* inside loop */
if (pid_pat_list[pids[k] & 0x0000FFFF].case_state != 3) {
continue; continue;
} }
}
if (pmq->pattern_id_bitarray[(pids[k] & 0x0000FFFF) / 8] & (1 << ((pids[k] & 0x0000FFFF) % 8))) { if (pmq->pattern_id_bitarray[(pids[k] & 0x0000FFFF) / 8] & (1 << ((pids[k] & 0x0000FFFF) % 8))) {
; ;
} else { } else {
@ -1973,10 +1952,8 @@ uint32_t SCACCudaPacketResultsProcessing(Packet *p, MpmCtx *mpm_ctx,
buf + offset - pid_pat_list[pids[k] & 0x0000FFFF].patlen + 1, buf + offset - pid_pat_list[pids[k] & 0x0000FFFF].patlen + 1,
pid_pat_list[pids[k] & 0x0000FFFF].patlen) != 0) { pid_pat_list[pids[k] & 0x0000FFFF].patlen) != 0) {
/* inside loop */ /* inside loop */
if (pid_pat_list[pids[k] & 0x0000FFFF].case_state != 3) {
continue; continue;
} }
}
if (pmq->pattern_id_bitarray[(pids[k] & 0x0000FFFF) / 8] & (1 << ((pids[k] & 0x0000FFFF) % 8))) { if (pmq->pattern_id_bitarray[(pids[k] & 0x0000FFFF) / 8] & (1 << ((pids[k] & 0x0000FFFF) % 8))) {
; ;
} else { } else {

@ -1,4 +1,4 @@
/* Copyright (C) 2007-2010 Open Information Security Foundation /* Copyright (C) 2007-2014 Open Information Security Foundation
* *
* You can copy, redistribute or modify this Program under the terms of * You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free * the GNU General Public License version 2 as published by the Free
@ -58,7 +58,6 @@ typedef struct SCACPattern_ {
typedef struct SCACPatternList_ { typedef struct SCACPatternList_ {
uint8_t *cs; uint8_t *cs;
uint16_t patlen; uint16_t patlen;
uint16_t case_state;
} SCACPatternList; } SCACPatternList;
typedef struct SCACOutputTable_ { typedef struct SCACOutputTable_ {

Loading…
Cancel
Save