mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-10-15 12:34:55 +00:00
all: reject duplicate keys in JSON
Teamd is not happy about them and would fail anyway. Worse even, if we json_loads() such a JSON, which is precisely what happens when we inject the "hwaddr" key, we turn bad JSON into a good one in a lossy matter. Not good. https://bugzilla.redhat.com/show_bug.cgi?id=1455130
This commit is contained in:
parent
484d666485
commit
c0419257e7
|
@ -4317,7 +4317,7 @@ nm_utils_is_json_object (const char *str, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
json = json_loads (str, 0, &jerror);
|
||||
json = json_loads (str, JSON_REJECT_DUPLICATES, &jerror);
|
||||
if (!json) {
|
||||
g_set_error (error,
|
||||
NM_CONNECTION_ERROR,
|
||||
|
@ -4369,9 +4369,9 @@ _nm_utils_team_config_equal (const char *conf1,
|
|||
return TRUE;
|
||||
|
||||
/* A NULL configuration is equivalent to default value '{}' */
|
||||
json1 = json_loads (conf1 ?: "{}", 0, &jerror);
|
||||
json1 = json_loads (conf1 ?: "{}", JSON_REJECT_DUPLICATES, &jerror);
|
||||
if (json1)
|
||||
json2 = json_loads (conf2 ?: "{}", 0, &jerror);
|
||||
json2 = json_loads (conf2 ?: "{}", JSON_REJECT_DUPLICATES, &jerror);
|
||||
|
||||
if (!json1 || !json2) {
|
||||
ret = FALSE;
|
||||
|
|
|
@ -568,7 +568,7 @@ teamd_start (NMDevice *device, NMConnection *connection)
|
|||
/* Inject the hwaddr property into the JSON configuration.
|
||||
* While doing so, detect potential conflicts */
|
||||
|
||||
json = json_loads (config ?: "{}", 0, &jerror);
|
||||
json = json_loads (config ?: "{}", JSON_REJECT_DUPLICATES, &jerror);
|
||||
g_return_val_if_fail (json, FALSE);
|
||||
|
||||
hwaddr = json_object_get (json, "hwaddr");
|
||||
|
|
Loading…
Reference in a new issue