From: Victor Julien Date: Tue, 26 Apr 2022 18:14:39 +0000 (+0200) Subject: mpm/ac-ks: address int handling issues X-Git-Tag: suricata-5.0.10~64 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=733795dc005322362bec0e49029a75a8113315df;p=thirdparty%2Fsuricata.git mpm/ac-ks: address int handling issues cppcheck: src/util-mpm-ac-ks.c:1452:5: warning: %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint] printf("Total states in the state table: %d\n", ctx->state_count); ^ src/util-mpm-ac-ks.c:606:34: error: Signed integer overflow for expression '1<<31'. [integerOverflow] encoded_next_state |= (1 << 31); ^ Bug: #5291. (cherry picked from commit a8d3cd6eb4f181000256986ea7cf83074a0d2b59) --- diff --git a/src/util-mpm-ac-ks.c b/src/util-mpm-ac-ks.c index cb521decd2..76b9933957 100644 --- a/src/util-mpm-ac-ks.c +++ b/src/util-mpm-ac-ks.c @@ -607,7 +607,7 @@ static void SCACTileSetState4Bytes(SCACTileCtx *ctx, int state, int aa, } if (outputs == 0) - encoded_next_state |= (1 << 31); + encoded_next_state |= (1UL << 31); state_table[state * ctx->alphabet_storage + aa] = encoded_next_state; } @@ -1454,7 +1454,7 @@ void SCACTilePrintInfo(MpmCtx *mpm_ctx) printf("Unique Patterns: %" PRIu32 "\n", mpm_ctx->pattern_cnt); printf("Smallest: %" PRIu32 "\n", mpm_ctx->minlen); printf("Largest: %" PRIu32 "\n", mpm_ctx->maxlen); - printf("Total states in the state table: %d\n", ctx->state_count); + printf("Total states in the state table: %u\n", ctx->state_count); printf("\n"); }