From d3e9b55223fc310b8c7c9b081618440582ea833e Mon Sep 17 00:00:00 2001 From: Jakub Jelen Date: Mon, 4 Nov 2019 17:26:41 +0100 Subject: [PATCH] asn1: Distinguish error codes for invalid objects from implementation limitation (integer size) --- src/libopensc/asn1.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libopensc/asn1.c b/src/libopensc/asn1.c index 68a71022..61fe6fbe 100644 --- a/src/libopensc/asn1.c +++ b/src/libopensc/asn1.c @@ -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++);