mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-25 11:37:56 +00:00
expr(1): Fix overflow detection when operand is INTMAX_MIN
PR: 227329 Submitted by: Tobias Stoeckmann <tobias AT stoeckmann.org>
This commit is contained in:
parent
f6e61711ed
commit
41bd31e656
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=332499
@ -422,11 +422,9 @@ op_plus(struct val *a, struct val *b)
|
||||
void
|
||||
assert_minus(intmax_t a, intmax_t b, intmax_t r)
|
||||
{
|
||||
/* special case subtraction of INTMAX_MIN */
|
||||
if (b == INTMAX_MIN && a < 0)
|
||||
if ((a >= 0 && b < 0 && r <= 0) ||
|
||||
(a < 0 && b > 0 && r >= 0))
|
||||
errx(ERR_EXIT, "overflow");
|
||||
/* check addition of negative subtrahend */
|
||||
assert_plus(a, -b, r);
|
||||
}
|
||||
|
||||
struct val *
|
||||
|
Loading…
Reference in New Issue
Block a user