pkcs15: Avoid insane allocations

Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18592
This commit is contained in:
Jakub Jelen 2019-10-29 10:53:22 +01:00 committed by Frank Morgner
parent 51363d3392
commit 424ebf8ed1
1 changed files with 4 additions and 0 deletions

View File

@ -1113,6 +1113,10 @@ sc_pkcs15_bind_internal(struct sc_pkcs15_card *p15card, struct sc_aid *aid)
sc_log(ctx, "EF(TokenInfo) is empty");
goto end;
}
if (len > MAX_FILE_SIZE) {
sc_log(ctx, "EF(TokenInfo) too large");
goto end;
}
buf = malloc(len);
if(buf == NULL)
LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);