@@ -206,7 +206,7 @@ static int settings_zms_load_one(struct settings_store *cs, const char *name, ch
206206 size_t buf_len )
207207{
208208 struct settings_zms * cf = CONTAINER_OF (cs , struct settings_zms , cf_store );
209- char r_name [SETTINGS_MAX_NAME_LEN + SETTINGS_EXTRA_LEN + 1 ];
209+ char r_name [SETTINGS_FULL_NAME_LEN ];
210210 ssize_t rc = 0 ;
211211 uint32_t name_hash ;
212212
@@ -215,7 +215,7 @@ static int settings_zms_load_one(struct settings_store *cs, const char *name, ch
215215 return - EINVAL ;
216216 }
217217
218- name_hash = sys_hash32 (name , strlen (name )) & ZMS_HASH_MASK ;
218+ name_hash = sys_hash32 (name , strnlen (name , SETTINGS_FULL_NAME_LEN )) & ZMS_HASH_MASK ;
219219 for (int i = 0 ; i <= cf -> hash_collision_num ; i ++ ) {
220220 name_hash = ZMS_UPDATE_COLLISION_NUM (name_hash , i );
221221 /* Get the name entry from ZMS */
@@ -247,15 +247,17 @@ static int settings_zms_load(struct settings_store *cs, const struct settings_lo
247247 struct settings_zms * cf = CONTAINER_OF (cs , struct settings_zms , cf_store );
248248 struct settings_zms_read_fn_arg read_fn_arg ;
249249 struct settings_hash_linked_list settings_element ;
250- char name [SETTINGS_MAX_NAME_LEN + SETTINGS_EXTRA_LEN + 1 ];
250+ char name [SETTINGS_FULL_NAME_LEN ];
251251 ssize_t rc1 ;
252252 ssize_t rc2 ;
253253 uint32_t ll_hash_id ;
254254 uint32_t name_hash ;
255255
256256 /* If arg->subtree is not null we must load settings in that subtree */
257257 if (arg -> subtree != NULL ) {
258- name_hash = sys_hash32 (arg -> subtree , strlen (arg -> subtree )) & ZMS_HASH_MASK ;
258+ name_hash =
259+ sys_hash32 (arg -> subtree , strnlen (arg -> subtree , SETTINGS_FULL_NAME_LEN )) &
260+ ZMS_HASH_MASK ;
259261 for (int i = 0 ; i <= cf -> hash_collision_num ; i ++ ) {
260262 name_hash = ZMS_UPDATE_COLLISION_NUM (name_hash , i );
261263 /* Get the name entry from ZMS */
@@ -418,7 +420,7 @@ static int settings_zms_save(struct settings_store *cs, const char *name, const
418420 /* Find out if we are doing a delete */
419421 delete = ((value == NULL ) || (val_len == 0 ));
420422
421- name_hash = sys_hash32 (name , strlen (name )) & ZMS_HASH_MASK ;
423+ name_hash = sys_hash32 (name , strnlen (name , SETTINGS_FULL_NAME_LEN )) & ZMS_HASH_MASK ;
422424 /* MSB is always 1 */
423425 name_hash |= BIT (31 );
424426
@@ -571,7 +573,7 @@ static int settings_zms_save(struct settings_store *cs, const char *name, const
571573no_ll_update :
572574#endif /* CONFIG_SETTINGS_ZMS_NO_LL_DELETE */
573575 /* Now let's write the name */
574- rc = zms_write (& cf -> cf_zms , name_hash , name , strlen (name ));
576+ rc = zms_write (& cf -> cf_zms , name_hash , name , strnlen (name , SETTINGS_FULL_NAME_LEN ));
575577 if (rc < 0 ) {
576578 return rc ;
577579 }
0 commit comments