Skip to content

Commit 6cdf2bd

Browse files
committed
goto_rw/range_spect: gracefully handle arbitrarily large ranges
When the value of an mp_integer doesn't fit into a range_spect::value_type we can safely fall back to using "unknown" instead, which is a safe over-approximation.
1 parent 35572f8 commit 6cdf2bd

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
CORE
2+
main.c
3+
--full-slice
4+
^\[main\.assertion\.\d+\] line 9 assertion havoc_slice W_OK.*: FAILURE$
5+
^\[main\.assertion\.\d+\] line 13 assertion havoc_slice W_OK.*: FAILURE$
6+
^\[main\.assertion\.\d+\] line 18 assertion havoc_slice W_OK.*: FAILURE$
7+
^\[main\.assertion\.\d+\] line 21 assertion havoc_slice W_OK.*: FAILURE$
8+
^\[main\.assertion\.\d+\] line 24 assertion havoc_slice W_OK.*: FAILURE$
9+
^\[main\.assertion\.\d+\] line 27 assertion havoc_slice W_OK.*: FAILURE$
10+
^\[main\.assertion\.\d+\] line 30 assertion havoc_slice W_OK.*: FAILURE$
11+
\*\* 7 of [0-9]+ failed \(.*\)
12+
^VERIFICATION FAILED$
13+
^EXIT=10$
14+
^SIGNAL=0$
15+
--

src/analyses/goto_rw.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,17 @@ class range_spect
7575

7676
static range_spect to_range_spect(const mp_integer &size)
7777
{
78-
PRECONDITION(size.is_long());
78+
if(!size.is_long())
79+
return range_spect::unknown();
80+
7981
mp_integer::llong_t ll = size.to_long();
80-
CHECK_RETURN(ll <= std::numeric_limits<range_spect::value_type>::max());
81-
CHECK_RETURN(ll >= std::numeric_limits<range_spect::value_type>::min());
82+
if(
83+
ll > std::numeric_limits<range_spect::value_type>::max() ||
84+
ll < std::numeric_limits<range_spect::value_type>::min())
85+
{
86+
return range_spect::unknown();
87+
}
88+
8289
return range_spect{(value_type)ll};
8390
}
8491

0 commit comments

Comments
 (0)