Skip to content

Commit 538669e

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 5de847f commit 538669e

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

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

0 commit comments

Comments
 (0)