Skip to content

Commit

Permalink
Fixes CN crash when ref attribute is null
Browse files Browse the repository at this point in the history
Added check for attr "null" and handle it gracefully by forcing it to
be an empty set {}
Modified existing test data to test this case.
Closes-bug: 1713407

Change-Id: I035729e2dc0e8d403c55ffc032d6c49001a68e5f
  • Loading branch information
psdsouza committed Sep 23, 2017
1 parent b678822 commit 8b25b80
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/config/config-client-mgr/config_cass2json_adapter.cc
Expand Up @@ -159,7 +159,12 @@ void ConfigCass2JsonAdapter::AddOneEntry(Value *jsonObject,
IsLinkWithAttr(obj_type, ref_type);
if (link_with_attr) {
Document ref_document(&a);
ref_document.Parse<0>(c.value.c_str());
string c_value = c.value;
c_value.erase(remove(c_value.begin(), c_value.end(), ' '),
c_value.end());
if (c_value == "{\"attr\":null}")
c_value = "{\"attr\":{}}";
ref_document.Parse<0>(c_value.c_str());
CONFIG_PARSE_ASSERT(ReferenceLinkAttributes,
!ref_document.HasParseError());
CONFIG_PARSE_ASSERT(ReferenceLinkAttributes,
Expand Down
2 changes: 1 addition & 1 deletion src/ifmap/testdata/cli1_vn2_np1_add.json
Expand Up @@ -295,7 +295,7 @@
"d0116475-a0a8-472d-9743-314d0e94c9e9": {
"fq_name": "[\"default-domain\",\"demo\",\"vn27-1\"]",
"type": "\"virtual_network\"",
"ref:network_policy:7367cbbc-8036-445d-9f7c-4190c91cdf5d": "{\"attr\":{\"major\":\"0\",\"minor\":\"0\"}}",
"ref:network_policy:7367cbbc-8036-445d-9f7c-4190c91cdf5d": "{\"attr\": null}",
"ref:network_ipam:9963c319-fadd-4b8d-b3f8-7160e682e2f6": "{\"attr\":{\"ipam_subnets\":[{\"subnet\":{\"ip_prefix\":\"27.1.1.0\",\"ip_prefix_len\":\"24\"},\"default_gateway\":\"27.1.1.254\"}]}}",
"prop:id_perms": "{\"permissions\":{\"owner\":\"cloud-admin\",\"owner_access\":\"7\",\"group\":\"cloud-admin-group\",\"group_access\":\"7\",\"other_access\":\"7\"},\"uuid\":{\"uuid_mslong\":\"14992875090862425901\",\"uuid_lslong\":\"10899609730193607145\"},\"enable\":\"true\"}",
"parent:project:ee523edc-e957-41ab-b7b0-2d557e9573ff": "null"
Expand Down

0 comments on commit 8b25b80

Please sign in to comment.