summaryrefslogtreecommitdiff
path: root/Userland/Utilities/base64.cpp
diff options
context:
space:
mode:
authorBen Wiederhake <BenWiederhake.GitHub@gmx.de>2021-10-23 15:43:59 +0200
committerLinus Groh <mail@linusgroh.de>2021-10-23 19:16:40 +0100
commitcb868cfa41072e08987e1c32f117483445ba197d (patch)
tree89660af33860e44523b81ef66fbf375f6533eb57 /Userland/Utilities/base64.cpp
parent3bf1f7ae874918365acedc3d511b60b066b9d4aa (diff)
downloadserenity-cb868cfa41072e08987e1c32f117483445ba197d.zip
AK+Everywhere: Make Base64 decoding fallible
Diffstat (limited to 'Userland/Utilities/base64.cpp')
-rw-r--r--Userland/Utilities/base64.cpp6
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;
}