From b21c0b91f84a9992a5e46b2222ba7fe00359904b Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Thu, 8 Oct 2026 19:42:45 -0500 Subject: [PATCH] Update: Ensure f_fll_id_t.name is always NULL terminated. Set the normal length of `f_fll_id_name_length_d` to 63. Then have the actual max length remain at 64 via newly added `f_fll_id_name_max_length_d`. The `f_fll_id_name_length_d` is only used for comparisons now. The `f_fll_id_name_max_length_d` is used on the structure. This should prevent **API** and **ABI** breakage. Add missing close parenthesis in documentation comment. --- level_0/f_type/c/type.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/level_0/f_type/c/type.h b/level_0/f_type/c/type.h index 0a48b716a..64b6ab401 100644 --- a/level_0/f_type/c/type.h +++ b/level_0/f_type/c/type.h @@ -1154,12 +1154,12 @@ extern "C" { * This was originally designed for FSS (Featureless Settings Specification) but has been expanded to be used by the entire project. * * An FLL Identifier consists of two parts: - * 1) A 64-byte long string representing a machine-name for the type. + * 1) A 64-byte long string representing a machine-name for the type where the last byte (the 64th byte) must always be NULL. * 2) A 16-bit digit representing 2^16 possible type classifications, which is representeed by 4 hexadecial 1-byte strings for text. * * For example "fss-1234" is a valid type such that: * 1) name: "fss". - * 2) type: "1234", (or 0x1 in binary. + * 2) type: "1234", (or 0x1 in binary). * * UTF-8 codes are available, but one must consider that 1 4-byte characte still takes up 4-bytes. * Therefore for all 4-byte UTF-8 characters, there is a maximum of 16 characters available. @@ -1171,16 +1171,20 @@ extern "C" { * For a more accurate clear, use memset() or something similar. * * The name must only be "word" characters (therefore "-" is not allowed). + * The f_fll_id_name_length_d defines the length of non-NULL characters and the f_fll_id_name_max_length_d must always be 1 byte longer than f_fll_id_name_length_d. + * This allows for the f_fll_id_t.name to be guaranteed to always be a NULL terminated when properly managed. + * * * name: The string representing the name of the FLL Identifier (This is not a NULL terminated string). * type: The code representing the type of the Identifier. * used: A representation of how many bytes in name are in used (if 0, then there is no name, thus this can be seen as not a valid identifier). */ #ifndef _di_f_fll_id_t_ - #define f_fll_id_name_length_d 64 + #define f_fll_id_name_length_d 63 + #define f_fll_id_name_max_length_d (f_fll_id_name_length_d + 1) typedef struct { - char name[f_fll_id_name_length_d]; + char name[f_fll_id_name_max_length_d]; uint16_t type; uint8_t used; -- 2.52.0