Skip to content

Commit 15eab97

Browse files
committed
don't over-allocate that much in der_decode_subject_public_key_info()
1 parent 0b04279 commit 15eab97

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/pk/asn1/der/sequence/der_decode_subject_public_key_info.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ int der_decode_subject_public_key_info(const unsigned char *in, unsigned long in
5858
}
5959

6060
/* see if the OpenSSL DER format RSA public key will work */
61-
tmpbuf = XCALLOC(1, LTC_DER_MAX_PUBKEY_SIZE*8);
61+
tmpbuf = XCALLOC(1, inlen);
6262
if (tmpbuf == NULL) {
6363
err = CRYPT_MEM;
6464
goto LBL_ERR;
@@ -72,7 +72,7 @@ int der_decode_subject_public_key_info(const unsigned char *in, unsigned long in
7272
* in a **BIT** string ... so we have to extract it then proceed to convert bit to octet
7373
*/
7474
LTC_SET_ASN1(subject_pubkey, 0, LTC_ASN1_SEQUENCE, alg_id, 2);
75-
LTC_SET_ASN1(subject_pubkey, 1, LTC_ASN1_RAW_BIT_STRING, tmpbuf, LTC_DER_MAX_PUBKEY_SIZE*8);
75+
LTC_SET_ASN1(subject_pubkey, 1, LTC_ASN1_RAW_BIT_STRING, tmpbuf, inlen);
7676

7777
err=der_decode_sequence(in, inlen, subject_pubkey, 2UL);
7878
if (err != CRYPT_OK) {

0 commit comments

Comments
 (0)