mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-21 05:04:46 -07:00
Fix some edge cases with max NDEF size
This commit is contained in:
@@ -50,7 +50,8 @@ void type_4_tag_cc_dump(const Type4TagData* data, uint8_t* buf, size_t len) {
|
||||
sizeof(cc->tlv[0].value.ndef_file_ctrl.file_id),
|
||||
(void*)&cc->tlv[0].value.ndef_file_ctrl.file_id);
|
||||
bit_lib_num_to_bytes_be(
|
||||
data->is_tag_specific ? data->ndef_max_len : TYPE_4_TAG_DEFAULT_NDEF_SIZE,
|
||||
sizeof(uint16_t) +
|
||||
(data->is_tag_specific ? data->ndef_max_len : TYPE_4_TAG_DEFAULT_NDEF_SIZE),
|
||||
sizeof(cc->tlv[0].value.ndef_file_ctrl.max_len),
|
||||
(void*)&cc->tlv[0].value.ndef_file_ctrl.max_len);
|
||||
cc->tlv[0].value.ndef_file_ctrl.read_perm =
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
#define TYPE_4_TAG_BUF_SIZE (256U - 3U - 2U)
|
||||
// Read returns 2 byte status trailer, write sends 5 byte command header
|
||||
#define TYPE_4_TAG_CHUNK_LEN MIN(TYPE_4_TAG_BUF_SIZE - 5U, TYPE_4_TAG_ISO_RW_CHUNK_LEN)
|
||||
#define TYPE_4_TAG_DEFAULT_NDEF_SIZE (2048U)
|
||||
#define TYPE_4_TAG_DEFAULT_NDEF_SIZE (2048U - sizeof(uint16_t))
|
||||
|
||||
extern const uint8_t type_4_tag_iso_mf_name[TYPE_4_TAG_ISO_NAME_LEN];
|
||||
extern const uint8_t type_4_tag_iso_df_name[TYPE_4_TAG_ISO_NAME_LEN];
|
||||
|
||||
@@ -196,8 +196,9 @@ static Type4TagError type_4_tag_listener_iso_write(
|
||||
}
|
||||
|
||||
if(instance->state == Type4TagListenerStateSelectedNdefMessage) {
|
||||
if(offset + lc > (instance->data->is_tag_specific ? instance->data->ndef_max_len :
|
||||
TYPE_4_TAG_DEFAULT_NDEF_SIZE)) {
|
||||
if(offset + lc > sizeof(uint16_t) + (instance->data->is_tag_specific ?
|
||||
instance->data->ndef_max_len :
|
||||
TYPE_4_TAG_DEFAULT_NDEF_SIZE)) {
|
||||
bit_buffer_append_bytes(
|
||||
instance->tx_buffer,
|
||||
type_4_tag_offset_error_apdu,
|
||||
|
||||
Reference in New Issue
Block a user