Skip to contentSkip to conversation

unicode: constify utf8 data table

PATCH Applied Thomas Weißschuh 3 participants 3 messages Aug 9, 2024 – Aug 13, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 unicode: constify utf8 data table

All users already handle the table as const data.
Move the table itself into .rodata to guard against accidental or malicious modifications.

---
 fs/unicode/mkutf8data.c       | 2 +-
 fs/unicode/utf8data.c_shipped | 2 +-
 fs/unicode/utf8n.h            | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
fs/unicode/mkutf8data.c +1 -1
index 77b685db8275..57e0e290ce6f 100644
@@ -3338,7 +3338,7 @@ static void write_file(void)
 	}
 	fprintf(file, "};\n");
 	fprintf(file, "\n");
-	fprintf(file, "struct utf8data_table utf8_data_table = {\n");
+	fprintf(file, "const struct utf8data_table utf8_data_table = {\n");
 	fprintf(file, "\t.utf8agetab = utf8agetab,\n");
 	fprintf(file, "\t.utf8agetab_size = ARRAY_SIZE(utf8agetab),\n");
 	fprintf(file, "\n");
fs/unicode/utf8data.c_shipped +1 -1
index dafa5fed761d..73a93d49b3ba 100644
@@ -4107,7 +4107,7 @@ static const unsigned char utf8data[64256] = {
 	0x81,0x80,0xcf,0x86,0x85,0x84,0xcf,0x86,0xcf,0x06,0x02,0x00,0x00,0x00,0x00,0x00
 };
 
-struct utf8data_table utf8_data_table = {
+const struct utf8data_table utf8_data_table = {
 	.utf8agetab = utf8agetab,
 	.utf8agetab_size = ARRAY_SIZE(utf8agetab),
 
fs/unicode/utf8n.h +1 -1
index bd00d587747a..fc703aa4b28e 100644
@@ -78,6 +78,6 @@ struct utf8data_table {
 	const unsigned char *utf8data;
 };
 
-extern struct utf8data_table utf8_data_table;
+extern const struct utf8data_table utf8_data_table;
 
 #endif /* UTF8NORM_H */

---
base-commit: ee9a43b7cfe2d8a3520335fea7d8ce71b8cabd9d
change-id: 20240809-unicode-const-2cd2295d3df3

Best regards,

Signature · 1 line
Thomas Weißschuh <[email protected]>
#2 lore raw
In reply to Thomas Weißschuh
Quoted 3 lines · Thomas Weißschuh

All users already handle the table as const data.
Move the table itself into .rodata to guard against accidental or malicious modifications.

Applied, thanks!

[1/1] unicode: constify utf8 data table

      commit: 43bf9d9755bd21970d8382dc88f071f74fc18fbf

Best regards,

Signature · 1 line
Gabriel Krisman Bertazi