diff options
author | Kuan-Wei Chiu <visitorckw@gmail.com> | 2024-12-19 02:09:57 +0800 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2024-12-18 23:30:39 +0100 |
commit | 87d9e5405a7e634b01031699ebb20fd02cb01db2 (patch) | |
tree | 68dd9fa5987bd982b985b59e3bc0cd2aa4d8464e /docs/examples/multithread.c | |
parent | 302bd6b385b3b73e52ce9a2cd25ef626b1b0fcac (diff) |
http_aws_sigv4: Fix invalid compare function handling zero-length pairs
The compare_func() can violate the antisymmetric property required by
qsort. Specifically, when both aa->len == 0 and bb->len == 0, the
function returns conflicting results (-1 for compare_func(a, b) and -1
for compare_func(b, a)).
This violates the rules of qsort and may lead to undefined behavior,
including incorrect sorting or memory corruption in glibc [1].
Add a check to return 0 when both lengths are zero, ensuring proper
behavior and preventing undefined behavior in the sorting process.
Ref: https://www.qualys.com/2024/01/30/qsort.txt [1]
Closes #15778
Diffstat (limited to 'docs/examples/multithread.c')
0 files changed, 0 insertions, 0 deletions