]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
mpm/ac-ks: address int handling issues
authorVictor Julien <vjulien@oisf.net>
Tue, 26 Apr 2022 18:14:39 +0000 (20:14 +0200)
committerVictor Julien <vjulien@oisf.net>
Wed, 27 Apr 2022 10:18:06 +0000 (12:18 +0200)
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.

src/util-mpm-ac-ks.c

index 1e487d28f8914d8385fb2baff3c37b84ef8a029b..5f6dbf9d328ea10b6b2546b6833bc466cf3ffcbb 100644 (file)
@@ -603,7 +603,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;
 }
@@ -1449,7 +1449,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");
 }