-
Notifications
You must be signed in to change notification settings - Fork 38
F 569 : Fix stack buffer overflow in encryption setup #212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -346,8 +346,31 @@ int wolfCLU_setup(int argc, char** argv, char action) | |||||||
| while (ret == 0) { | ||||||||
| WOLFCLU_LOG(WOLFCLU_L0, | ||||||||
| "-in flag was not set, please enter a string or" | ||||||||
| "file name to be encrypted: "); | ||||||||
| ret = (int) scanf("%s", inName); | ||||||||
| " file name to be encrypted: "); | ||||||||
| if (fgets(inName, sizeof(inName), stdin) == NULL) { | ||||||||
| /* EOF or read error: cannot prompt further */ | ||||||||
| wolfCLU_LogError("failed to read input file name"); | ||||||||
| wolfCLU_freeBins(pwdKey, iv, key, NULL, NULL); | ||||||||
| if (mode != NULL) | ||||||||
| XFREE(mode, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER); | ||||||||
| return WOLFCLU_FATAL_ERROR; | ||||||||
| } | ||||||||
| /* If no newline is present, the line was too long: flush and | ||||||||
| * re-prompt rather than proceeding with a truncated filename. */ | ||||||||
| if (strchr(inName, '\n') == NULL) { | ||||||||
| int ch; | ||||||||
| do { | ||||||||
| ch = getchar(); | ||||||||
| } while (ch != '\n' && ch != EOF); | ||||||||
| wolfCLU_LogError("input too long, please try again"); | ||||||||
| continue; | ||||||||
| } | ||||||||
| inName[strcspn(inName, "\n")] = '\0'; | ||||||||
|
||||||||
| inName[strcspn(inName, "\n")] = '\0'; | |
| inName[strcspn(inName, "\r\n")] = '\0'; |
Copilot
AI
Apr 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty input is silently ignored and the loop re-prompts without any feedback. Consider logging a short message (or re-printing the prompt with a clear hint) so interactive users understand why it’s asking again. Same applies to the empty-string checks for outNameEnc/outNameDec.
| if (inName[0] == '\0') { | |
| if (inName[0] == '\0') { | |
| wolfCLU_LogError("empty input is not allowed, please try again"); |
miyazakh marked this conversation as resolved.
Show resolved
Hide resolved
miyazakh marked this conversation as resolved.
Show resolved
Hide resolved
miyazakh marked this conversation as resolved.
Show resolved
Hide resolved
miyazakh marked this conversation as resolved.
Show resolved
Hide resolved
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -185,5 +185,89 @@ fi | |||||||
| rm -f test-dec.der | ||||||||
| rm -f test-enc.der | ||||||||
|
|
||||||||
| # Regression tests for stack buffer overflow fix (scanf -> fgets) | ||||||||
|
|
||||||||
| # Test: -in not provided, filename supplied via stdin to exercise the inName Path | ||||||||
|
||||||||
| # Test: -in not provided, filename supplied via stdin to exercise the inName Path | |
| # Test: -in not provided, filename supplied via stdin to exercise the inName Path | |
| rm -f test-stdin-in.enc test-stdin-in.dec |
Copilot
AI
Apr 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests assume the output files don’t already exist. If ./wolfssl enc prompts/refuses on overwrite (or if a previous run left artifacts), the test can hang or behave inconsistently. Consider rm -f of the target outputs before invoking ./wolfssl enc for each case to make runs idempotent.
Copilot
AI
Apr 7, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests assume the output files don’t already exist. If ./wolfssl enc prompts/refuses on overwrite (or if a previous run left artifacts), the test can hang or behave inconsistently. Consider rm -f of the target outputs before invoking ./wolfssl enc for each case to make runs idempotent.
Uh oh!
There was an error while loading. Please reload this page.