diff options
author | Ben Wiederhake <BenWiederhake.GitHub@gmx.de> | 2021-10-23 15:43:59 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-10-23 19:16:40 +0100 |
commit | cb868cfa41072e08987e1c32f117483445ba197d (patch) | |
tree | 89660af33860e44523b81ef66fbf375f6533eb57 /Userland/Utilities/base64.cpp | |
parent | 3bf1f7ae874918365acedc3d511b60b066b9d4aa (diff) | |
download | serenity-cb868cfa41072e08987e1c32f117483445ba197d.zip |
AK+Everywhere: Make Base64 decoding fallible
Diffstat (limited to 'Userland/Utilities/base64.cpp')
-rw-r--r-- | Userland/Utilities/base64.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Userland/Utilities/base64.cpp b/Userland/Utilities/base64.cpp index 21e4dc04f5..e08e025509 100644 --- a/Userland/Utilities/base64.cpp +++ b/Userland/Utilities/base64.cpp @@ -51,7 +51,11 @@ int main(int argc, char** argv) if (decode) { auto decoded = decode_base64(StringView(buffer)); - fwrite(decoded.data(), sizeof(u8), decoded.size(), stdout); + if (!decoded.has_value()) { + warnln("base64: invalid input"); + return 1; + } + fwrite(decoded.value().data(), sizeof(u8), decoded.value().size(), stdout); return 0; } |