Skip to content

Commit 36e3285

Browse files
committed
addressed Copilot review comments
1 parent a658fc2 commit 36e3285

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

src/crypto/clu_crypto_setup.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,9 +365,10 @@ int wolfCLU_setup(int argc, char** argv, char action)
365365
wolfCLU_LogError("input too long, please try again");
366366
continue;
367367
}
368-
inName[strcspn(inName, "\n")] = '\0';
368+
inName[strcspn(inName, "\r\n")] = '\0';
369369
/* Do not accept an empty string as valid input */
370370
if (inName[0] == '\0') {
371+
wolfCLU_LogError("empty input, please enter a file name");
371372
continue;
372373
}
373374
ret = 1;
@@ -436,8 +437,9 @@ int wolfCLU_setup(int argc, char** argv, char action)
436437
wolfCLU_LogError("input too long, please try again");
437438
continue;
438439
}
439-
outNameEnc[strcspn(outNameEnc, "\n")] = '\0';
440+
outNameEnc[strcspn(outNameEnc, "\r\n")] = '\0';
440441
if (outNameEnc[0] == '\0') {
442+
wolfCLU_LogError("empty input, please enter a file name");
441443
continue;
442444
}
443445
out = outNameEnc;
@@ -478,8 +480,9 @@ int wolfCLU_setup(int argc, char** argv, char action)
478480
wolfCLU_LogError("input too long, please try again");
479481
continue;
480482
}
481-
outNameDec[strcspn(outNameDec, "\n")] = '\0';
483+
outNameDec[strcspn(outNameDec, "\r\n")] = '\0';
482484
if (outNameDec[0] == '\0') {
485+
wolfCLU_LogError("empty input, please enter a file name");
483486
continue;
484487
}
485488
out = outNameDec;

src/tools/clu_funcs.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,14 +1249,16 @@ void wolfCLU_AddNameEntry(WOLFSSL_X509_NAME* name, int type, int nid, char* str)
12491249
WOLFSSL_X509_NAME_ENTRY *entry;
12501250

12511251
if (str != NULL) {
1252-
/* strip off newline character if found at the end of str */
1253-
i = (int)XSTRLEN((const char*)str);
1252+
/* strip off newline/carriage-return characters at the end of str */
1253+
i = (int)XSTRLEN((const char*)str) - 1;
12541254
while (i >= 0) {
1255-
if (str[i] == '\n') {
1255+
if (str[i] == '\n' || str[i] == '\r') {
12561256
str[i] = '\0';
1257+
i--;
1258+
}
1259+
else {
12571260
break;
12581261
}
1259-
i--;
12601262
}
12611263

12621264
/* treats a '.' string as 'do not add' */

0 commit comments

Comments
 (0)