Skip to content

Commit a2474fc

Browse files
committed
Remove {r,w}_ok from is_valid_IotResponseHandle
This commit attempts to preserve the functionality of the memory checks in is_valid_IotResponseHandle until the issue in diffblue/cbmc#5194 is sorted out. This commit is needed because is_valid_IotResponseHandle uses the __CPROVER_r_ok and __CPROVER_w_ok macros, and is_valid_IotResponseHandle itself is used inside an assume statement, triggering the issue mentioned in that bug.
1 parent 473f16e commit a2474fc

File tree

1 file changed

+26
-25
lines changed

1 file changed

+26
-25
lines changed

tools/cbmc/proofs/HTTP/global_state_HTTP.c

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -296,21 +296,20 @@ int is_valid_IotResponseHandle(IotHttpsResponseHandle_t pResponseHandle) {
296296
pResponseHandle->pBodyCur <= pResponseHandle->pBodyEnd;
297297
int valid_parserdata =
298298
pResponseHandle->httpParserInfo.readHeaderParser.data == pResponseHandle;
299-
return
300-
valid_headers &&
301-
valid_header_order &&
302-
valid_body &&
303-
valid_body_order &&
304-
valid_parserdata &&
305-
// valid_order and short circuit evaluation prevents integer overflow
306-
__CPROVER_r_ok(pResponseHandle->pHeaders,
307-
pResponseHandle->pHeadersEnd - pResponseHandle->pHeaders) &&
308-
__CPROVER_w_ok(pResponseHandle->pHeaders,
309-
pResponseHandle->pHeadersEnd - pResponseHandle->pHeaders) &&
310-
__CPROVER_r_ok(pResponseHandle->pBody,
311-
pResponseHandle->pBodyEnd - pResponseHandle->pBody) &&
312-
__CPROVER_w_ok(pResponseHandle->pBody,
313-
pResponseHandle->pBodyEnd - pResponseHandle->pBody);
299+
300+
if(!( valid_headers &&
301+
valid_header_order &&
302+
valid_body &&
303+
valid_body_order &&
304+
valid_parserdata))
305+
return false;
306+
307+
// Check that these are accessible. This is a workaround until
308+
// https://github.com/diffblue/cbmc/issues/5194 is fixed.
309+
(void *)(pResponseHandle->pHeaders);
310+
(void *)(pResponseHandle->pBody);
311+
312+
return true;
314313
}
315314

316315
/****************************************************************
@@ -349,16 +348,18 @@ int is_valid_IotRequestHandle(IotHttpsRequestHandle_t pRequestHandle) {
349348
pRequestHandle->pBody != NULL;
350349
int bounded_header_buffer =
351350
__CPROVER_OBJECT_SIZE(pRequestHandle->pHeaders) < CBMC_MAX_OBJECT_SIZE;
352-
return
353-
valid_headers &&
354-
valid_order &&
355-
valid_body &&
356-
bounded_header_buffer &&
357-
// valid_order and short circuit evaluation prevents integer overflow
358-
__CPROVER_r_ok(pRequestHandle->pHeaders,
359-
pRequestHandle->pHeadersEnd - pRequestHandle->pHeaders) &&
360-
__CPROVER_w_ok(pRequestHandle->pHeaders,
361-
pRequestHandle->pHeadersEnd - pRequestHandle->pHeaders);
351+
352+
if(!( valid_headers &&
353+
valid_order &&
354+
valid_body &&
355+
bounded_header_buffer))
356+
return false;
357+
358+
// Check that this is accessible. This is a workaround until
359+
// https://github.com/diffblue/cbmc/issues/5194 is fixed.
360+
(void *)(pRequestHandle->pHeaders);
361+
362+
return true;
362363
}
363364

364365
/****************************************************************

0 commit comments

Comments
 (0)