From 710df522feca97755bc0a058f0a7c8612da4c6c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AD=90=E6=AD=AA?= Date: Sun, 23 Aug 2026 05:27:19 +0800 Subject: [PATCH 1/2] fix: correct NLEN wording and empty record example --- client/src/cmdhf14a.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/client/src/cmdhf14a.c b/client/src/cmdhf14a.c index 6758384d9..7cdab3cb6 100644 --- a/client/src/cmdhf14a.c +++ b/client/src/cmdhf14a.c @@ -4225,7 +4225,7 @@ int CmdHF14ANdefWrite(const char *Cmd) { CLIParserContext *ctx; CLIParserInit(&ctx, "hf 14a ndefwrite", "Write raw NDEF hex bytes to tag. This commands assumes tag already been NFC/NDEF formatted.\n", - "hf 14a ndefwrite -d 0300FE -> write empty record to tag\n" + "hf 14a ndefwrite -d 0000 -> write empty record to tag\n" "hf 14a ndefwrite -f myfilename\n" "hf 14a ndefwrite -d 003fd1023a53709101195405656e2d55534963656d616e2054776974746572206c696e6b5101195502747769747465722e636f6d2f686572726d616e6e31303031\n" ); @@ -4300,11 +4300,16 @@ int CmdHF14ANdefWrite(const char *Cmd) { } uint8_t tmp_raw[256]; memcpy(tmp_raw, raw, sizeof(tmp_raw)); + // A NFC Type 4 Tag NDEF file starts with the NLEN field, a two byte + // big endian length of the NDEF message that follows. It is not a + // TLV container, so there is no 0x03 tag byte here. + // raw[] is 256 bytes and the bounds check above caps bytes at 254, + // hence the high byte of NLEN is always zero. raw[0] = 0x00; raw[1] = bytes; memcpy(raw + 2, tmp_raw, sizeof(raw) - 2); bytes += 2; - PrintAndLogEx(SUCCESS, "Added generic message header (0x03)"); + PrintAndLogEx(SUCCESS, "Added NDEF length prefix (NLEN)"); } } } From 910f6ba41fd2a937ea9181650774af2429f453a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AD=90=E6=AD=AA?= Date: Sun, 30 Aug 2026 03:46:41 +0800 Subject: [PATCH 2/2] Update cmdhf14a.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 歐歪 --- client/src/cmdhf14a.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/client/src/cmdhf14a.c b/client/src/cmdhf14a.c index 7cdab3cb6..9c4ec7e01 100644 --- a/client/src/cmdhf14a.c +++ b/client/src/cmdhf14a.c @@ -4300,12 +4300,7 @@ int CmdHF14ANdefWrite(const char *Cmd) { } uint8_t tmp_raw[256]; memcpy(tmp_raw, raw, sizeof(tmp_raw)); - // A NFC Type 4 Tag NDEF file starts with the NLEN field, a two byte - // big endian length of the NDEF message that follows. It is not a - // TLV container, so there is no 0x03 tag byte here. - // raw[] is 256 bytes and the bounds check above caps bytes at 254, - // hence the high byte of NLEN is always zero. - raw[0] = 0x00; + raw[0] = 0x00; // the high byte of NLEN is always zero. raw[1] = bytes; memcpy(raw + 2, tmp_raw, sizeof(raw) - 2); bytes += 2;