From f2e777e3a5fa5ee9d419b3fc2528b3f37e4696cd Mon Sep 17 00:00:00 2001 From: Ken Steele Date: Tue, 24 Jun 2014 14:43:58 -0400 Subject: [PATCH] Fix lowercase table initialization (bug 1221) The for loop needed to check for < 256, not < 255. --- src/suricata.c | 6 +++--- src/util-mpm-ac.c | 2 +- src/util-mpm-wumanber.c | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/suricata.c b/src/suricata.c index 4117492a55..bcba8dcbf8 100644 --- a/src/suricata.c +++ b/src/suricata.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2007-2013 Open Information Security Foundation +/* Copyright (C) 2007-2014 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free @@ -346,9 +346,9 @@ void CreateLowercaseTable() { /* create table for O(1) lowercase conversion lookup. It was removed, but * we still need it for cuda. So resintalling it back into the codebase */ - uint8_t c = 0; + int c = 0; memset(g_u8_lowercasetable, 0x00, sizeof(g_u8_lowercasetable)); - for ( ; c < 255; c++) { + for ( ; c < 256; c++) { if (c >= 'A' && c <= 'Z') g_u8_lowercasetable[c] = (c + ('a' - 'A')); else diff --git a/src/util-mpm-ac.c b/src/util-mpm-ac.c index 800e3db9f3..a181da102c 100644 --- a/src/util-mpm-ac.c +++ b/src/util-mpm-ac.c @@ -1711,7 +1711,7 @@ static void *SCACCudaDispatcher(void *arg) #endif uint8_t g_u8_lowercasetable[256]; - for (uint8_t c = 0; c < 255; c++) + for (int c = 0; c < 256; c++) g_u8_lowercasetable[c] = tolower((uint8_t)c); CUdeviceptr cuda_g_u8_lowercasetable_d = 0; CUdeviceptr cuda_packets_buffer_d = 0; diff --git a/src/util-mpm-wumanber.c b/src/util-mpm-wumanber.c index 80d1d1581e..648da6a30b 100644 --- a/src/util-mpm-wumanber.c +++ b/src/util-mpm-wumanber.c @@ -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 * the GNU General Public License version 2 as published by the Free @@ -1441,8 +1441,8 @@ void MpmWuManberRegister (void) { mpm_table[MPM_WUMANBER].RegisterUnittests = WmRegisterTests; /* create table for O(1) lowercase conversion lookup */ - uint8_t c = 0; - for ( ; c < 255; c++) { + int c = 0; + for ( ; c < 256; c++) { if (c >= 'A' && c <= 'Z') lowercasetable[c] = (c + ('a' - 'A')); else