Summary: | [patch] expr(1) doesn't detect some overflow errors with multiplication | ||
---|---|---|---|
Product: | Base System | Reporter: | Enji Cooper <ngie> |
Component: | bin | Assignee: | freebsd-bugs (Nobody) <bugs> |
Status: | Closed DUPLICATE | ||
Severity: | Affects Some People | CC: | jilles |
Priority: | --- | ||
Version: | CURRENT | ||
Hardware: | Any | ||
OS: | Any |
Description
Enji Cooper
![]() ![]() A proposed fix can be found here: https://github.com/yaneurabeya/freebsd/commit/14fd327099ddd5421b095a46fdb9077c07dcc6e7 . It passes all of the (slightly) modified NetBSD t_expr testcases. All the overflow checks except for division and modulo are fundamentally broken because they first let overflow happen and then attempt to check for it. Since signed integer overflow is undefined behaviour, this allows the compiler to optimize the overflow checks away, or worse. Also, INTMAX_MIN modulo -1 causes SIGFPE on amd64, like expr -e -- $((-0x7fffffffffffffff - 1)) % -1 Either op_rem() should not sabotage assert_div()'s check or op_rem() should return a zero-valued integer for anything modulo -1. se@ is resolving this as part of PR 196867. Resolving as a duplicate. *** This bug has been marked as a duplicate of bug 196867 *** |