Skip to content

Commit

Permalink
Fix issue with strncpy truncating null character from source string
Browse files Browse the repository at this point in the history
  • Loading branch information
bjsowa authored and paulbartell committed Nov 27, 2023
1 parent c263e33 commit c80540c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion source/FreeRTOS_DNS.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@

( void ) memset( pxAddrInfo, 0, sizeof( *pxAddrInfo ) );
pxAddrInfo->ai_canonname = pxAddrInfo->xPrivateStorage.ucName;
( void ) strncpy( pxAddrInfo->xPrivateStorage.ucName, pcName, sizeof( pxAddrInfo->xPrivateStorage.ucName ) );
( void ) strncpy( pxAddrInfo->xPrivateStorage.ucName, pcName, sizeof( pxAddrInfo->xPrivateStorage.ucName ) - 1 );
pxAddrInfo->xPrivateStorage.ucName[ sizeof( pxAddrInfo->xPrivateStorage.ucName ) - 1 ] = '\0';

pxAddrInfo->ai_addr = ( ( struct freertos_sockaddr * ) &( pxAddrInfo->xPrivateStorage.sockaddr ) );

Expand Down

0 comments on commit c80540c

Please sign in to comment.