CID 357984: Avoid casting signed integer to unsigned before checking its value

This commit is contained in:
Jakub Jelen 2020-08-04 14:31:58 +02:00 committed by Jakub Jelen
parent 34a5a80870
commit a1d35518dd
1 changed files with 3 additions and 2 deletions

View File

@ -1227,11 +1227,12 @@ piv_write_certificate(sc_card_t *card, const u8* buf, size_t count, unsigned lon
}
taglen = tmplen + tmplen2 + tmplen3;
sbuflen = sc_asn1_put_tag(0x53, NULL, taglen, NULL, 0, NULL);
if (sbuflen <= 0) {
tmplen = sc_asn1_put_tag(0x53, NULL, taglen, NULL, 0, NULL);
if (tmplen <= 0) {
LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL);
}
sbuflen = tmplen;
sbuf = malloc(sbuflen);
if (sbuf == NULL)
LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);