mirror of
https://github.com/RfidResearchGroup/ChameleonUltra.git
synced 2026-05-12 11:22:59 -07:00
Fix commands for r/w into UL / NTAG emulator memory.
This commit is contained in:
@@ -791,6 +791,7 @@ static data_frame_tx_t *cmd_processor_mf1_read_emu_block_data(uint16_t cmd, uint
|
||||
}
|
||||
|
||||
static data_frame_tx_t *cmd_processor_mf0_ntag_write_emu_page_data(uint16_t cmd, uint16_t status, uint16_t length, uint8_t *data) {
|
||||
uint8_t byte;
|
||||
uint8_t active_slot = tag_emulation_get_slot();
|
||||
|
||||
tag_slot_specific_type_t active_slot_tag_types;
|
||||
@@ -800,11 +801,14 @@ static data_frame_tx_t *cmd_processor_mf0_ntag_write_emu_page_data(uint16_t cmd,
|
||||
// This means wrong slot type.
|
||||
if (nr_pages <= 0) return data_frame_make(cmd, STATUS_INVALID_SLOT_TYPE, 0, data);
|
||||
|
||||
if (length < 2) return data_frame_make(cmd, STATUS_INVALID_PARAMS, 1, &nr_pages);
|
||||
if (length < 2) {
|
||||
byte = nr_pages;
|
||||
return data_frame_make(cmd, STATUS_INVALID_PARAMS, 1, &byte);
|
||||
}
|
||||
|
||||
int page_index = data[0];
|
||||
int pages_count = data[1];
|
||||
int byte_length = (int)nr_pages * NFC_TAG_MF0_NTAG_DATA_SIZE;
|
||||
int byte_length = (int)pages_count * NFC_TAG_MF0_NTAG_DATA_SIZE;
|
||||
|
||||
if (pages_count == 0) return data_frame_make(cmd, STATUS_SUCCESS, 0, NULL);
|
||||
else if (
|
||||
@@ -812,7 +816,8 @@ static data_frame_tx_t *cmd_processor_mf0_ntag_write_emu_page_data(uint16_t cmd,
|
||||
|| (pages_count > (((int)nr_pages) - page_index))
|
||||
|| (((int)length - 2) < byte_length)
|
||||
) {
|
||||
return data_frame_make(cmd, STATUS_INVALID_PARAMS, 1, &nr_pages);
|
||||
byte = nr_pages;
|
||||
return data_frame_make(cmd, STATUS_INVALID_PARAMS, 1, &byte);
|
||||
}
|
||||
|
||||
tag_data_buffer_t *buffer = get_buffer_by_tag_type(active_slot_tag_types.tag_hf);
|
||||
@@ -824,6 +829,7 @@ static data_frame_tx_t *cmd_processor_mf0_ntag_write_emu_page_data(uint16_t cmd,
|
||||
}
|
||||
|
||||
static data_frame_tx_t *cmd_processor_mf0_ntag_read_emu_page_data(uint16_t cmd, uint16_t status, uint16_t length, uint8_t *data) {
|
||||
uint8_t byte;
|
||||
uint8_t active_slot = tag_emulation_get_slot();
|
||||
|
||||
tag_slot_specific_type_t active_slot_tag_types;
|
||||
@@ -833,14 +839,18 @@ static data_frame_tx_t *cmd_processor_mf0_ntag_read_emu_page_data(uint16_t cmd,
|
||||
// This means wrong slot type.
|
||||
if (nr_pages <= 0) return data_frame_make(cmd, STATUS_INVALID_SLOT_TYPE, 0, data);
|
||||
|
||||
if (length < 2) return data_frame_make(cmd, STATUS_INVALID_PARAMS, 1, &nr_pages);
|
||||
if (length < 2) {
|
||||
byte = nr_pages;
|
||||
return data_frame_make(cmd, STATUS_INVALID_PARAMS, 1, &byte);
|
||||
}
|
||||
|
||||
int page_index = data[0];
|
||||
int pages_count = data[1];
|
||||
|
||||
if (pages_count == 0) return data_frame_make(cmd, STATUS_SUCCESS, 0, NULL);
|
||||
else if ((page_index >= ((int)nr_pages)) || (pages_count > (((int)nr_pages) - page_index))) {
|
||||
return data_frame_make(cmd, STATUS_INVALID_PARAMS, 1, &nr_pages);
|
||||
byte = nr_pages;
|
||||
return data_frame_make(cmd, STATUS_INVALID_PARAMS, 1, &byte);
|
||||
}
|
||||
|
||||
tag_data_buffer_t *buffer = get_buffer_by_tag_type(active_slot_tag_types.tag_hf);
|
||||
|
||||
Reference in New Issue
Block a user