asn1: Avoid invalid unused bits values

This commit is contained in:
Jakub Jelen 2019-10-24 11:25:30 +02:00
parent 8d49e4a305
commit c1814571bd
1 changed files with 3 additions and 0 deletions

View File

@ -577,6 +577,9 @@ static int decode_bit_string(const u8 * inbuf, size_t inlen, void *outbuf,
if (inlen < 1)
return SC_ERROR_INVALID_ASN1_OBJECT;
/* ITU-T Rec. X.690 8.6.2.2: The number shall be in the range zero to seven. */
if ((*in & ~0x07) != 0)
return SC_ERROR_INVALID_ASN1_OBJECT;
memset(outbuf, 0, outlen);
zero_bits = *in & 0x07;
in++;