asn1: Avoid calling malloc with 0 argument
Caused problems reported by oss-fuzz https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18758
This commit is contained in:
parent
cd51430ba7
commit
cc917b541f
|
@ -1500,10 +1500,12 @@ static int asn1_decode_entry(sc_context_t *ctx,struct sc_asn1_entry *entry,
|
||||||
/* Allocate buffer if needed */
|
/* Allocate buffer if needed */
|
||||||
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