@@ -67,7 +67,7 @@ int wh_DemoClient_CryptoRsa(whClientContext* clientContext)
6767 (void )clientContext ;
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,7 @@ int wh_DemoClient_CryptoEcc(whClientContext* clientContext)
497497 (void )clientContext ;
498498
499499 /* Set the message to the test string */
500- strcpy ((char * )message , plainMessage );
500+ strncpy ((char * )message , plainMessage , sizeof ( message ) - 1 );
501501
502502 /* Initialize the rng to make the ecc keys */
503503 ret = wc_InitRng_ex (rng , NULL , WH_DEV_ID );
@@ -627,7 +627,7 @@ int wh_DemoClient_CryptoEccImport(whClientContext* clientContext)
627627 uint8_t keyBuf [256 ];
628628
629629 /* Set the message to the test string */
630- strcpy ((char * )message , plainMessage );
630+ strncpy ((char * )message , plainMessage , sizeof ( message ) - 1 );
631631
632632 /* Initialize the rng for signature signing */
633633 ret = wc_InitRng_ex (rng , NULL , WH_DEV_ID );
0 commit comments