Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle malloc failure in dns setcallback #1155

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions source/FreeRTOS_DNS.c
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,10 @@
BaseType_t xHasRandom = pdFALSE;
TickType_t uxIdentifier = 0U;

#if ( ipconfigDNS_USE_CALLBACKS == 1 )
BaseType_t xReturnSetCallback = pdPASS;
#endif

#if ( ipconfigUSE_DNS_CACHE != 0 )
BaseType_t xLengthOk = pdFALSE;
#endif
Expand Down Expand Up @@ -690,12 +694,12 @@
if( xHasRandom != pdFALSE )
{
uxReadTimeOut_ticks = 0U;
vDNSSetCallBack( pcHostName,
pvSearchID,
pCallbackFunction,
uxTimeout,
( TickType_t ) uxIdentifier,
( xFamily == FREERTOS_AF_INET6 ) ? pdTRUE : pdFALSE );
xReturnSetCallback = xDNSSetCallBack( pcHostName,
pvSearchID,
pCallbackFunction,
uxTimeout,
( TickType_t ) uxIdentifier,
( xFamily == FREERTOS_AF_INET6 ) ? pdTRUE : pdFALSE );
}
}
else /* When ipconfigDNS_USE_CALLBACKS enabled, ppxAddressInfo is always non null. */
Expand All @@ -707,7 +711,13 @@
}
#endif /* if ( ipconfigDNS_USE_CALLBACKS == 1 ) */

if( ( ulIPAddress == 0U ) && ( xHasRandom != pdFALSE ) )
if( ( ulIPAddress == 0U ) &&

#if ( ipconfigDNS_USE_CALLBACKS == 1 )
( xReturnSetCallback == pdPASS ) &&
#endif

( xHasRandom != pdFALSE ) )
{
ulIPAddress = prvGetHostByName( pcHostName,
uxIdentifier,
Expand Down
18 changes: 11 additions & 7 deletions source/FreeRTOS_DNS_Callback.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,14 @@
* @param[in] uxIdentifier Random number used as ID in the DNS message.
* @param[in] xIsIPv6 pdTRUE if the address type should be IPv6.
*/
void vDNSSetCallBack( const char * pcHostName,
void * pvSearchID,
FOnDNSEvent pCallbackFunction,
TickType_t uxTimeout,
TickType_t uxIdentifier,
BaseType_t xIsIPv6 )
BaseType_t xDNSSetCallBack( const char * pcHostName,
void * pvSearchID,
FOnDNSEvent pCallbackFunction,
TickType_t uxTimeout,
TickType_t uxIdentifier,
BaseType_t xIsIPv6 )
{
BaseType_t xReturn = pdPASS;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Can the strcpy in line 158 cause a copy overflow. We can use strncpy instead or put a size check as the destination is a fixed array

size_t lLength = strlen( pcHostName );

/* MISRA Ref 4.12.1 [Use of dynamic memory]. */
Expand Down Expand Up @@ -171,9 +172,12 @@
}
else
{
FreeRTOS_debug_printf( ( " vDNSSetCallBack : Could not allocate memory: %u bytes",
xReturn = pdFAIL;
FreeRTOS_debug_printf( ( " xDNSSetCallBack : Could not allocate memory: %u bytes",
( unsigned ) ( sizeof( *pxCallback ) + lLength ) ) );
}

return xReturn;
}
/*-----------------------------------------------------------*/

Expand Down
12 changes: 6 additions & 6 deletions source/include/FreeRTOS_DNS_Callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@
BaseType_t xDNSDoCallback( ParseSet_t * pxSet,
struct freertos_addrinfo * pxAddress );

void vDNSSetCallBack( const char * pcHostName,
void * pvSearchID,
FOnDNSEvent pCallbackFunction,
TickType_t uxTimeout,
TickType_t uxIdentifier,
BaseType_t xIsIPv6 );
BaseType_t xDNSSetCallBack( const char * pcHostName,
void * pvSearchID,
FOnDNSEvent pCallbackFunction,
TickType_t uxTimeout,
TickType_t uxIdentifier,
BaseType_t xIsIPv6 );

void vDNSCheckCallBack( void * pvSearchID );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@

void vDNSInitialise( void );

void vDNSSetCallBack( const char * pcHostName,
void * pvSearchID,
FOnDNSEvent pCallbackFunction,
TickType_t xTimeout,
TickType_t xIdentifier,
BaseType_t xIsIPv6 );
BaseType_t xDNSSetCallBack( const char * pcHostName,
void * pvSearchID,
FOnDNSEvent pCallbackFunction,
TickType_t xTimeout,
TickType_t xIdentifier,
BaseType_t xIsIPv6 );

void * safeMalloc( size_t xWantedSize ) /* Returns a NULL pointer if the wanted size is 0. */
{
Expand Down Expand Up @@ -59,6 +59,7 @@ void harness()
TickType_t xIdentifier;
BaseType_t xIsIPv6;
size_t len;
BaseType_t xReturn;

__CPROVER_assume( len >= 0 && len <= MAX_HOSTNAME_LEN );
char * pcHostName = safeMalloc( len );
Expand All @@ -68,6 +69,6 @@ void harness()
pcHostName[ len - 1 ] = NULL;
}

vDNSSetCallBack( pcHostName, &pvSearchID, pCallback, xTimeout, xIdentifier, xIsIPv6 ); /* Add an item to be able to check the cancel function if the list is non-empty. */
xReturn = xDNSSetCallBack( pcHostName, &pvSearchID, pCallback, xTimeout, xIdentifier, xIsIPv6 ); /* Add an item to be able to check the cancel function if the list is non-empty. */
FreeRTOS_gethostbyname_cancel( &pvSearchID );
}
76 changes: 55 additions & 21 deletions test/unit-test/FreeRTOS_DNS/FreeRTOS_DNS_utest.c
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ void test_FreeRTOS_gethostbyname_a_SetCallback( void )
FreeRTOS_inet_addr_ExpectAndReturn( GOOD_ADDRESS, 0 );
Prepare_CacheLookup_ExpectAnyArgsAndReturn( 0 );
xApplicationGetRandomNumber_IgnoreAndReturn( pdTRUE );
vDNSSetCallBack_ExpectAnyArgs();
xDNSSetCallBack_ExpectAnyArgsAndReturn( pdPASS );
DNS_CreateSocket_ExpectAnyArgsAndReturn( NULL );

ret = FreeRTOS_gethostbyname_a( GOOD_ADDRESS,
Expand Down Expand Up @@ -665,7 +665,7 @@ void test_FreeRTOS_gethostbyname_a_Callback( void )
}

/**
* @brief Ensures that if vDNSSetCallBack is called the client is put in
* @brief Ensures that if xDNSSetCallBack is called the client is put in
* asynchronous mode, and only one retry is performed by calling
* prvGetHostByNameOp instead of prvGetHostByNameOp_WithRetry
*/
Expand Down Expand Up @@ -700,7 +700,7 @@ void test_FreeRTOS_gethostbyname_a_NoCallbackRetryOnce( void )
Prepare_CacheLookup_ExpectAnyArgsAndReturn( 0 );
xApplicationGetRandomNumber_ExpectAnyArgsAndReturn( pdTRUE );
xApplicationGetRandomNumber_ReturnThruPtr_pulNumber( &ulNumber );
vDNSSetCallBack_ExpectAnyArgs();
xDNSSetCallBack_ExpectAnyArgsAndReturn( pdPASS );

/* in prvGetHostByName */
DNS_CreateSocket_ExpectAnyArgsAndReturn( &xDNSSocket );
Expand Down Expand Up @@ -893,7 +893,7 @@ void test_FreeRTOS_getaddrinfo_a_IPv4DomainCacheMiss_Random( void )
Prepare_CacheLookup_ExpectAndReturn( GOOD_ADDRESS, FREERTOS_AF_INET4, &pxAddress, 0 );
xApplicationGetRandomNumber_ExpectAnyArgsAndReturn( pdTRUE );
xApplicationGetRandomNumber_ReturnMemThruPtr_pulNumber( &ulRandom, sizeof( uint32_t ) );
vDNSSetCallBack_Expect( GOOD_ADDRESS, NULL, dns_callback, 0U, ulRandom, pdFALSE );
xDNSSetCallBack_ExpectAndReturn( GOOD_ADDRESS, NULL, dns_callback, 0U, ulRandom, pdFALSE, pdPASS );
DNS_CreateSocket_ExpectAndReturn( 0U, NULL );

xReturn = FreeRTOS_getaddrinfo_a( GOOD_ADDRESS, "Service", NULL, &pxAddress, dns_callback, NULL, 0U );
Expand Down Expand Up @@ -921,7 +921,7 @@ void test_FreeRTOS_getaddrinfo_a_IPv6DomainCacheMiss_Random( void )
Prepare_CacheLookup_ExpectAndReturn( GOOD_ADDRESS, FREERTOS_AF_INET6, &pxAddress, 0 );
xApplicationGetRandomNumber_ExpectAnyArgsAndReturn( pdTRUE );
xApplicationGetRandomNumber_ReturnMemThruPtr_pulNumber( &ulRandom, sizeof( uint32_t ) );
vDNSSetCallBack_Expect( GOOD_ADDRESS, NULL, dns_callback, 0U, ulRandom, pdTRUE );
xDNSSetCallBack_ExpectAndReturn( GOOD_ADDRESS, NULL, dns_callback, 0U, ulRandom, pdTRUE, pdPASS );
DNS_CreateSocket_ExpectAndReturn( 0U, NULL );

xReturn = FreeRTOS_getaddrinfo_a( GOOD_ADDRESS, "Service", pxHint, &pxAddress, dns_callback, NULL, 0U );
Expand Down Expand Up @@ -955,7 +955,7 @@ void test_FreeRTOS_getaddrinfo_a_IPv6Random_EndPointNotFound( void )
Prepare_CacheLookup_ExpectAndReturn( GOOD_ADDRESS, FREERTOS_AF_INET6, &pxAddress, 0 );
xApplicationGetRandomNumber_ExpectAnyArgsAndReturn( pdTRUE );
xApplicationGetRandomNumber_ReturnMemThruPtr_pulNumber( &ulRandom, sizeof( uint32_t ) );
vDNSSetCallBack_Expect( GOOD_ADDRESS, NULL, dns_callback, 0U, ulRandom, pdTRUE );
xDNSSetCallBack_ExpectAndReturn( GOOD_ADDRESS, NULL, dns_callback, 0U, ulRandom, pdTRUE, pdPASS );

/* In prvGetHostByName */
DNS_CreateSocket_ExpectAndReturn( 0U, &xDNSSocket );
Expand All @@ -970,6 +970,40 @@ void test_FreeRTOS_getaddrinfo_a_IPv6Random_EndPointNotFound( void )
TEST_ASSERT_EQUAL( -pdFREERTOS_ERRNO_ENOENT, xReturn );
}

/**
* @brief Try to get IP address through network but malloc fails while setting
* callback
*/
void test_FreeRTOS_getaddrinfo_a_IPv6Random_SetCallBackFails( void )
{
BaseType_t xReturn;
struct freertos_addrinfo xAddress, * pxAddress = &xAddress;
struct freertos_addrinfo xHint, * pxHint = &xHint;
uint32_t ulRandom = 0x1234U;
struct xSOCKET xDNSSocket;
NetworkEndPoint_t xEndPoint;

memset( &xAddress, 0, sizeof( struct freertos_addrinfo ) );
memset( &xHint, 0, sizeof( struct freertos_addrinfo ) );
memset( &xDNSSocket, 0, sizeof( struct xSOCKET ) );
memset( &xEndPoint, 0, sizeof( xEndPoint ) );

xEndPoint.bits.bIPv6 = pdFALSE;

xHint.ai_family = FREERTOS_AF_INET6;

FreeRTOS_inet_pton6_ExpectAndReturn( GOOD_ADDRESS, NULL, 0 );
FreeRTOS_inet_pton6_IgnoreArg_pvDestination();
Prepare_CacheLookup_ExpectAndReturn( GOOD_ADDRESS, FREERTOS_AF_INET6, &pxAddress, 0 );
xApplicationGetRandomNumber_ExpectAnyArgsAndReturn( pdTRUE );
xApplicationGetRandomNumber_ReturnMemThruPtr_pulNumber( &ulRandom, sizeof( uint32_t ) );
xDNSSetCallBack_ExpectAndReturn( GOOD_ADDRESS, NULL, dns_callback, 0U, ulRandom, pdTRUE, pdFAIL );

xReturn = FreeRTOS_getaddrinfo_a( GOOD_ADDRESS, "Service", pxHint, &pxAddress, dns_callback, NULL, 0U );

TEST_ASSERT_EQUAL( -pdFREERTOS_ERRNO_ENOENT, xReturn );
}

/**
* @brief IPv4 socket bind fail with domain name containing dot
*/
Expand Down Expand Up @@ -1010,7 +1044,7 @@ void test_FreeRTOS_getaddrinfo_a_IPv4Random_BindFailWithDot( void )
Prepare_CacheLookup_ExpectAndReturn( GOOD_ADDRESS, FREERTOS_AF_INET4, &pxAddress, 0 );
xApplicationGetRandomNumber_ExpectAnyArgsAndReturn( pdTRUE );
xApplicationGetRandomNumber_ReturnMemThruPtr_pulNumber( &ulRandom, sizeof( uint32_t ) );
vDNSSetCallBack_Expect( GOOD_ADDRESS, NULL, dns_callback, 0U, ulRandom, pdFALSE );
xDNSSetCallBack_ExpectAndReturn( GOOD_ADDRESS, NULL, dns_callback, 0U, ulRandom, pdFALSE, pdPASS );

/* In prvGetHostByName */
DNS_CreateSocket_ExpectAndReturn( 0U, &xDNSSocket );
Expand Down Expand Up @@ -1079,7 +1113,7 @@ void test_FreeRTOS_getaddrinfo_a_IPv6Random_BindFailWithDot( void )
Prepare_CacheLookup_ExpectAndReturn( GOOD_ADDRESS, FREERTOS_AF_INET6, &pxAddress, 0 );
xApplicationGetRandomNumber_ExpectAnyArgsAndReturn( pdTRUE );
xApplicationGetRandomNumber_ReturnMemThruPtr_pulNumber( &ulRandom, sizeof( uint32_t ) );
vDNSSetCallBack_Expect( GOOD_ADDRESS, NULL, dns_callback, 0U, ulRandom, pdTRUE );
xDNSSetCallBack_ExpectAndReturn( GOOD_ADDRESS, NULL, dns_callback, 0U, ulRandom, pdTRUE, pdPASS );

/* In prvGetHostByName */
DNS_CreateSocket_ExpectAndReturn( 0U, &xDNSSocket );
Expand Down Expand Up @@ -1128,7 +1162,7 @@ void test_FreeRTOS_getaddrinfo_a_IPv4Random_BindFailWODot( void )
Prepare_CacheLookup_ExpectAndReturn( LLMNR_ADDRESS, FREERTOS_AF_INET4, &pxAddress, 0 );
xApplicationGetRandomNumber_ExpectAnyArgsAndReturn( pdTRUE );
xApplicationGetRandomNumber_ReturnMemThruPtr_pulNumber( &ulRandom, sizeof( uint32_t ) );
vDNSSetCallBack_Expect( LLMNR_ADDRESS, NULL, dns_callback, 0U, ulRandom, pdFALSE );
xDNSSetCallBack_ExpectAndReturn( LLMNR_ADDRESS, NULL, dns_callback, 0U, ulRandom, pdFALSE, pdPASS );

/* In prvGetHostByName */
DNS_CreateSocket_ExpectAndReturn( 0U, &xDNSSocket );
Expand Down Expand Up @@ -1176,7 +1210,7 @@ void test_FreeRTOS_getaddrinfo_a_IPv6Random_BindFailWODot( void )
Prepare_CacheLookup_ExpectAndReturn( LLMNR_ADDRESS, FREERTOS_AF_INET6, &pxAddress, 0 );
xApplicationGetRandomNumber_ExpectAnyArgsAndReturn( pdTRUE );
xApplicationGetRandomNumber_ReturnMemThruPtr_pulNumber( &ulRandom, sizeof( uint32_t ) );
vDNSSetCallBack_Expect( LLMNR_ADDRESS, NULL, dns_callback, 0U, ulRandom, pdTRUE );
xDNSSetCallBack_ExpectAndReturn( LLMNR_ADDRESS, NULL, dns_callback, 0U, ulRandom, pdTRUE, pdPASS );

/* In prvGetHostByName */
DNS_CreateSocket_ExpectAndReturn( 0U, &xDNSSocket );
Expand Down Expand Up @@ -1218,7 +1252,7 @@ void test_FreeRTOS_getaddrinfo_a_IPv4Random_InvalidDNSServerIndex( void )
Prepare_CacheLookup_ExpectAndReturn( GOOD_ADDRESS, FREERTOS_AF_INET4, &pxAddress, 0 );
xApplicationGetRandomNumber_ExpectAnyArgsAndReturn( pdTRUE );
xApplicationGetRandomNumber_ReturnMemThruPtr_pulNumber( &ulRandom, sizeof( uint32_t ) );
vDNSSetCallBack_Expect( GOOD_ADDRESS, NULL, dns_callback, 0U, ulRandom, pdFALSE );
xDNSSetCallBack_ExpectAndReturn( GOOD_ADDRESS, NULL, dns_callback, 0U, ulRandom, pdFALSE, pdPASS );

/* In prvGetHostByName */
DNS_CreateSocket_ExpectAndReturn( 0U, &xDNSSocket );
Expand Down Expand Up @@ -1258,7 +1292,7 @@ void test_FreeRTOS_getaddrinfo_a_IPv6Random_InvalidDNSServerIndex( void )
Prepare_CacheLookup_ExpectAndReturn( GOOD_ADDRESS, FREERTOS_AF_INET6, &pxAddress, 0 );
xApplicationGetRandomNumber_ExpectAnyArgsAndReturn( pdTRUE );
xApplicationGetRandomNumber_ReturnMemThruPtr_pulNumber( &ulRandom, sizeof( uint32_t ) );
vDNSSetCallBack_Expect( GOOD_ADDRESS, NULL, dns_callback, 0U, ulRandom, pdTRUE );
xDNSSetCallBack_ExpectAndReturn( GOOD_ADDRESS, NULL, dns_callback, 0U, ulRandom, pdTRUE, pdPASS );

/* In prvGetHostByName */
DNS_CreateSocket_ExpectAndReturn( 0U, &xDNSSocket );
Expand Down Expand Up @@ -1297,7 +1331,7 @@ void test_FreeRTOS_getaddrinfo_a_IPv4Random_UnknownPreference( void )
Prepare_CacheLookup_ExpectAndReturn( GOOD_ADDRESS, FREERTOS_AF_INET4, &pxAddress, 0 );
xApplicationGetRandomNumber_ExpectAnyArgsAndReturn( pdTRUE );
xApplicationGetRandomNumber_ReturnMemThruPtr_pulNumber( &ulRandom, sizeof( uint32_t ) );
vDNSSetCallBack_Expect( GOOD_ADDRESS, NULL, dns_callback, 0U, ulRandom, pdFALSE );
xDNSSetCallBack_ExpectAndReturn( GOOD_ADDRESS, NULL, dns_callback, 0U, ulRandom, pdFALSE, pdPASS );

/* In prvGetHostByName */
DNS_CreateSocket_ExpectAndReturn( 0U, &xDNSSocket );
Expand Down Expand Up @@ -1363,7 +1397,7 @@ void test_FreeRTOS_getaddrinfo_a_IPv6Random_DNSReplySuccess( void )
Prepare_CacheLookup_ExpectAndReturn( GOOD_ADDRESS, FREERTOS_AF_INET6, &pxAddress, 0 );
xApplicationGetRandomNumber_ExpectAnyArgsAndReturn( pdTRUE );
xApplicationGetRandomNumber_ReturnMemThruPtr_pulNumber( &ulRandom, sizeof( uint32_t ) );
vDNSSetCallBack_Expect( GOOD_ADDRESS, NULL, dns_callback, 0U, ulRandom, pdTRUE );
xDNSSetCallBack_ExpectAndReturn( GOOD_ADDRESS, NULL, dns_callback, 0U, ulRandom, pdTRUE, pdPASS );

/* In prvGetHostByName */
DNS_CreateSocket_ExpectAndReturn( 0U, &xDNSSocket );
Expand Down Expand Up @@ -1532,7 +1566,7 @@ void test_FreeRTOS_getaddrinfo_a_IPv4Random_LocalDNSSuccess( void )
Prepare_CacheLookup_ExpectAndReturn( LOCAL_ADDRESS, FREERTOS_AF_INET4, &pxAddress, 0 );
xApplicationGetRandomNumber_ExpectAnyArgsAndReturn( pdTRUE );
xApplicationGetRandomNumber_ReturnMemThruPtr_pulNumber( &ulRandom, sizeof( uint32_t ) );
vDNSSetCallBack_Expect( LOCAL_ADDRESS, NULL, dns_callback, 0U, ulRandom, pdFALSE );
xDNSSetCallBack_ExpectAndReturn( LOCAL_ADDRESS, NULL, dns_callback, 0U, ulRandom, pdFALSE, pdPASS );

/* In prvGetHostByName */
DNS_CreateSocket_ExpectAnyArgsAndReturn( &xDNSSocket );
Expand Down Expand Up @@ -1620,7 +1654,7 @@ void test_FreeRTOS_getaddrinfo_a_IPv6Random_LocalDNSSuccess( void )
Prepare_CacheLookup_ExpectAndReturn( LOCAL_ADDRESS, FREERTOS_AF_INET6, &pxAddress, 0 );
xApplicationGetRandomNumber_ExpectAnyArgsAndReturn( pdTRUE );
xApplicationGetRandomNumber_ReturnMemThruPtr_pulNumber( &ulRandom, sizeof( uint32_t ) );
vDNSSetCallBack_Expect( LOCAL_ADDRESS, NULL, dns_callback, 0U, ulRandom, pdTRUE );
xDNSSetCallBack_ExpectAndReturn( LOCAL_ADDRESS, NULL, dns_callback, 0U, ulRandom, pdTRUE, pdPASS );

/* In prvGetHostByName */
DNS_CreateSocket_ExpectAnyArgsAndReturn( &xDNSSocket );
Expand Down Expand Up @@ -1708,7 +1742,7 @@ void test_FreeRTOS_getaddrinfo_a_IPv4Random_LocalDNSUnknownPreference( void )
Prepare_CacheLookup_ExpectAndReturn( LOCAL_ADDRESS, FREERTOS_AF_INET4, &pxAddress, 0 );
xApplicationGetRandomNumber_ExpectAnyArgsAndReturn( pdTRUE );
xApplicationGetRandomNumber_ReturnMemThruPtr_pulNumber( &ulRandom, sizeof( uint32_t ) );
vDNSSetCallBack_Expect( LOCAL_ADDRESS, NULL, dns_callback, 0U, ulRandom, pdFALSE );
xDNSSetCallBack_ExpectAndReturn( LOCAL_ADDRESS, NULL, dns_callback, 0U, ulRandom, pdFALSE, pdPASS );

/* In prvGetHostByName */
DNS_CreateSocket_ExpectAnyArgsAndReturn( &xDNSSocket );
Expand Down Expand Up @@ -1780,7 +1814,7 @@ void test_FreeRTOS_getaddrinfo_a_IPv6Random_LLMNRDNSSuccess( void )
Prepare_CacheLookup_ExpectAndReturn( LLMNR_ADDRESS, FREERTOS_AF_INET6, &pxAddress, 0 );
xApplicationGetRandomNumber_ExpectAnyArgsAndReturn( pdTRUE );
xApplicationGetRandomNumber_ReturnMemThruPtr_pulNumber( &ulRandom, sizeof( uint32_t ) );
vDNSSetCallBack_Expect( LLMNR_ADDRESS, NULL, dns_callback, 0U, ulRandom, pdTRUE );
xDNSSetCallBack_ExpectAndReturn( LLMNR_ADDRESS, NULL, dns_callback, 0U, ulRandom, pdTRUE, pdPASS );

/* In prvGetHostByName */
DNS_CreateSocket_ExpectAnyArgsAndReturn( &xDNSSocket );
Expand Down Expand Up @@ -1859,7 +1893,7 @@ void test_FreeRTOS_getaddrinfo_a_IPv6Random_LLMNRDNSNoEndPoint( void )
Prepare_CacheLookup_ExpectAndReturn( LLMNR_ADDRESS, FREERTOS_AF_INET6, &pxAddress, 0 );
xApplicationGetRandomNumber_ExpectAnyArgsAndReturn( pdTRUE );
xApplicationGetRandomNumber_ReturnMemThruPtr_pulNumber( &ulRandom, sizeof( uint32_t ) );
vDNSSetCallBack_Expect( LLMNR_ADDRESS, NULL, dns_callback, 0U, ulRandom, pdTRUE );
xDNSSetCallBack_ExpectAndReturn( LLMNR_ADDRESS, NULL, dns_callback, 0U, ulRandom, pdTRUE, pdPASS );

/* In prvGetHostByName */
DNS_CreateSocket_ExpectAnyArgsAndReturn( &xDNSSocket );
Expand Down Expand Up @@ -1926,7 +1960,7 @@ void test_FreeRTOS_getaddrinfo_a_IPv4Random_LLMNRDNSUnknownPreference( void )
Prepare_CacheLookup_ExpectAndReturn( LLMNR_ADDRESS, FREERTOS_AF_INET4, &pxAddress, 0 );
xApplicationGetRandomNumber_ExpectAnyArgsAndReturn( pdTRUE );
xApplicationGetRandomNumber_ReturnMemThruPtr_pulNumber( &ulRandom, sizeof( uint32_t ) );
vDNSSetCallBack_Expect( LLMNR_ADDRESS, NULL, dns_callback, 0U, ulRandom, pdFALSE );
xDNSSetCallBack_ExpectAndReturn( LLMNR_ADDRESS, NULL, dns_callback, 0U, ulRandom, pdFALSE, pdPASS );

/* In prvGetHostByName */
DNS_CreateSocket_ExpectAnyArgsAndReturn( &xDNSSocket );
Expand Down Expand Up @@ -2179,7 +2213,7 @@ void test_FreeRTOS_getaddrinfo_a_IPv4Random_PortSpecified( void )
Prepare_CacheLookup_ExpectAndReturn( GOOD_ADDRESS, FREERTOS_AF_INET6, &pxAddress, 0 );
xApplicationGetRandomNumber_ExpectAnyArgsAndReturn( pdTRUE );
xApplicationGetRandomNumber_ReturnMemThruPtr_pulNumber( &ulRandom, sizeof( uint32_t ) );
vDNSSetCallBack_Expect( GOOD_ADDRESS, NULL, dns_callback, 0U, ulRandom, pdTRUE );
xDNSSetCallBack_ExpectAndReturn( GOOD_ADDRESS, NULL, dns_callback, 0U, ulRandom, pdTRUE, pdPASS );

/* In prvGetHostByName */
DNS_CreateSocket_ExpectAndReturn( 0U, &xDNSSocket );
Expand Down
Loading
Loading