Skip to content

Commit 0f6ed66

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 6401faf commit 0f6ed66

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
@@ -1133,6 +1133,18 @@ int net_config_get(struct net_init_config *cfg)
11331133
settings_loaded = true;
11341134
}
11351135

1136+
/* Verify that the yaml schema file is not changed between what is in
1137+
* use and what was used when the user modified the configuration.
1138+
*/
1139+
if (net_init_config_user.config_format_hash != NULL &&
1140+
strncmp(config->config_format_hash,
1141+
net_init_config_user.config_format_hash,
1142+
sizeof(config->config_format_hash) - 1) != 0) {
1143+
NET_ERR("User network configuration format hash mismatch");
1144+
settings_loaded = false;
1145+
return -EINVAL;
1146+
}
1147+
11361148
/* Make a union of the default config and the user modified one and
11371149
* return results in cfg pointer.
11381150
*/

0 commit comments

Comments
 (0)