@@ -67,7 +67,7 @@ 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 );
7171
7272 /* initialize rng to make the rsa key */
7373 ret = wc_InitRng_ex (rng , NULL , WH_DEV_ID );
@@ -144,7 +144,7 @@ int wh_DemoClient_CryptoRsaImport(whClientContext* clientContext)
144144 WC_RNG rng [1 ];
145145
146146 /* set the plainText to the test string */
147- strcpy ((char * )plainText , plainString );
147+ strncpy ((char * )plainText , plainString , sizeof ( plainText ) - 1 );
148148
149149 /* initialize rng to encrypt with the rsa key */
150150 ret = wc_InitRng_ex (rng , NULL , WH_DEV_ID );
@@ -497,7 +497,8 @@ int wh_DemoClient_CryptoEcc(whClientContext* clientContext)
497497 byte signature [128 ];
498498
499499 /* Set the message to the test string */
500- strcpy ((char * )message , plainMessage );
500+ strncpy ((char * )message , plainMessage , sizeof (message )- 1 );
501+ message [sizeof (message )- 1 ] = '\0' ;
501502
502503 /* Initialize the rng to make the ecc keys */
503504 ret = wc_InitRng_ex (rng , NULL , WH_DEV_ID );
@@ -627,7 +628,8 @@ int wh_DemoClient_CryptoEccImport(whClientContext* clientContext)
627628 uint8_t keyBuf [256 ];
628629
629630 /* Set the message to the test string */
630- strcpy ((char * )message , plainMessage );
631+ strncpy ((char * )message , plainMessage , sizeof (message )- 1 );
632+ message [sizeof (message )- 1 ] = '\0' ;
631633
632634 /* Initialize the rng for signature signing */
633635 ret = wc_InitRng_ex (rng , NULL , WH_DEV_ID );
0 commit comments