소스 검색

LibCrypto: Fix inverted boolean decoded error in ASN.1

ASN.1 encodes booleans as false is zero and true is non-zero. The
decoder currently returned true when the boolean was zero.

Since this decoder was barely used it did not cause any problems,
however for support of other certificate extensions the correct version
is required.
Michiel Visser 3 년 전
부모
커밋
b16b61f6bc
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      Userland/Libraries/LibCrypto/ASN1/DER.cpp

+ 1 - 1
Userland/Libraries/LibCrypto/ASN1/DER.cpp

@@ -100,7 +100,7 @@ Result<bool, DecodeError> Decoder::decode_boolean(ReadonlyBytes data)
     if (data.size() != 1)
     if (data.size() != 1)
         return DecodeError::InvalidInputFormat;
         return DecodeError::InvalidInputFormat;
 
 
-    return data[0] == 0;
+    return data[0] != 0;
 }
 }
 
 
 Result<UnsignedBigInteger, DecodeError> Decoder::decode_arbitrary_sized_integer(ReadonlyBytes data)
 Result<UnsignedBigInteger, DecodeError> Decoder::decode_arbitrary_sized_integer(ReadonlyBytes data)