authentic: Do not leak memory on fail path
Thanks oss-fuzz https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=23788
This commit is contained in:
parent
7cf8087351
commit
5098cfdb40
|
@ -540,7 +540,10 @@ authentic_set_current_files(struct sc_card *card, struct sc_path *path,
|
|||
file->path = *path;
|
||||
|
||||
rv = authentic_process_fci(card, file, resp, resplen);
|
||||
LOG_TEST_RET(ctx, rv, "cannot set 'current file': FCI process error");
|
||||
if (rv != SC_SUCCESS) {
|
||||
sc_file_free(file);
|
||||
LOG_TEST_RET(ctx, rv, "cannot set 'current file': FCI process error");
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
|
@ -560,8 +563,10 @@ authentic_set_current_files(struct sc_card *card, struct sc_path *path,
|
|||
|
||||
if (cur_df_path.len) {
|
||||
if (cur_df_path.len + card->cache.current_df->path.len > sizeof card->cache.current_df->path.value
|
||||
|| cur_df_path.len > sizeof card->cache.current_df->path.value)
|
||||
|| cur_df_path.len > sizeof card->cache.current_df->path.value) {
|
||||
sc_file_free(file);
|
||||
LOG_FUNC_RETURN(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
|
||||
}
|
||||
memcpy(card->cache.current_df->path.value + cur_df_path.len,
|
||||
card->cache.current_df->path.value,
|
||||
card->cache.current_df->path.len);
|
||||
|
|
Loading…
Reference in New Issue