Skip to content

Commit

Permalink
Replace strcpy with strncpy
Browse files Browse the repository at this point in the history
  • Loading branch information
tony-josi-aws committed Jun 17, 2024
1 parent 0c8210f commit d8a8fef
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion source/FreeRTOS_DNS.c
Original file line number Diff line number Diff line change
Expand Up @@ -1517,7 +1517,7 @@
uxIndex = uxStart + 1U;

/* Copy in the host name. */
( void ) strcpy( ( char * ) &( pucUDPPayloadBuffer[ uxIndex ] ), pcHostName );
( void ) strncpy( ( char * ) &( pucUDPPayloadBuffer[ uxIndex ] ), pcHostName, strlen( pcHostName ) + 1U );

/* Walk through the string to replace the '.' characters with byte
* counts. pucStart holds the address of the byte count. Walking the
Expand Down
2 changes: 1 addition & 1 deletion source/FreeRTOS_DNS_Cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@
/* Add or update the item. */
if( strlen( pcName ) < ( size_t ) ipconfigDNS_CACHE_NAME_LENGTH )
{
( void ) strcpy( xDNSCache[ uxFreeEntry ].pcName, pcName );
( void ) strncpy( xDNSCache[ uxFreeEntry ].pcName, pcName, ipconfigDNS_CACHE_NAME_LENGTH );
( void ) memcpy( &( xDNSCache[ uxFreeEntry ].xAddresses[ 0 ] ), pxIP, sizeof( *pxIP ) );


Expand Down
2 changes: 1 addition & 1 deletion source/FreeRTOS_DNS_Callback.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
vDNSTimerReload( FreeRTOS_min_uint32( 1000U, ( uint32_t ) uxTimeout ) );
}

( void ) strcpy( pxCallback->pcName, pcHostName );
( void ) strncpy( pxCallback->pcName, pcHostName, lLength + 1U );
pxCallback->pCallbackFunction = pCallbackFunction;
pxCallback->pvSearchID = pvSearchID;
pxCallback->uxRemainingTime = uxTimeout;
Expand Down

0 comments on commit d8a8fef

Please sign in to comment.