-
Notifications
You must be signed in to change notification settings - Fork 991
Fenrir Fixes #10675
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
Open
kareem-wolfssl
wants to merge
6
commits into
wolfSSL:master
Choose a base branch
from
kareem-wolfssl:f5393
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+48
−19
Open
Fenrir Fixes #10675
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
857c448
Zero out buffer on error in AES_GCM_decrypt_C.
kareem-wolfssl d654293
Zero out the aead in wc_ChaCha20Poly1305_Encrypt/Decrypt before freei…
kareem-wolfssl 8f0d2d8
Limit parsed port to 65535 in wolfIO_DecodeUrl.
kareem-wolfssl 207f08a
Fix length calculations in wolfSSL_BUF_MEM_grow_ex and wolfSSL_BUF_ME…
kareem-wolfssl 5982bb9
Fix wolfIO_DecodeUrl handling of IPv6 brackets.
kareem-wolfssl 6f59b95
Code review feedback
kareem-wolfssl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1710,6 +1710,12 @@ int wolfIO_DecodeUrl(const char* url, int urlSz, char* outName, char* outPath, | |
| outName[i] = url[cur]; | ||
| i++; cur++; | ||
| } | ||
| /* A bracketed IPv6 literal must be terminated by ']'. The loop | ||
| * above can also stop on end-of-buffer, NUL, or the length cap, | ||
| * none of which represent a well-formed host. Reject those cases | ||
| * rather than accepting the unterminated tail as the hostname. */ | ||
| if (cur >= urlSz || url[cur] != ']') | ||
| return WOLFSSL_FATAL_ERROR; | ||
| cur++; /* skip ']' */ | ||
| } | ||
| else { | ||
|
|
@@ -1725,23 +1731,35 @@ int wolfIO_DecodeUrl(const char* url, int urlSz, char* outName, char* outPath, | |
| /* Need to pick out the path after the domain name */ | ||
|
|
||
| if (cur < urlSz && url[cur] == ':') { | ||
| char port[6]; | ||
| char port[5]; | ||
| int j; | ||
| word32 bigPort = 0; | ||
| i = 0; | ||
| cur++; | ||
|
|
||
| XMEMSET(port, 0, sizeof(port)); | ||
|
|
||
| while (i < 6 && cur < urlSz && url[cur] != 0 && url[cur] != '/') { | ||
| while (i < 5 && cur < urlSz && url[cur] != 0 && url[cur] != '/') { | ||
| port[i] = url[cur]; | ||
| i++; cur++; | ||
| } | ||
|
|
||
| /* A valid port is at most 5 digits; if more characters remain | ||
| * before the path/terminator the port field is malformed (e.g. | ||
| * a 6-digit port) and must be rejected rather than parsed from a | ||
| * truncated digit string. */ | ||
| if (cur < urlSz && url[cur] != 0 && url[cur] != '/') | ||
| return WOLFSSL_FATAL_ERROR; | ||
|
|
||
| for (j = 0; j < i; j++) { | ||
| if (port[j] < '0' || port[j] > '9') return WOLFSSL_FATAL_ERROR; | ||
| bigPort = (bigPort * 10) + (word32)(port[j] - '0'); | ||
| } | ||
| /* Reject out-of-range ports rather than silently truncating to | ||
| * word16, which would otherwise wrap (e.g. 65536 -> 0) and | ||
| * connect to an unintended port. */ | ||
| if (bigPort > 65535) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't use a magic number here. If a macro is not already available then please add one. |
||
| return WOLFSSL_FATAL_ERROR; | ||
| if (outPort) | ||
| *outPort = (word16)bigPort; | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Use wolfSSL's macro WOLFSSL_MAX_32BIT for INT_MAX. I've seen port issues when using INT_MAX.