asn1: Avoid malloc(0) also from BIT STRING and GENERALIZED TIME structures
This commit is contained in:
parent
e50bc29bd9
commit
cd51430ba7
|
@ -1464,10 +1464,12 @@ static int asn1_decode_entry(sc_context_t *ctx,struct sc_asn1_entry *entry,
|
||||||
}
|
}
|
||||||
if (entry->flags & SC_ASN1_ALLOC) {
|
if (entry->flags & SC_ASN1_ALLOC) {
|
||||||
u8 **buf = (u8 **) parm;
|
u8 **buf = (u8 **) parm;
|
||||||
*buf = malloc(objlen-1);
|
if (objlen > 1) {
|
||||||
if (*buf == NULL) {
|
*buf = malloc(objlen-1);
|
||||||
r = SC_ERROR_OUT_OF_MEMORY;
|
if (*buf == NULL) {
|
||||||
break;
|
r = SC_ERROR_OUT_OF_MEMORY;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
*len = objlen-1;
|
*len = objlen-1;
|
||||||
parm = *buf;
|
parm = *buf;
|
||||||
|
@ -1518,10 +1520,12 @@ static int asn1_decode_entry(sc_context_t *ctx,struct sc_asn1_entry *entry,
|
||||||
assert(len != NULL);
|
assert(len != NULL);
|
||||||
if (entry->flags & SC_ASN1_ALLOC) {
|
if (entry->flags & SC_ASN1_ALLOC) {
|
||||||
u8 **buf = (u8 **) parm;
|
u8 **buf = (u8 **) parm;
|
||||||
*buf = malloc(objlen);
|
if (objlen > 0) {
|
||||||
if (*buf == NULL) {
|
*buf = malloc(objlen);
|
||||||
r = SC_ERROR_OUT_OF_MEMORY;
|
if (*buf == NULL) {
|
||||||
break;
|
r = SC_ERROR_OUT_OF_MEMORY;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
c = *len = objlen;
|
c = *len = objlen;
|
||||||
parm = *buf;
|
parm = *buf;
|
||||||
|
|
Loading…
Reference in New Issue