Fix DecodeBase64 to reject truncated input#1398
Conversation
If the input doesn't have the proper number of encoding characters (a multiple of 4), return an empty result. Co-Authored-By: Sean Curtis <sean.curtis@tri.global>
|
Why? Alternatively, what about throwing an exception since it's a failed conversion? |
In general for parsers, it's important to detect and reject invalid input.
The pre-existing logic in the function already returns the empty vector to indicate a conversion failure, e.g., for invalid characters: Lines 83 to 84 in 2e6383d I was trying to remain consistent with existing practice. If you would prefer that all decode failures throw instead of returning empty, I can work on revising the patch? |
|
Note that the call site already correctly interprets an empty return value as an error: yaml-cpp/include/yaml-cpp/node/convert.h Lines 462 to 464 in 2e6383d |
|
Ok sounds good |
If the input doesn't have the proper number of encoding characters (a multiple of 4), return an empty result.