Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace strcpy with strncpy #1157

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion test/cbmc/proofs/DNS/CreateDNSMessage/Makefile.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[
"--unwind 1",
"--unwindset strlen.0:{HOSTNAME_UNWIND}",
"--unwindset strcpy.0:{HOSTNAME_UNWIND}",
"--unwindset strncpy.0:{HOSTNAME_UNWIND}",
"--unwindset __CPROVER_file_local_FreeRTOS_DNS_c_prvCreateDNSMessage.0:{HOSTNAME_UNWIND}",
"--unwindset __CPROVER_file_local_FreeRTOS_DNS_c_prvCreateDNSMessage.1:{HOSTNAME_UNWIND}",
"--nondet-static"
Expand Down
Loading