Skip to content

Commit 995af46

Browse files
committed
EnDefineNS pcName buffer when MDNS/LLMNR enabled.
1 parent c00ad8a commit 995af46

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

source/FreeRTOS_DNS.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,9 @@ const MACAddress_t xMDNS_MacAddressIPv6 = { { 0x33, 0x33, 0x00, 0x00, 0x00, 0xFB
257257

258258
/* 'xFamily' might not be used when IPv6 is disabled. */
259259
( void ) xFamily;
260+
/* 'pcName' might not be used when DNS cache is disabled. */
261+
( void ) pcName;
262+
260263
pvBuffer = pvPortMalloc( sizeof( *pxAddrInfo ) );
261264

262265
if( pvBuffer != NULL )

source/FreeRTOS_DNS_Parser.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@
4747

4848
#if ( ipconfigUSE_DNS != 0 )
4949

50-
51-
#if ( ipconfigUSE_DNS_CACHE == 1 ) || ( ipconfigDNS_USE_CALLBACKS == 1 )
50+
#if ( ipconfigIS_ENABLED( ipconfigUSE_DNS_CACHE ) || \
51+
ipconfigIS_ENABLED( ipconfigDNS_USE_CALLBACKS ) || \
52+
ipconfigIS_ENABLED( ipconfigUSE_MDNS ) || \
53+
ipconfigIS_ENABLED( ipconfigUSE_LLMNR ) )
5254

5355
/**
5456
* @brief Read the Name field out of a DNS response packet.
@@ -162,7 +164,7 @@
162164

163165
return uxIndex;
164166
}
165-
#endif /* ipconfigUSE_DNS_CACHE || ipconfigDNS_USE_CALLBACKS */
167+
#endif /* ipconfigUSE_DNS_CACHE || ipconfigDNS_USE_CALLBACKS || ipconfigUSE_MDNS || ipconfigUSE_LLMNR */
166168

167169
/**
168170
* @brief Simple routine that jumps over the NAME field of a resource record.
@@ -288,7 +290,7 @@
288290
* for easier access. */
289291

290292
/* MISRA Ref 11.3.1 [Misaligned access] */
291-
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
293+
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
292294
/* coverity[misra_c_2012_rule_11_3_violation] */
293295
xSet.pxDNSMessageHeader = ( ( DNSMessage_t * )
294296
pucUDPPayloadBuffer );
@@ -358,15 +360,19 @@
358360
}
359361
#endif
360362

361-
#if ( ipconfigUSE_DNS_CACHE == 1 ) || ( ipconfigDNS_USE_CALLBACKS == 1 )
363+
#if ( ipconfigIS_ENABLED( ipconfigUSE_DNS_CACHE ) || \
364+
ipconfigIS_ENABLED( ipconfigDNS_USE_CALLBACKS ) || \
365+
ipconfigIS_ENABLED( ipconfigUSE_MDNS ) || \
366+
ipconfigIS_ENABLED( ipconfigUSE_LLMNR ) )
367+
362368
if( x == 0U )
363369
{
364370
uxResult = DNS_ReadNameField( &xSet,
365371
sizeof( xSet.pcName ) );
366372
( void ) uxResult;
367373
}
368374
else
369-
#endif /* ipconfigUSE_DNS_CACHE || ipconfigDNS_USE_CALLBACKS */
375+
#endif /* ipconfigUSE_DNS_CACHE || ipconfigDNS_USE_CALLBACKS || ipconfigUSE_MDNS || ipconfigUSE_LLMNR */
370376
{
371377
/* Skip the variable length pcName field. */
372378
uxResult = DNS_SkipNameField( xSet.pucByte,
@@ -724,7 +730,7 @@
724730
* fields of the structure. */
725731

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

@@ -877,7 +883,7 @@
877883
/* Cast the response to DNSAnswerRecord for easy access to fields of the DNS response. */
878884

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

source/include/FreeRTOS_DNS_Globals.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,11 @@
189189
uint16_t usClass; /**< Only the value 'dnsCLASS_IN' is recognised, which stands for "Internet". */
190190
char * pcRequestedName; /**< A pointer to the full name of the host being looked up. */
191191
#endif
192-
#if ( ipconfigUSE_DNS_CACHE == 1 ) || ( ipconfigDNS_USE_CALLBACKS == 1 ) || ( ipconfigUSE_MDNS == 1 )
192+
193+
#if ( ipconfigIS_ENABLED( ipconfigUSE_DNS_CACHE ) || \
194+
ipconfigIS_ENABLED( ipconfigDNS_USE_CALLBACKS ) || \
195+
ipconfigIS_ENABLED( ipconfigUSE_MDNS ) || \
196+
ipconfigIS_ENABLED( ipconfigUSE_LLMNR ) )
193197
BaseType_t xDoStore; /**< Becomes true when a DNS reply was requested by this device,
194198
* i.e. it has a matching request ID. */
195199
char pcName[ ipconfigDNS_CACHE_NAME_LENGTH ]; /**< A copy of the name that is mentioned in the questions. */

0 commit comments

Comments
 (0)