@@ -67,7 +67,8 @@ int wh_DemoClient_CryptoRsa(whClientContext* clientContext)
6767 WC_RNG rng [1 ];
6868
6969 /* set the plainText to the test string */
70- strcpy ((char * )plainText , plainString );
70+ strncpy ((char * )plainText , plainString , sizeof (plainText )- 1 );
71+ plainText [sizeof (plainText )- 1 ] = '\0' ;
7172
7273 /* initialize rng to make the rsa key */
7374 ret = wc_InitRng_ex (rng , NULL , WH_DEV_ID );
@@ -144,7 +145,8 @@ int wh_DemoClient_CryptoRsaImport(whClientContext* clientContext)
144145 WC_RNG rng [1 ];
145146
146147 /* set the plainText to the test string */
147- strcpy ((char * )plainText , plainString );
148+ strncpy ((char * )plainText , plainString , sizeof (plainText )- 1 );
149+ plainText [sizeof (plainText )- 1 ] = '\0' ;
148150
149151 /* initialize rng to encrypt with the rsa key */
150152 ret = wc_InitRng_ex (rng , NULL , WH_DEV_ID );
@@ -497,7 +499,8 @@ int wh_DemoClient_CryptoEcc(whClientContext* clientContext)
497499 byte signature [128 ];
498500
499501 /* Set the message to the test string */
500- strcpy ((char * )message , plainMessage );
502+ strncpy ((char * )message , plainMessage , sizeof (message )- 1 );
503+ message [sizeof (message )- 1 ] = '\0' ;
501504
502505 /* Initialize the rng to make the ecc keys */
503506 ret = wc_InitRng_ex (rng , NULL , WH_DEV_ID );
@@ -627,7 +630,8 @@ int wh_DemoClient_CryptoEccImport(whClientContext* clientContext)
627630 uint8_t keyBuf [256 ];
628631
629632 /* Set the message to the test string */
630- strcpy ((char * )message , plainMessage );
633+ strncpy ((char * )message , plainMessage , sizeof (message )- 1 );
634+ message [sizeof (message )- 1 ] = '\0' ;
631635
632636 /* Initialize the rng for signature signing */
633637 ret = wc_InitRng_ex (rng , NULL , WH_DEV_ID );
0 commit comments