Skip to content

Commit f5dd020

Browse files
committed
net: config: Verify that the config format hash is not changed
The hash is used to detect whether the yaml schema file is changed. If the data format in the settings is different that what is found in the ROM, then the settings db must be discarded because the data is now incompatible. Signed-off-by: Jukka Rissanen <[email protected]>
1 parent 47ee136 commit f5dd020

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

subsys/net/lib/config/init.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,6 +1075,18 @@ int net_config_get(struct net_init_config *cfg)
10751075
settings_loaded = true;
10761076
}
10771077

1078+
/* Verify that the yaml schema file is not changed between what is in
1079+
* use and what was used when the user modified the configuration.
1080+
*/
1081+
if (net_init_config_user.config_format_hash != NULL &&
1082+
strncmp(config->config_format_hash,
1083+
net_init_config_user.config_format_hash,
1084+
sizeof(config->config_format_hash) - 1) != 0) {
1085+
NET_ERR("User network configuration format hash mismatch");
1086+
settings_loaded = false;
1087+
return -EINVAL;
1088+
}
1089+
10781090
/* Make a union of the default config and the user modified one and
10791091
* return results in cfg pointer.
10801092
*/

0 commit comments

Comments
 (0)