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/Libraries/LibCrypto/ASN1 | |
parent | 3bf1f7ae874918365acedc3d511b60b066b9d4aa (diff) | |
download | serenity-cb868cfa41072e08987e1c32f117483445ba197d.zip |
AK+Everywhere: Make Base64 decoding fallible
Diffstat (limited to 'Userland/Libraries/LibCrypto/ASN1')
-rw-r--r-- | Userland/Libraries/LibCrypto/ASN1/PEM.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Userland/Libraries/LibCrypto/ASN1/PEM.cpp b/Userland/Libraries/LibCrypto/ASN1/PEM.cpp index 53768f67b4..c901febe41 100644 --- a/Userland/Libraries/LibCrypto/ASN1/PEM.cpp +++ b/Userland/Libraries/LibCrypto/ASN1/PEM.cpp @@ -35,7 +35,11 @@ ByteBuffer decode_pem(ReadonlyBytes data) break; } auto b64decoded = decode_base64(lexer.consume_line().trim_whitespace(TrimMode::Right)); - if (!decoded.try_append(b64decoded.data(), b64decoded.size())) { + if (!b64decoded.has_value()) { + dbgln("Failed to decode PEM, likely bad Base64"); + return {}; + } + if (!decoded.try_append(b64decoded.value().data(), b64decoded.value().size())) { dbgln("Failed to decode PEM, likely OOM condition"); return {}; } |