]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: sample: Fix wrong overflow detection in add/sub conveters
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 17 Jul 2023 06:35:11 +0000 (08:35 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 17 Jul 2023 09:14:10 +0000 (11:14 +0200)
commitb982fc21770d433a2edfac1336974d289316b271
treeb9ef67fb40d77711d8f39071149120f6235d6a56
parent46e5876035d17eb5d9daf1ad9d4682a955fc1942
BUG/MINOR: sample: Fix wrong overflow detection in add/sub conveters

When "add" or "sub" conveters are used, an overflow detection is performed.
When 2 negative integers are added (or a positive integer is substracted to
a positive one), we take care to not exceed the low limit (LLONG_MIN) and
when 2 positive integers are added, we take care to not exceed the high
limit (LLONG_MAX).

However, because of a missing 'else' statement, if there is no overflow in
the first case, we fall back on the second check (the one for positive adds)
and LLONG_MAX is returned. It means that most of time, when 2 negative
integers are added (or a positive integer is substracted to a negative one),
LLONG_MAX is returned.

This patch should solve the issue #2216. It must be backported to all stable
versions.
src/sample.c