From d1bf2c0d13028e1fdf0cbc92a0bf353bc1f1f1c9 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Mon, 23 Nov 2020 14:06:19 +0000 Subject: [PATCH] dynsec: Fix missing correlationData for getDefaultACLAccess. --- plugins/dynamic-security/clients.c | 6 ++---- plugins/dynamic-security/groups.c | 13 +++++-------- plugins/dynamic-security/plugin.c | 9 +++++++++ plugins/dynamic-security/roles.c | 6 ++---- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/plugins/dynamic-security/clients.c b/plugins/dynamic-security/clients.c index 14936bf4..a6e62b05 100644 --- a/plugins/dynamic-security/clients.c +++ b/plugins/dynamic-security/clients.c @@ -889,13 +889,12 @@ int dynsec_clients__process_get(cJSON *j_responses, struct mosquitto *context, c cJSON_AddItemToObject(j_data, "client", j_client); if(correlation_data){ - jtmp = cJSON_CreateString(correlation_data); + jtmp = cJSON_AddStringToObject(tree, "correlationData", correlation_data); if(jtmp == NULL){ cJSON_Delete(tree); dynsec__command_reply(j_responses, context, "getClient", "Internal error", correlation_data); return 1; } - cJSON_AddItemToObject(tree, "correlationData", jtmp); } cJSON_AddItemToArray(j_responses, tree); @@ -968,13 +967,12 @@ int dynsec_clients__process_list(cJSON *j_responses, struct mosquitto *context, i++; } if(correlation_data){ - jtmp = cJSON_CreateString(correlation_data); + jtmp = cJSON_AddStringToObject(tree, "correlationData", correlation_data); if(jtmp == NULL){ cJSON_Delete(tree); dynsec__command_reply(j_responses, context, "listClients", "Internal error", correlation_data); return 1; } - cJSON_AddItemToObject(tree, "correlationData", jtmp); } cJSON_AddItemToArray(j_responses, tree); diff --git a/plugins/dynamic-security/groups.c b/plugins/dynamic-security/groups.c index 591c92a0..6e2a8bf6 100644 --- a/plugins/dynamic-security/groups.c +++ b/plugins/dynamic-security/groups.c @@ -731,13 +731,12 @@ int dynsec_groups__process_list(cJSON *j_responses, struct mosquitto *context, c i++; } if(correlation_data){ - jtmp = cJSON_CreateString(correlation_data); + jtmp = cJSON_AddStringToObject(tree, "correlationData", correlation_data); if(jtmp == NULL){ cJSON_Delete(tree); dynsec__command_reply(j_responses, context, "listGroups", "Internal error", correlation_data); return 1; } - cJSON_AddItemToObject(tree, "correlationData", jtmp); } cJSON_AddItemToArray(j_responses, tree); @@ -794,13 +793,12 @@ int dynsec_groups__process_get(cJSON *j_responses, struct mosquitto *context, cJ cJSON_AddItemToObject(j_data, "group", j_group); } if(correlation_data){ - jtmp = cJSON_CreateString(correlation_data); + jtmp = cJSON_AddStringToObject(tree, "correlationData", correlation_data); if(jtmp == NULL){ - dynsec__command_reply(j_responses, context, "getGroup", "Internal error", correlation_data); cJSON_Delete(tree); + dynsec__command_reply(j_responses, context, "getGroup", "Internal error", correlation_data); return 1; } - cJSON_AddItemToObject(tree, "correlationData", jtmp); } cJSON_AddItemToArray(j_responses, tree); @@ -1031,13 +1029,12 @@ int dynsec_groups__process_get_anonymous_group(cJSON *j_responses, struct mosqui } } if(correlation_data){ - jtmp = cJSON_CreateString(correlation_data); + jtmp = cJSON_AddStringToObject(tree, "correlationData", correlation_data); if(jtmp == NULL){ - dynsec__command_reply(j_responses, context, "getGroup", "Internal error", correlation_data); cJSON_Delete(tree); + dynsec__command_reply(j_responses, context, "getGroup", "Internal error", correlation_data); return 1; } - cJSON_AddItemToObject(tree, "correlationData", jtmp); } cJSON_AddItemToArray(j_responses, tree); diff --git a/plugins/dynamic-security/plugin.c b/plugins/dynamic-security/plugin.c index 264fef35..82b8f2f0 100644 --- a/plugins/dynamic-security/plugin.c +++ b/plugins/dynamic-security/plugin.c @@ -256,6 +256,15 @@ int dynsec__process_get_default_acl_access(cJSON *j_responses, struct mosquitto cJSON_AddItemToArray(j_responses, tree); + if(correlation_data){ + jtmp = cJSON_AddStringToObject(tree, "correlationData", correlation_data); + if(jtmp == NULL){ + cJSON_Delete(tree); + dynsec__command_reply(j_responses, context, "getDefaultACLAccess", "Internal error", correlation_data); + return 1; + } + } + return MOSQ_ERR_SUCCESS; } diff --git a/plugins/dynamic-security/roles.c b/plugins/dynamic-security/roles.c index 6bd120cd..05fa104a 100644 --- a/plugins/dynamic-security/roles.c +++ b/plugins/dynamic-security/roles.c @@ -579,13 +579,12 @@ int dynsec_roles__process_list(cJSON *j_responses, struct mosquitto *context, cJ i++; } if(correlation_data){ - jtmp = cJSON_CreateString(correlation_data); + jtmp = cJSON_AddStringToObject(tree, "correlationData", correlation_data); if(jtmp == NULL){ cJSON_Delete(tree); dynsec__command_reply(j_responses, context, "listRoles", "Internal error", correlation_data); return 1; } - cJSON_AddItemToObject(tree, "correlationData", jtmp); } cJSON_AddItemToArray(j_responses, tree); @@ -813,13 +812,12 @@ int dynsec_roles__process_get(cJSON *j_responses, struct mosquitto *context, cJS cJSON_AddItemToObject(j_data, "role", j_role); if(correlation_data){ - jtmp = cJSON_CreateString(correlation_data); + jtmp = cJSON_AddStringToObject(tree, "correlationData", correlation_data); if(jtmp == NULL){ cJSON_Delete(tree); dynsec__command_reply(j_responses, context, "getRole", "Internal error", correlation_data); return 1; } - cJSON_AddItemToObject(tree, "correlationData", jtmp); } cJSON_AddItemToArray(j_responses, tree);