]> git.kaiwu.me - haproxy.git/commit
BUG/MINOR: tools: my_memspn/my_memcspn wrong cast causing incorrect byte reading
authorWilly Tarreau <w@1wt.eu>
Sun, 26 Apr 2026 21:00:38 +0000 (23:00 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 27 Apr 2026 12:44:29 +0000 (14:44 +0200)
commit84cb8dd1263c8c5fe1a4f82a8fbb858f9493c88e
treec4c839b58da448e544e8ddda9341a4dab2f8a28a
parentc6600d7835bd53f63fadaf9ff7b80715f1cb4764
BUG/MINOR: tools: my_memspn/my_memcspn wrong cast causing incorrect byte reading

Both functions cast void * to int * and dereference, reading 4 bytes as an
integer instead of a single byte. This is passed to memchr() which expects a
byte value. On unaligned addresses this causes crashes on ARM/mips etc, and
search for the wrong byte on big endian platforms. Fixed to cast to
const unsigned char * and dereference a single byte. This is marked as
minor because these functions were added in 2.2 by commit 5eb96cbcbc
("MINOR: standard: Add my_memspn and my_memcspn") and have not been used
since then.
src/tools.c