Fixes out of bounds read

This commit is contained in:
Frank Morgner 2015-09-17 21:14:49 +02:00
parent 69320f9d54
commit 07038225a7
1 changed files with 2 additions and 0 deletions

View File

@ -256,6 +256,8 @@ static int gemsafe_get_cert_len(sc_card_t *card)
return SC_SUCCESS;
}
/* DER cert len is encoded this way */
if (ind+3 >= sizeof ibuf)
return SC_ERROR_INVALID_DATA;
certlen = ((((size_t) ibuf[ind+2]) << 8) | ibuf[ind+3]) + 4;
sc_log(card->ctx, "Found certificate of key container %d at offset %d, len %d", i+1, ind, certlen);
gemsafe_cert[i].index = ind;