From: "Frédéric Danis" <frederic.danis@collabora.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v3 7/7] unit/test-eir: Add name encoding tests
Date: Tue, 8 Jul 2025 17:43:07 +0200 [thread overview]
Message-ID: <20250708154308.238963-8-frederic.danis@collabora.com> (raw)
In-Reply-To: <20250708154308.238963-1-frederic.danis@collabora.com>
This ensures that device name encode with UTF-16, ISO-2022-JP or with
an incorrect character in UTF-8 string are truncated correctly.
---
unit/test-eir.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/unit/test-eir.c b/unit/test-eir.c
index 49ce65f24..b94a2985a 100644
--- a/unit/test-eir.c
+++ b/unit/test-eir.c
@@ -396,6 +396,50 @@ static const struct test_data fuelband_test = {
.uuid = fuelband_uuid,
};
+static const unsigned char invalid_utf8_name_data[] = {
+ 0x22, 0x09, 0x74, 0x65, 0x73, 0x74, 0x20, 0xe0,
+ 0xa4, 0xaa, 0xe0, 0xa4, 0xb0, 0xe0, 0xa5, 0x80,
+ 0xe0, 0xa4, /*0x95,*/ 0xe0, 0xa5, 0x8d, 0xe0, 0xa4,
+ 0xb7, 0xe0, 0xa4, 0xbe, 0x20, 0x69, 0x6e, 0x76,
+ 0x61, 0x6c, 0x69, 0x64,
+};
+
+static const struct test_data invalid_utf8_name_test = {
+ .eir_data = invalid_utf8_name_data,
+ .eir_size = sizeof(invalid_utf8_name_data),
+ .name = "test परी",
+ .name_complete = true,
+ .tx_power = 127,
+};
+
+static const unsigned char utf16_name_data[] = {
+ 0x17, 0x09, 0x00, 0x55, 0x00, 0x54, 0x00, 0x46,
+ 0x00, 0x2d, 0x00, 0x31, 0x00, 0x36, 0x00, 0x20,
+ 0x00, 0x74, 0x00, 0x65, 0x00, 0x73, 0x00, 0x74,
+};
+
+static const struct test_data utf16_name_test = {
+ .eir_data = utf16_name_data,
+ .eir_size = sizeof(utf16_name_data),
+ .name = "",
+ .name_complete = true,
+ .tx_power = 127,
+};
+
+static const unsigned char iso_2022_jp_name_data[] = {
+ 0x13, 0x09, 0x74, 0x65, 0x73, 0x74, 0x20, 0x1B,
+ 0x24, 0x42, 0xbb, 0xfa, 0xb8, 0xb5, 0x1b, 0x28,
+ 0x42, 0x20, 0x4f, 0x4b,
+};
+
+static const struct test_data iso_2022_jp_name_test = {
+ .eir_data = iso_2022_jp_name_data,
+ .eir_size = sizeof(iso_2022_jp_name_data),
+ .name = "test \033$B",
+ .name_complete = true,
+ .tx_power = 127,
+};
+
static const unsigned char bluesc_data[] = {
0x02, 0x01, 0x06, 0x03, 0x02, 0x16, 0x18, 0x12,
0x09, 0x57, 0x61, 0x68, 0x6f, 0x6f, 0x20, 0x42,
@@ -707,6 +751,12 @@ int main(int argc, char *argv[])
tester_add("/eir/sl910", &gigaset_sl910_test, NULL, test_parsing, NULL);
tester_add("/eir/bh907", &nokia_bh907_test, NULL, test_parsing, NULL);
tester_add("/eir/fuelband", &fuelband_test, NULL, test_parsing, NULL);
+ tester_add("/eir/invalid-utf8-name", &invalid_utf8_name_test, NULL,
+ test_parsing, NULL);
+ tester_add("/eir/utf16-name", &utf16_name_test, NULL, test_parsing,
+ NULL);
+ tester_add("/eir/iso-2022-jp-name", &iso_2022_jp_name_test, NULL,
+ test_parsing, NULL);
tester_add("/ad/bluesc", &bluesc_test, NULL, test_parsing, NULL);
tester_add("/ad/wahooscale", &wahoo_scale_test, NULL, test_parsing,
NULL);
--
2.43.0
next prev parent reply other threads:[~2025-07-08 15:43 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-08 15:43 [PATCH BlueZ v3 0/7] audio/avrcp: Fix crash with invalid UTF-8 item name Frédéric Danis
2025-07-08 15:43 ` [PATCH BlueZ v3 1/7] shared/util: Add strtoutf8 function Frédéric Danis
2025-07-08 17:06 ` audio/avrcp: Fix crash with invalid UTF-8 item name bluez.test.bot
2025-07-08 15:43 ` [PATCH BlueZ v3 2/7] " Frédéric Danis
2025-07-08 15:43 ` [PATCH BlueZ v3 3/7] audio/mcp: Use strtoutf8 for player name and track title Frédéric Danis
2025-07-08 15:43 ` [PATCH BlueZ v3 4/7] audio/gap: Use strtoutf8 for GAP device name Frédéric Danis
2025-07-08 15:43 ` [PATCH BlueZ v3 5/7] eir: Use strtoutf8 for device names Frédéric Danis
2025-07-08 15:43 ` [PATCH BlueZ v3 6/7] shared/ad: Use strtoutf8 for name Frédéric Danis
2025-07-08 17:12 ` Pauli Virtanen
2025-07-08 17:16 ` Pauli Virtanen
2025-07-08 17:19 ` Luiz Augusto von Dentz
2025-07-08 15:43 ` Frédéric Danis [this message]
2025-07-08 16:30 ` [PATCH BlueZ v3 0/7] audio/avrcp: Fix crash with invalid UTF-8 item name patchwork-bot+bluetooth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250708154308.238963-8-frederic.danis@collabora.com \
--to=frederic.danis@collabora.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox