asn1: Do not crash on invalid arguments

This commit is contained in:
Jakub Jelen 2020-05-21 16:28:48 +02:00
parent a020b85d94
commit cb8c7647ca
1 changed files with 4 additions and 0 deletions

View File

@ -1991,6 +1991,10 @@ static int asn1_encode(sc_context_t *ctx, const struct sc_asn1_entry *asn1,
u8 *obj = NULL, *buf = NULL, *tmp;
size_t total = 0, objsize;
if (asn1 == NULL) {
return SC_ERROR_INVALID_ARGUMENTS;
}
for (idx = 0; asn1[idx].name != NULL; idx++) {
r = asn1_encode_entry(ctx, &asn1[idx], &obj, &objsize, depth);
if (r) {