mirror of
https://github.com/polhenarejos/pico-keys-sdk
synced 2026-05-07 21:46:10 +02:00
If file functions are called with NULL arg silently return.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
@@ -284,6 +284,8 @@ file_t *search_dynamic_file(uint16_t fid) {
|
||||
}
|
||||
|
||||
int delete_dynamic_file(file_t *f) {
|
||||
if (f == NULL)
|
||||
return NULL;
|
||||
for (int i = 0; i < dynamic_files; i++) {
|
||||
if (dynamic_file[i].fid == f->fid) {
|
||||
for (int j = i+1; j < dynamic_files; j++)
|
||||
@@ -439,6 +441,8 @@ bool file_has_data(file_t *f) {
|
||||
}
|
||||
|
||||
int delete_file(file_t *ef) {
|
||||
if (ef == NULL)
|
||||
return CCID_OK;
|
||||
meta_delete(ef->fid);
|
||||
if (flash_clear_file(ef) != CCID_OK)
|
||||
return CCID_EXEC_ERROR;
|
||||
|
||||
@@ -95,6 +95,8 @@ uintptr_t allocate_free_addr(uint16_t size, bool persistent) {
|
||||
}
|
||||
|
||||
int flash_clear_file(file_t *file) {
|
||||
if (file == NULL)
|
||||
return CCID_OK;
|
||||
uintptr_t base_addr = (uintptr_t)(file->data-sizeof(uintptr_t)-sizeof(uint16_t)-sizeof(uintptr_t));
|
||||
uintptr_t prev_addr = flash_read_uintptr(base_addr+sizeof(uintptr_t));
|
||||
uintptr_t next_addr = flash_read_uintptr(base_addr);
|
||||
|
||||
Reference in New Issue
Block a user