Skip to content

Commit

Permalink
Merge branch 'main' into dev-stm32
Browse files Browse the repository at this point in the history
  • Loading branch information
tony-josi-aws authored Nov 4, 2024
2 parents b1d730b + 4f67761 commit 55b1458
Show file tree
Hide file tree
Showing 43 changed files with 539 additions and 145 deletions.
1 change: 1 addition & 0 deletions .github/.cSpellWords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ BLXNS
bmcr
BMSR
BPDG
BPIALL
brgintclr
brginten
brgintstat
Expand Down
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# the repo. Unless a later match takes precedence,
# @global-owner1 and @global-owner2 will be requested for
# review when someone opens a pull request.
* @FreeRTOS/pr-bar-raiser
* @FreeRTOS/pr-bar-raisers

# Order is important; the last matching pattern takes the most
# precedence. When someone opens a pull request that only
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ jobs:
- name: Set up CBMC runner
uses: FreeRTOS/CI-CD-Github-Actions/set_up_cbmc_runner@main
with:
cbmc_version: "5.95.1"
cbmc_version: "6.3.1"

- env:
stepName: Install Dependencies
Expand Down
4 changes: 2 additions & 2 deletions source/FreeRTOS_DHCP.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
/**
* @brief The number of end-points that are making use of the UDP-socket.
*/
static BaseType_t xDHCPSocketUserCount = 0;
_static BaseType_t xDHCPSocketUserCount = 0;

/*
* Generate a DHCP discover message and send it on the DHCP socket.
Expand Down Expand Up @@ -881,7 +881,7 @@
configASSERT( xSocketValid( xDHCPv4Socket ) == pdTRUE );

/* MISRA Ref 11.4.1 [Socket error and integer to pointer conversion] */
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-114 */
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-114 */
/* coverity[misra_c_2012_rule_11_4_violation] */
if( xSocketValid( xDHCPv4Socket ) == pdTRUE )
{
Expand Down
14 changes: 10 additions & 4 deletions source/FreeRTOS_DHCPv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@
( ( ( uint32_t ) 1U ) << DHCPv6_Option_Server_Identifier ) )

/** @brief The UDP socket which is shared by all end-points that need DHCPv6. */
static Socket_t xDHCPv6Socket;
_static Socket_t xDHCPv6Socket;

/** @brief A reference count makes sure that the UDP socket will be deleted when it
* is not used anymore. */
static BaseType_t xDHCPv6SocketUserCount;
_static BaseType_t xDHCPv6SocketUserCount;

static BaseType_t prvIsOptionLengthValid( uint16_t usOption,
size_t uxOptionLength,
Expand Down Expand Up @@ -151,7 +151,7 @@ static BaseType_t prvDHCPv6_handleOption( struct xNetworkEndPoint * pxEndPoint,
/**
* @brief DHCP IPv6 message object
*/
static DHCPMessage_IPv6_t xDHCPMessage;
_static DHCPMessage_IPv6_t xDHCPMessage;

/**
* @brief Get the DHCP state from a given endpoint.
Expand Down Expand Up @@ -1500,7 +1500,13 @@ static BaseType_t prvDHCPv6Analyse( struct xNetworkEndPoint * pxEndPoint,
}
else
{
ulOptionsReceived |= ( ( ( uint32_t ) 1U ) << usOption );
/* ulOptionsReceived has only 32-bits, it's not allowed to shift more than 32-bits on it. */
if( usOption < 32 )
{
/* Store the option by bit-map only if it's less than 32. */
ulOptionsReceived |= ( ( ( uint32_t ) 1U ) << usOption );
}

xReady = prvDHCPv6_handleOption( pxEndPoint, usOption, &( xSet ), pxDHCPMessage, &( xMessage ) );
}

Expand Down
3 changes: 3 additions & 0 deletions source/FreeRTOS_DNS.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@ const MACAddress_t xMDNS_MacAddressIPv6 = { { 0x33, 0x33, 0x00, 0x00, 0x00, 0xFB

/* 'xFamily' might not be used when IPv6 is disabled. */
( void ) xFamily;
/* 'pcName' might not be used when DNS cache is disabled. */
( void ) pcName;

pvBuffer = pvPortMalloc( sizeof( *pxAddrInfo ) );

if( pvBuffer != NULL )
Expand Down
182 changes: 92 additions & 90 deletions source/FreeRTOS_DNS_Parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@

#if ( ipconfigUSE_DNS != 0 )

#if ( ( ipconfigUSE_DNS_CACHE != 0 ) || ( ipconfigDNS_USE_CALLBACKS != 0 ) || ( ipconfigUSE_MDNS != 0 ) || ( ipconfigUSE_LLMNR != 0 ) )

/**
* @brief Read the Name field out of a DNS response packet.
Expand All @@ -56,110 +57,111 @@
*
* @return If a fully formed name was found, then return the number of bytes processed in pucByte.
*/
size_t DNS_ReadNameField( ParseSet_t * pxSet,
size_t uxDestLen )
{
size_t uxNameLen = 0U;
size_t uxIndex = 0U;
size_t uxSourceLen = pxSet->uxSourceBytesRemaining;
const uint8_t * pucByte = pxSet->pucByte;

/* uxCount gets the values from pucByte and counts down to 0.
* No need to have a different type than that of pucByte */
size_t uxCount;

if( uxSourceLen == ( size_t ) 0U )
size_t DNS_ReadNameField( ParseSet_t * pxSet,
size_t uxDestLen )
{
/* Return 0 value in case of error. */
uxIndex = 0U;
}
size_t uxNameLen = 0U;
size_t uxIndex = 0U;
size_t uxSourceLen = pxSet->uxSourceBytesRemaining;
const uint8_t * pucByte = pxSet->pucByte;

/* Determine if the name is the fully coded name, or an offset to the name
* elsewhere in the message. */
else if( ( pucByte[ uxIndex ] & dnsNAME_IS_OFFSET ) == dnsNAME_IS_OFFSET )
{
/* Jump over the two byte offset. */
if( uxSourceLen > sizeof( uint16_t ) )
{
uxIndex += sizeof( uint16_t );
}
else
/* uxCount gets the values from pucByte and counts down to 0.
* No need to have a different type than that of pucByte */
size_t uxCount;

if( uxSourceLen == ( size_t ) 0U )
{
/* Return 0 value in case of error. */
uxIndex = 0U;
}
}
else
{
/* 'uxIndex' points to the full name. Walk over the string. */
while( ( uxIndex < uxSourceLen ) && ( pucByte[ uxIndex ] != ( uint8_t ) 0x00U ) )
{
/* If this is not the first time through the loop, then add a
* separator in the output. */
if( ( uxNameLen > 0U ) )
{
/*
* uxNameLen can never be greater than uxDestLen, since there are checks
* outside this condition, so the check is removed.
*/
pxSet->pcName[ uxNameLen ] = '.';
uxNameLen++;
}

/* Process the first/next sub-string. */
uxCount = ( size_t ) pucByte[ uxIndex ];

/* uxIndex should point to the first character now, unless uxCount
* is an offset field. */
uxIndex++;

if( ( uxIndex + uxCount ) > uxSourceLen )
/* Determine if the name is the fully coded name, or an offset to the name
* elsewhere in the message. */
else if( ( pucByte[ uxIndex ] & dnsNAME_IS_OFFSET ) == dnsNAME_IS_OFFSET )
{
/* Jump over the two byte offset. */
if( uxSourceLen > sizeof( uint16_t ) )
{
uxIndex = 0U;
break;
uxIndex += sizeof( uint16_t );
}

if( ( uxNameLen + uxCount ) >= uxDestLen )
else
{
uxIndex = 0U;
break;
}

while( uxCount-- != 0U )
{
/*
* uxNameLen can never be greater than uxDestLen, since there are checks
* outside this condition, so the check is removed.
*/
pxSet->pcName[ uxNameLen ] = ( char ) pucByte[ uxIndex ];
uxNameLen++;
uxIndex++;
}
}

/* Confirm that a fully formed name was found. */
if( uxIndex > 0U )
else
{
/* Here, there is no need to check for pucByte[ uxindex ] == 0 because:
* When we break out of the above while loop, uxIndex is made 0 thereby
* failing above check. Whenever we exit the loop otherwise, either
* pucByte[ uxIndex ] == 0 (which makes the check here unnecessary) or
* uxIndex >= uxSourceLen (which makes sure that we do not go in the 'if'
* case).
*/
if( uxIndex < uxSourceLen )
/* 'uxIndex' points to the full name. Walk over the string. */
while( ( uxIndex < uxSourceLen ) && ( pucByte[ uxIndex ] != ( uint8_t ) 0x00U ) )
{
pxSet->pcName[ uxNameLen ] = '\0';
/* If this is not the first time through the loop, then add a
* separator in the output. */
if( ( uxNameLen > 0U ) )
{
/*
* uxNameLen can never be greater than uxDestLen, since there are checks
* outside this condition, so the check is removed.
*/
pxSet->pcName[ uxNameLen ] = '.';
uxNameLen++;
}

/* Process the first/next sub-string. */
uxCount = ( size_t ) pucByte[ uxIndex ];

/* uxIndex should point to the first character now, unless uxCount
* is an offset field. */
uxIndex++;

if( ( uxIndex + uxCount ) > uxSourceLen )
{
uxIndex = 0U;
break;
}

if( ( uxNameLen + uxCount ) >= uxDestLen )
{
uxIndex = 0U;
break;
}

while( uxCount-- != 0U )
{
/*
* uxNameLen can never be greater than uxDestLen, since there are checks
* outside this condition, so the check is removed.
*/
pxSet->pcName[ uxNameLen ] = ( char ) pucByte[ uxIndex ];
uxNameLen++;
uxIndex++;
}
}
else

/* Confirm that a fully formed name was found. */
if( uxIndex > 0U )
{
uxIndex = 0U;
/* Here, there is no need to check for pucByte[ uxindex ] == 0 because:
* When we break out of the above while loop, uxIndex is made 0 thereby
* failing above check. Whenever we exit the loop otherwise, either
* pucByte[ uxIndex ] == 0 (which makes the check here unnecessary) or
* uxIndex >= uxSourceLen (which makes sure that we do not go in the 'if'
* case).
*/
if( uxIndex < uxSourceLen )
{
pxSet->pcName[ uxNameLen ] = '\0';
uxIndex++;
}
else
{
uxIndex = 0U;
}
}
}
}

return uxIndex;
}
return uxIndex;
}
#endif /* ipconfigUSE_DNS_CACHE || ipconfigDNS_USE_CALLBACKS || ipconfigUSE_MDNS || ipconfigUSE_LLMNR */

/**
* @brief Simple routine that jumps over the NAME field of a resource record.
Expand Down Expand Up @@ -285,7 +287,7 @@
* for easier access. */

/* MISRA Ref 11.3.1 [Misaligned access] */
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
/* coverity[misra_c_2012_rule_11_3_violation] */
xSet.pxDNSMessageHeader = ( ( DNSMessage_t * )
pucUDPPayloadBuffer );
Expand Down Expand Up @@ -355,15 +357,15 @@
}
#endif

#if ( ipconfigUSE_DNS_CACHE == 1 ) || ( ipconfigDNS_USE_CALLBACKS == 1 )
#if ( ( ipconfigUSE_DNS_CACHE != 0 ) || ( ipconfigDNS_USE_CALLBACKS != 0 ) || ( ipconfigUSE_MDNS != 0 ) || ( ipconfigUSE_LLMNR != 0 ) )
if( x == 0U )
{
uxResult = DNS_ReadNameField( &xSet,
sizeof( xSet.pcName ) );
( void ) uxResult;
}
else
#endif /* ipconfigUSE_DNS_CACHE || ipconfigDNS_USE_CALLBACKS */
#endif /* ipconfigUSE_DNS_CACHE || ipconfigDNS_USE_CALLBACKS || ipconfigUSE_MDNS || ipconfigUSE_LLMNR */
{
/* Skip the variable length pcName field. */
uxResult = DNS_SkipNameField( xSet.pucByte,
Expand Down Expand Up @@ -721,7 +723,7 @@
* fields of the structure. */

/* MISRA Ref 11.3.1 [Misaligned access] */
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
/* coverity[misra_c_2012_rule_11_3_violation] */
pxDNSAnswerRecord = ( ( DNSAnswerRecord_t * ) pxSet->pucByte );

Expand Down Expand Up @@ -874,7 +876,7 @@
/* Cast the response to DNSAnswerRecord for easy access to fields of the DNS response. */

/* MISRA Ref 11.3.1 [Misaligned access] */
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
/* coverity[misra_c_2012_rule_11_3_violation] */
pxDNSAnswerRecord = ( ( DNSAnswerRecord_t * ) pxSet->pucByte );

Expand Down Expand Up @@ -1093,7 +1095,7 @@
/* Define the ASCII value of the capital "A". */
const uint8_t ucCharA = ( uint8_t ) 0x41U;

ucByte = ( uint8_t ) ( ( ( pucSource[ 0 ] - ucCharA ) << 4 ) |
ucByte = ( uint8_t ) ( ( ( ( pucSource[ 0 ] - ucCharA ) & 0x0F ) << 4 ) |
( pucSource[ 1 ] - ucCharA ) );

/* Make sure there are no trailing spaces in the name. */
Expand Down
Loading

0 comments on commit 55b1458

Please sign in to comment.