Skip to content

Commit c80540c

Browse files
bjsowapaulbartell
authored andcommitted
Fix issue with strncpy truncating null character from source string
1 parent c263e33 commit c80540c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

source/FreeRTOS_DNS.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,8 @@
282282

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

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

0 commit comments

Comments
 (0)