BUG/MEDIUM: server: fix crash after duplicate GUID insertion
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 22 May 2025 15:48:58 +0000 (17:48 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 27 May 2025 13:15:27 +0000 (15:15 +0200)
commitcf571a65c28db518c0220617b60035f73c52ace5
tree9870e10326e9671325ed5397e26625e74052acd5
parentbb1eb4f117865b8cba66cacafb721c4f67d6c28e
BUG/MEDIUM: server: fix crash after duplicate GUID insertion

On "add server", if a GUID is defined, guid_insert() is used to add the
entry into the global GUID tree. If a similar entry already exists, GUID
insertion fails and the server creation is eventually aborted.

A crash could occur in this case because of an invalid memory access via
guid_remove(). The latter is caused via free_server() as the server
insertion is rejected. The invalid occurs on GUID key.

The issue occurs because of guid_insert(). The function properly
deallocates the GUID key on duplicate insertion, but it failed to reset
<guid.node.key> to NULL. This caused the invalid memory access on
guid_remove(). To fix this, ensure that key member is properly resetted
on guid_insert() error path.

This must be backported up to 3.0.

(cherry picked from commit b40ce97ecca0e43c45f6a15e3a7184436d5cb467)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit dfde7bd6b0b6f5e87e4ab65059f9a86219c55c95)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
src/guid.c