File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -533,7 +533,13 @@ supported by Windows' cmd.\n\n");
533533 }
534534
535535 char keystr [MAX_KEYSTR_LENGTH ];
536+ for (int i = 0 ; i < MAX_KEYSTR_LENGTH ; i ++ ) {
537+ keystr [i ] = 0 ;
538+ }
536539 uint8_t key [Nb * Nb ];
540+ for (int i = 0 ; i < Nb * Nb ; i ++ ) {
541+ key [i ] = 0 ;
542+ }
537543
538544 if ((o_enc || o_dec )) {
539545 #ifdef __LINUX__
@@ -545,14 +551,19 @@ supported by Windows' cmd.\n\n");
545551 if (!fgets (input , sizeof (input ), stdin )) {
546552 fprintf (stderr , "The key is too long, the max size is %d.\n" , MAX_KEYSTR_LENGTH - 1 );
547553 return EXIT_FAILURE ;
554+ } else {
555+ size_t len = strcspn (input , "\n" );
556+ for (int i = len ; i < MAX_KEYSTR_LENGTH ; i ++ ) {
557+ input [i ] = '\0' ;
558+ }
548559 }
549560 #endif
550561
551562 if (strlen (input ) >= MAX_KEYSTR_LENGTH - 1 ) {
552563 fprintf (stderr , "🚧 The key is too long, the max size is %d.\n" , MAX_KEYSTR_LENGTH - 1 );
553564 return EXIT_FAILURE ;
554565 }
555-
566+
556567 strncpy (keystr , input , sizeof (keystr ));
557568
558569 // Clear the original input from memory for security
You can’t perform that action at this time.
0 commit comments