]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: anon: memory illegal accesses in tools.c with hash_anon and hash_ipanon
authorErwan Le Goas <elegoas@haproxy.com>
Wed, 21 Sep 2022 14:24:23 +0000 (16:24 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 22 Sep 2022 13:44:13 +0000 (15:44 +0200)
chipitsine reported in github issue #1872 that in function hash_anon and
hash_ipanon, index_hash can be equal to NB_L_HASH_WORD and can reach an
inexisting line table, the table is initialized hash_word[NB_L_HASH_WORD][20];
so hash_word[NB_L_HASH_WORD] doesn't exist.

No backport needed, except if anonymization mechanism is backported.

src/tools.c

index 474b7df315cc78866a875e74ddeb956dc44d7e8a..f697eaccb976bc3bbbc3c12d4682073c06fc0d20 100644 (file)
@@ -5858,7 +5858,7 @@ void update_word_fingerprint(uint8_t *fp, const char *word)
 const char *hash_anon(uint32_t scramble, const char *string2hash, const char *prefix, const char *suffix)
 {
        index_hash++;
-       if (index_hash > NB_L_HASH_WORD)
+       if (index_hash == NB_L_HASH_WORD)
                index_hash = 0;
 
        /* don't hash empty strings */
@@ -5885,7 +5885,7 @@ const char *hash_ipanon(uint32_t scramble, char *ipstring)
        int port;
 
        index_hash++;
-        if (index_hash > NB_L_HASH_WORD) {
+        if (index_hash == NB_L_HASH_WORD) {
                 index_hash = 0;
        }