@@ -114,12 +114,11 @@ __CPROVER_HIDE:;
114
114
((ptr == 0 ) | __CPROVER_rw_ok (ptr , size )),
115
115
"ptr NULL or writable up to size" );
116
116
__CPROVER_assert (
117
- size < __CPROVER_max_malloc_size ,
117
+ size <= __CPROVER_max_malloc_size ,
118
118
"CAR size is less than __CPROVER_max_malloc_size" );
119
- __CPROVER_ssize_t offset = __CPROVER_POINTER_OFFSET (ptr );
119
+ __CPROVER_size_t offset = __CPROVER_POINTER_OFFSET (ptr );
120
120
__CPROVER_assert (
121
- !(offset > 0 ) |
122
- ((__CPROVER_size_t )offset + size < __CPROVER_max_malloc_size ),
121
+ !(offset > 0 ) | (offset + size <= __CPROVER_max_malloc_size ),
123
122
"no offset bits overflow on CAR upper bound computation" );
124
123
return (__CPROVER_contracts_car_t ){
125
124
.is_writable = ptr != 0 , .size = size , .lb = ptr , .ub = (char * )ptr + size };
@@ -163,12 +162,11 @@ __CPROVER_HIDE:;
163
162
((ptr == 0 ) | __CPROVER_rw_ok (ptr , size )),
164
163
"ptr NULL or writable up to size" );
165
164
__CPROVER_assert (
166
- size < __CPROVER_max_malloc_size ,
165
+ size <= __CPROVER_max_malloc_size ,
167
166
"CAR size is less than __CPROVER_max_malloc_size" );
168
- __CPROVER_ssize_t offset = __CPROVER_POINTER_OFFSET (ptr );
167
+ __CPROVER_size_t offset = __CPROVER_POINTER_OFFSET (ptr );
169
168
__CPROVER_assert (
170
- !(offset > 0 ) |
171
- ((__CPROVER_size_t )offset + size < __CPROVER_max_malloc_size ),
169
+ !(offset > 0 ) | (offset + size <= __CPROVER_max_malloc_size ),
172
170
"no offset bits overflow on CAR upper bound computation" );
173
171
__CPROVER_contracts_car_t * elem = set -> elems + idx ;
174
172
* elem = (__CPROVER_contracts_car_t ){
@@ -783,14 +781,13 @@ __CPROVER_HIDE:;
783
781
784
782
// Compute the upper bound, perform inclusion check against contract-assigns
785
783
__CPROVER_assert (
786
- size < __CPROVER_max_malloc_size ,
784
+ size <= __CPROVER_max_malloc_size ,
787
785
"CAR size is less than __CPROVER_max_malloc_size" );
788
786
789
- __CPROVER_ssize_t offset = __CPROVER_POINTER_OFFSET (ptr );
787
+ __CPROVER_size_t offset = __CPROVER_POINTER_OFFSET (ptr );
790
788
791
789
__CPROVER_assert (
792
- !(offset > 0 ) |
793
- ((__CPROVER_size_t )offset + size < __CPROVER_max_malloc_size ),
790
+ !(offset > 0 ) | (offset + size <= __CPROVER_max_malloc_size ),
794
791
"no offset bits overflow on CAR upper bound computation" );
795
792
void * ub = (void * )((char * )ptr + size );
796
793
__CPROVER_contracts_car_t * elem = set -> contract_assigns .elems ;
@@ -1198,7 +1195,7 @@ __CPROVER_HIDE:;
1198
1195
{
1199
1196
// When --malloc-may-fail --malloc-fail-null
1200
1197
// add implicit assumption that the size is capped
1201
- __CPROVER_assume (size < __CPROVER_max_malloc_size );
1198
+ __CPROVER_assume (size <= __CPROVER_max_malloc_size );
1202
1199
}
1203
1200
else if (
1204
1201
__CPROVER_malloc_failure_mode ==
@@ -1208,9 +1205,9 @@ __CPROVER_HIDE:;
1208
1205
// check if max allocation size is exceeded and
1209
1206
// add implicit assumption that the size is capped
1210
1207
__CPROVER_assert (
1211
- size < __CPROVER_max_malloc_size ,
1208
+ size <= __CPROVER_max_malloc_size ,
1212
1209
"__CPROVER_is_fresh max allocation size exceeded" );
1213
- __CPROVER_assume (size < __CPROVER_max_malloc_size );
1210
+ __CPROVER_assume (size <= __CPROVER_max_malloc_size );
1214
1211
}
1215
1212
1216
1213
void * ptr = __CPROVER_allocate (size , 0 );
@@ -1255,16 +1252,16 @@ __CPROVER_HIDE:;
1255
1252
__CPROVER_malloc_failure_mode ==
1256
1253
__CPROVER_malloc_failure_mode_return_null )
1257
1254
{
1258
- __CPROVER_assume (size < __CPROVER_max_malloc_size );
1255
+ __CPROVER_assume (size <= __CPROVER_max_malloc_size );
1259
1256
}
1260
1257
else if (
1261
1258
__CPROVER_malloc_failure_mode ==
1262
1259
__CPROVER_malloc_failure_mode_assert_then_assume )
1263
1260
{
1264
1261
__CPROVER_assert (
1265
- size < __CPROVER_max_malloc_size ,
1266
- "__CPROVER_is_fresh requires size < __CPROVER_max_malloc_size" );
1267
- __CPROVER_assume (size < __CPROVER_max_malloc_size );
1262
+ size <= __CPROVER_max_malloc_size ,
1263
+ "__CPROVER_is_fresh requires size <= __CPROVER_max_malloc_size" );
1264
+ __CPROVER_assume (size <= __CPROVER_max_malloc_size );
1268
1265
}
1269
1266
1270
1267
void * ptr = __CPROVER_allocate (size , 0 );
@@ -1360,8 +1357,8 @@ __CPROVER_HIDE:;
1360
1357
__CPROVER_assert (
1361
1358
__CPROVER_same_object (lb , ub ),
1362
1359
"lb and ub pointers must have the same object" );
1363
- __CPROVER_ssize_t lb_offset = __CPROVER_POINTER_OFFSET (lb );
1364
- __CPROVER_ssize_t ub_offset = __CPROVER_POINTER_OFFSET (ub );
1360
+ __CPROVER_size_t lb_offset = __CPROVER_POINTER_OFFSET (lb );
1361
+ __CPROVER_size_t ub_offset = __CPROVER_POINTER_OFFSET (ub );
1365
1362
__CPROVER_assert (
1366
1363
lb_offset <= ub_offset , "lb and ub pointers must be ordered" );
1367
1364
if (write_set -> assume_requires_ctx | write_set -> assume_ensures_ctx )
@@ -1373,14 +1370,14 @@ __CPROVER_HIDE:;
1373
1370
__CPROVER_size_t offset = __VERIFIER_nondet_size ();
1374
1371
1375
1372
// this cast is safe because we prove that ub and lb are ordered
1376
- __CPROVER_size_t max_offset = ( __CPROVER_size_t )( ub_offset - lb_offset ) ;
1373
+ __CPROVER_size_t max_offset = ub_offset - lb_offset ;
1377
1374
__CPROVER_assume (offset <= max_offset );
1378
1375
* ptr = (char * )lb + offset ;
1379
1376
return 1 ;
1380
1377
}
1381
1378
else /* write_set->assert_requires_ctx | write_set->assert_ensures_ctx */
1382
1379
{
1383
- __CPROVER_ssize_t offset = __CPROVER_POINTER_OFFSET (* ptr );
1380
+ __CPROVER_size_t offset = __CPROVER_POINTER_OFFSET (* ptr );
1384
1381
return __CPROVER_same_object (lb , * ptr ) && lb_offset <= offset &&
1385
1382
offset <= ub_offset ;
1386
1383
}
0 commit comments