Skip to content

Commit

Permalink
The overflow check mul_overflows_s64(int64_t, int64_t) overflows and …
Browse files Browse the repository at this point in the history
…triggers UB :-) Remove it

The overflow check `mul_overflows_s64(int64_t, int64_t)` overflows.
Since this is an signed integer overflow this triggers UB, which
in turn means that we cannot trust the check.

Luckily mul_overflows_s64(int64_t, int64_t) is unused. Removing it.
  • Loading branch information
practicalswift authored and rustyrussell committed Mar 27, 2018
1 parent f2e81fd commit 8df29d1
Showing 1 changed file with 0 additions and 10 deletions.
10 changes: 0 additions & 10 deletions common/overflows.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,6 @@ static inline bool add_overflows_u64(uint64_t a, uint64_t b)
return (a + b) < a;
}

static inline bool mul_overflows_s64(int64_t a, int64_t b)
{
int64_t ret;

if (a == 0)
return false;
ret = a * b;
return (ret / a != b);
}

static inline bool mul_overflows_u64(uint64_t a, uint64_t b)
{
uint64_t ret;
Expand Down

0 comments on commit 8df29d1

Please sign in to comment.