Delete meta file if becomes zero.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos
2023-01-14 00:39:06 +01:00
parent 7293683906
commit f59b7d92ef

View File

@@ -353,6 +353,9 @@ int meta_delete(uint16_t fid) {
uint16_t cfid = (tag_data[0] << 8 | tag_data[1]); uint16_t cfid = (tag_data[0] << 8 | tag_data[1]);
if (cfid == fid) { if (cfid == fid) {
size_t new_len = data_len-1-tag_len-format_tlv_len(tag_len, NULL); size_t new_len = data_len-1-tag_len-format_tlv_len(tag_len, NULL);
if (new_len == 0)
flash_clear_file(ef);
else {
fdata = (uint8_t *)calloc(1, new_len); fdata = (uint8_t *)calloc(1, new_len);
if (tpos > data) { if (tpos > data) {
memcpy(fdata, data, tpos-data); memcpy(fdata, data, tpos-data);
@@ -364,6 +367,7 @@ int meta_delete(uint16_t fid) {
free(fdata); free(fdata);
if (r != CCID_OK) if (r != CCID_OK)
return CCID_EXEC_ERROR; return CCID_EXEC_ERROR;
}
low_flash_available(); low_flash_available();
break; break;
} }