From: Victor Julien Date: Tue, 16 Dec 2014 18:12:20 +0000 (+0100) Subject: memcmp: compare the first byte as well X-Git-Tag: suricata-2.1beta3~56 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=17dfd59bc31a21e103e2f1216443cd1418398aa9;p=thirdparty%2Fsuricata.git memcmp: compare the first byte as well MemcmpLowercase would not compare the first byte of both input buffers leading to two non-identical buffers to be considered the same. Affects SSE_4_1 and SSE_4_2 implementations of SCMemcmpLowercase, as well as the non-SIMD implementation. SSE_3 and Tile version are not affected. --- diff --git a/src/util-memcmp.h b/src/util-memcmp.h index 4a5be891ee..875652b109 100644 --- a/src/util-memcmp.h +++ b/src/util-memcmp.h @@ -41,12 +41,12 @@ void MemcmpRegisterTests(void); static inline int MemcmpLowercase(const void *s1, const void *s2, size_t n) { - size_t i; + ssize_t i; /* check backwards because we already tested the first * 2 to 4 chars. This way we are more likely to detect * a miss and thus speed up a little... */ - for (i = n - 1; i; i--) { + for (i = n - 1; i >= 0; i--) { if (((uint8_t *)s1)[i] != u8_tolower(*(((uint8_t *)s2)+i))) return 1; }