-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
IndexOutOfRangeException on decoding base64 bytes with LF characters included (>= .NET 5 only) #76918
Comments
Tagging subscribers to this area: @dotnet/area-system-security, @vcsjones Issue DetailsDescriptionI have upgraded runtime from netcoreapp3.1 to NET 6 and the code which was transforming base64 bytes containing LF characters to string without errors started to crash with IndexOutOfRangeException. Behavior is the same for Windows and Linux platforms. Reproduction Steps
Expected behavior"abcdef" in the output, which is happening for example on netcoreapp3.1 runtime. Actual behavior
Regression?Regression happened after the upgrade from netcoreapp3.1 to NET 6. Known WorkaroundsNo response ConfigurationNo response Other informationNo response
|
It is worth mentioning that the same input but using a CRLF delimiter works without exceptions. |
The crash happens in Line 267 in 4850c88
tmpBuffer which is to happen with \n in your example (len=1), whilst for \r\n len=2 (or any other whitespace instead of \r ).So the problem is in FromBase64Transform (test-hole?).
Side note: |
Having another look with the input
Point 4 is the problem here. For futher analysis I don't have time now... |
FYI guys from SO suggested padding base64 bytes to the length of % 4 as a workaround until this is fixed. It seems to work and the implementation is simpler than adding a middleware stream which would remove all whitespaces from base64 bytes input. |
@gfoidl we arrived to the same conclusion, see https://stackoverflow.com/questions/74039771/indexoutofrangeexception-on-decoding-base64-bytes-with-lf-characters-included/74041328#74041328. |
OK. But why was here no link to to SO given before as that had saved a bit of work? And vice-versa. |
Yeah, sorry about the links, just thought I'd launch SO and GitHub issue processes in parallel, so the solution would be found faster. |
Description
I have upgraded runtime from netcoreapp3.1 to NET 6 and the code which was transforming base64 bytes containing LF characters to string without errors started to crash with IndexOutOfRangeException. Behavior is the same for Windows and Linux platforms.
Reproduction Steps
Expected behavior
"abcdef" in the output, which is happening for example on netcoreapp3.1 runtime.
Actual behavior
Regression?
Regression happened after the upgrade from netcoreapp3.1 to NET 5/NET 6.
Known Workarounds
No response
Configuration
No response
Other information
No response
The text was updated successfully, but these errors were encountered: