]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: tools: Don't try to anonymize a NULL string
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 15 Sep 2026 05:36:27 +0000 (07:36 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 18 Sep 2026 15:05:18 +0000 (17:05 +0200)
hash_anon() function is used to anonymize a string. It is called at several
places (via HA_ANON_* macros), especially from debugging functions. It is
hard to be sure the string to hash is always defined. So let's return
immediately if it is NULL.

Among other things, this fix avoids to get a crash when the server name
created by a LUA CO-SOCKET is anonymized. Indeed, this server is created
with no name.

This patch should fix the issue #3491. It must be backported as far as 2.8.

src/tools.c

index 62fd2bdcf2111aebf2344f07f9dc6c2c2ecec0bd..50e78389acd9f121e6ddc2e0238734d8a361e4ed 100644 (file)
@@ -7423,7 +7423,7 @@ const char *hash_anon(uint32_t scramble, const char *string2hash, const char *pr
                index_hash = 0;
 
        /* don't hash empty strings */
-       if (!string2hash[0] || (string2hash[0] == ' ' && string2hash[1] == 0))
+       if (!string2hash || !string2hash[0] || (string2hash[0] == ' ' && string2hash[1] == 0))
                return string2hash;
 
        if (scramble != 0) {