From ccaff6c8aeea349f09559f0821bfe3443ab5f76f Mon Sep 17 00:00:00 2001 From: Florian Franzen Date: Thu, 8 Oct 2026 22:52:35 +0200 Subject: [PATCH] Answer NotFound to GET DATA for an unknown data object tag --- CHANGELOG.md | 1 + src/commands.rs | 3 ++- tests/command_response.ron | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e1a0096..9c5ba791 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ default (5) - Fix the inverted parsing of the touch requirement in SET MANAGEMENT KEY's P2 (0xFF means no touch, 0xFE means touch required) +- Answer NotFound to GET DATA for an unknown data object tag ## [v0.7.0][] (2026-08-17) diff --git a/src/commands.rs b/src/commands.rs index 88cf4209..5f59fa22 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -111,8 +111,9 @@ impl TryFrom<&[u8]> for GetData { if tagged_slice.tag() != flexiber::Tag::application(0x1C) { return Err(Status::IncorrectDataParameter); } + // An unknown tag is an absent object let container = containers::Container::try_from(tagged_slice.as_bytes()) - .map_err(|_| Status::IncorrectDataParameter)?; + .map_err(|_| Status::NotFound)?; info!("request to GetData for container {:?}", container); Ok(Self(container)) diff --git a/tests/command_response.ron b/tests/command_response.ron index 7bc7ecea..6cf53348 100644 --- a/tests/command_response.ron +++ b/tests/command_response.ron @@ -255,6 +255,23 @@ ) ] ), + IoTest( + name: "Unknown data object", + cmd_resp: [ + GetData( + input: "5C 03 5FFF00", + expected_status: NotFound + ), + GetData( + input: "5C 03 5FABCD", + expected_status: NotFound + ), + GetData( + input: "5C 03 5FC1FF", + expected_status: NotFound + ), + ] + ), IoTest( name: "PUT DATA", cmd_resp: [