Skip to content

Commit 80b8d81

Browse files
committed
Fix CBMC
1 parent 9168039 commit 80b8d81

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

source/FreeRTOS_DHCPv6.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,7 @@ void vDHCPv6Process( BaseType_t xReset,
432432
BaseType_t xRecvFlags = ( BaseType_t ) FREERTOS_ZERO_COPY;
433433
struct freertos_sockaddr xSourceAddressCurrent;
434434
socklen_t xSourceAddressCurrentLength = 0;
435+
pucUDPPayload = NULL;
435436

436437
/* Get the next UDP message. */
437438
lBytes = FreeRTOS_recvfrom( EP_DHCPData.xDHCPSocket, &( pucUDPPayload ), 0, xRecvFlags, &xSourceAddressCurrent, &xSourceAddressCurrentLength );
@@ -443,6 +444,11 @@ void vDHCPv6Process( BaseType_t xReset,
443444
FreeRTOS_printf( ( "vDHCPProcess: FreeRTOS_recvfrom returns %d\n", ( int ) lBytes ) );
444445
}
445446

447+
if(pucUDPPayload != NULL)
448+
{
449+
FreeRTOS_ReleaseUDPPayloadBuffer( pucUDPPayload );
450+
}
451+
446452
break;
447453
}
448454

@@ -452,7 +458,7 @@ void vDHCPv6Process( BaseType_t xReset,
452458
ucFirstIter = 0U;
453459
}
454460

455-
/* Verify DHCPv6 server address. */*/
461+
/* Verify DHCPv6 server address. */
456462
if((memcmp(&(xSourceAddress.sin_address.xIP_IPv6.ucBytes), \
457463
&(xSourceAddressCurrent.sin_address.xIP_IPv6.ucBytes), \
458464
sizeof(xSourceAddressCurrent.sin_address.xIP_IPv6.ucBytes) ) == 0) &&

test/cbmc/proofs/DHCPv6/DHCPv6Process/DHCPv6Process_harness.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,17 @@ int32_t FreeRTOS_recvfrom( Socket_t xSocket,
153153
return retVal;
154154
}
155155

156+
/* For the purpose of this proof we stub the
157+
* implementation of FreeRTOS_ReleaseUDPPayloadBuffer here, but make sure that
158+
* the pvBuffer is not NULL, its not verified here if the pointer is a valid
159+
* payload buffer as its proved in other proofs */
160+
void FreeRTOS_ReleaseUDPPayloadBuffer( void * pvBuffer )
161+
{
162+
__CPROVER_assert( pvBuffer != NULL,
163+
"FreeRTOS precondition: pvBuffer != NULL" );
164+
165+
}
166+
156167
void harness()
157168
{
158169
BaseType_t xReset;

test/cbmc/proofs/DHCPv6/DHCPv6Process/Makefile.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"CBMCFLAGS":
66
[
77
"--unwind {LOOP_UNWIND_COUNT}",
8+
"--unwindset memcmp.0:17",
89
"--nondet-static --flush"
910
],
1011
"OPT":

0 commit comments

Comments
 (0)