diff --git a/source/FreeRTOS_DNS.c b/source/FreeRTOS_DNS.c index 7dbacd56a..5044edb4c 100644 --- a/source/FreeRTOS_DNS.c +++ b/source/FreeRTOS_DNS.c @@ -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 ) );