asn1: Distinguish error codes for invalid objects from implementation limitation (integer size)

This commit is contained in:
Jakub Jelen 2019-11-04 17:26:41 +01:00
parent 1271299955
commit d3e9b55223
1 changed files with 5 additions and 1 deletions

View File

@ -718,8 +718,12 @@ int sc_asn1_decode_integer(const u8 * inbuf, size_t inlen, int *out)
int a = 0, is_negative = 0;
size_t i = 0;
if (inlen > sizeof(int) || inlen == 0)
if (inlen == 0) {
return SC_ERROR_INVALID_ASN1_OBJECT;
}
if (inlen > sizeof(int)) {
return SC_ERROR_NOT_SUPPORTED;
}
if (inbuf[0] & 0x80) {
is_negative = 1;
a |= 0xff^(*inbuf++);