Skip to content

Base64{Url} incorrectly handles small destinations when inputs contain whitespace #123222

@MihaZupan

Description

@MihaZupan
byte[] input = Encoding.UTF8.GetBytes("  zA==  ");
Console.WriteLine(Base64Url.DecodeFromUtf8(input, new byte[5])); // writes 1 byte
Console.WriteLine(Base64Url.DecodeFromUtf8(input, new byte[1])); // "Destination is too short."
_ = Base64Url.DecodeFromChars(new string(' ', 8), new byte[1]); // "Destination is too short."

Our logic in the core DecodeFrom workhorse isn't properly accounting for the possibility of skippable whitespace when calculating how much input we can process for a given destination size.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions