summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2017-05-31 18:07:33 +0200
committerLubomir Rintel <lkundrak@v3.sk>2017-06-01 13:30:21 +0200
commitc0419257e70cc64c889a9a906445a74efb92dc44 (patch)
tree79fdb9218da448120414adf6084310ba16d29ec5
parent484d666485f481ea3fce447bfeec0b32a3b4f793 (diff)
downloadNetworkManager-c0419257e70cc64c889a9a906445a74efb92dc44.tar.gz
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
-rw-r--r--libnm-core/nm-utils.c6
-rw-r--r--src/devices/team/nm-device-team.c2
2 files changed, 4 insertions, 4 deletions
diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c
index dedad241ad..8f08c1b566 100644
--- a/libnm-core/nm-utils.c
+++ b/libnm-core/nm-utils.c
@@ -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;
diff --git a/src/devices/team/nm-device-team.c b/src/devices/team/nm-device-team.c
index 1c4d2ef6d2..c457e91242 100644
--- a/src/devices/team/nm-device-team.c
+++ b/src/devices/team/nm-device-team.c
@@ -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");