diff options
Diffstat (limited to 'Userland/Libraries/LibCrypto')
-rw-r--r-- | Userland/Libraries/LibCrypto/ASN1/DER.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Userland/Libraries/LibCrypto/ASN1/DER.cpp b/Userland/Libraries/LibCrypto/ASN1/DER.cpp index 1fcbbc113b..d09c7ee87e 100644 --- a/Userland/Libraries/LibCrypto/ASN1/DER.cpp +++ b/Userland/Libraries/LibCrypto/ASN1/DER.cpp @@ -196,7 +196,12 @@ Result<const BitmapView, DecodeError> Decoder::decode_bit_string(ReadonlyBytes d return DecodeError::InvalidInputFormat; auto unused_bits = data[0]; - return BitmapView { const_cast<u8*>(data.offset_pointer(1)), data.size() * 8 - unused_bits }; + auto total_size_in_bits = data.size() * 8; + + if (unused_bits > total_size_in_bits) + return DecodeError::Overflow; + + return BitmapView { const_cast<u8*>(data.offset_pointer(1)), total_size_in_bits - unused_bits }; } Result<Tag, DecodeError> Decoder::peek() |