File tree Expand file tree Collapse file tree 6 files changed +50
-27
lines changed
pointer-primitive-check-03 Expand file tree Collapse file tree 6 files changed +50
-27
lines changed Original file line number Diff line number Diff line change 1+ #include <stdlib.h>
2+
3+ int main ()
4+ {
5+ size_t s ;
6+ char * p = malloc (s );
7+ // at __CPROVER_max_malloc_size p + s would overflow; all larger values of s
8+ // make malloc return NULL when using --malloc-fail-null
9+ if (p != NULL && s != __CPROVER_max_malloc_size )
10+ {
11+ char * q = p + s ;
12+ __CPROVER_assert (__CPROVER_r_ok (q , 0 ), "should be valid" );
13+ __CPROVER_assert (!__CPROVER_r_ok (q + 1 , 0 ), "should fail" );
14+ }
15+ }
Original file line number Diff line number Diff line change 1+ CORE broken-smt-backend
2+ at_bounds1.c
3+ --pointer-primitive-check --malloc-fail-null
4+ ^\[main.pointer_primitives.\d+\] line 13 pointer outside object bounds in R_OK\(q \+ (\(signed (long (long )?)?int\))?1, (\(unsigned (long (long )?)?int\))?0\): FAILURE$
5+ ^\*\* 1 of \d+ failed
6+ ^VERIFICATION FAILED$
7+ ^EXIT=10$
8+ ^SIGNAL=0$
9+ --
10+ ^warning: ignoring
11+ --
12+ Verifies that the check succeeds when pointing to one-beyond-object-bounds.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -22,7 +22,8 @@ void main()
2222 // offset out of bounds
2323 char * p5 = malloc (10 );
2424 p5 += 10 ;
25- __CPROVER_r_ok (p5 , 1 );
25+ _Bool result = __CPROVER_r_ok (p5 , 1 );
26+ __CPROVER_assert (!result , "should be false" );
2627
2728 // dead
2829 char * p6 ;
Original file line number Diff line number Diff line change 1+ CORE
2+ main.c
3+ --pointer-primitive-check
4+ ^EXIT=10$
5+ ^SIGNAL=0$
6+ ^\[main.pointer_primitives.\d+\] line 7 pointer invalid in R_OK\(p1, \(unsigned (long (long )?)?int\)1\): FAILURE$
7+ ^\[main.pointer_primitives.\d+\] line 7 pointer outside object bounds in R_OK\(p1, \(unsigned (long (long )?)?int\)1\): FAILURE$
8+ ^\[main.pointer_primitives.\d+\] line 11 pointer invalid in R_OK\(p2, \(unsigned (long (long )?)?int\)1\): FAILURE$
9+ ^\[main.pointer_primitives.\d+\] line 11 pointer outside object bounds in R_OK\(p2, \(unsigned (long (long )?)?int\)1\): FAILURE$
10+ ^\[main.pointer_primitives.\d+\] line 15 pointer outside object bounds in R_OK\(p3, \(unsigned (long (long )?)?int\)1\): FAILURE$
11+ ^\[main.pointer_primitives.\d+\] line 20 pointer outside object bounds in R_OK\(p4, \(unsigned (long (long )?)?int\)1\): FAILURE$
12+ ^\[main.pointer_primitives.\d+\] line 34 dead object in R_OK\(p6, \(unsigned (long (long )?)?int\)1\): FAILURE$
13+ ^\[main.pointer_primitives.\d+\] line 40 deallocated dynamic object in R_OK\(p7, \(unsigned (long (long )?)?int\)1\): FAILURE$
14+ ^\*\* 8 of \d+ failed
15+ --
16+ ^warning: ignoring
17+ --
18+ Verifies that the pointer primitives check fails for the various forms of
19+ invalid pointers
Original file line number Diff line number Diff line change @@ -1454,15 +1454,8 @@ void goto_check_ct::pointer_primitive_check(
14541454 return ;
14551455 }
14561456
1457- const auto size_of_expr_opt =
1458- size_of_expr (to_pointer_type (pointer.type ()).base_type (), ns);
1459-
1460- const exprt size = !size_of_expr_opt.has_value ()
1461- ? from_integer (1 , size_type ())
1462- : size_of_expr_opt.value ();
1463-
1464- const conditionst &conditions =
1465- get_pointer_points_to_valid_memory_conditions (pointer, size);
1457+ const conditionst &conditions = get_pointer_points_to_valid_memory_conditions (
1458+ pointer, from_integer (0 , size_type ()));
14661459 for (const auto &c : conditions)
14671460 {
14681461 add_guarded_property (
You can’t perform that action at this time.
0 commit comments