From 8bdcfa1041e7da6042616ce006f5b37dc78b8307 Mon Sep 17 00:00:00 2001 From: Pol Henarejos Date: Fri, 3 Jun 2022 11:16:25 +0200 Subject: [PATCH] Replacing with asn1 tag len function. Signed-off-by: Pol Henarejos --- src/fs/file.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fs/file.c b/src/fs/file.c index e586be2..e20eed1 100644 --- a/src/fs/file.c +++ b/src/fs/file.c @@ -379,7 +379,7 @@ int meta_add(uint16_t fid, const uint8_t *data, uint16_t len) { return CCID_OK; } else { //needs reallocation - uint8_t *tpos = p-tag_len-format_tlv_len(tag_len, NULL)-1; + uint8_t *tpos = p-asn1_len_tag(tag, tag_len); memmove(tpos, p, fdata+ef_size-p); tpos += fdata+ef_size-p; uintptr_t meta_offset = tpos-fdata; @@ -401,14 +401,14 @@ int meta_add(uint16_t fid, const uint8_t *data, uint16_t len) { } } } - fdata = (uint8_t *)realloc(fdata, ef_size+1+format_tlv_len(len+2,NULL)+2+len); + fdata = (uint8_t *)realloc(fdata, ef_size+asn1_len_tag(fid & 0x1f, len+2)); uint8_t *f = fdata+ef_size; *f++ = fid & 0x1f; f += format_tlv_len(len+2, f); *f++ = fid >> 8; *f++ = fid & 0xff; memcpy(f, data, len); - r = flash_write_data_to_file(ef, fdata, ef_size+1+format_tlv_len(len+2,NULL)+2+len); + r = flash_write_data_to_file(ef, fdata, ef_size+asn1_len_tag(fid & 0x1f, len+2)); free(fdata); if (r != CCID_OK) return CCID_EXEC_ERROR;