Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow UpdateConfiguration IPC KeyPaths of length zero; Disallow updates to component accessControl #782

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 33 additions & 12 deletions ggipcd/src/services/config/update_configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <ggl/object.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stddef.h>

GglError ggl_handle_update_configuration(
const GglIpcOperationInfo *info,
Expand All @@ -27,13 +28,13 @@ GglError ggl_handle_update_configuration(
(void) info;
(void) alloc;

GglObject *key_path_obj;
GglObject *key_path_obj = NULL;
GglObject *value_to_merge_obj;
GglObject *timestamp_obj;
GglError ret = ggl_map_validate(
args,
GGL_MAP_SCHEMA(
{ GGL_STR("keyPath"), true, GGL_TYPE_LIST, &key_path_obj },
{ GGL_STR("keyPath"), false, GGL_TYPE_LIST, &key_path_obj },
{ GGL_STR("valueToMerge"),
true,
GGL_TYPE_NULL,
Expand All @@ -46,18 +47,38 @@ GglError ggl_handle_update_configuration(
return GGL_ERR_INVALID;
}

ret = ggl_list_type_check(key_path_obj->list, GGL_TYPE_BUF);
if (ret != GGL_ERR_OK) {
GGL_LOGE("Received invalid paramters.");
return GGL_ERR_INVALID;
GglObject *empty_list = (GglObject *) &GGL_OBJ_LIST({ 0 });
if (key_path_obj == NULL) {
key_path_obj = empty_list;
} else {
ret = ggl_list_type_check(key_path_obj->list, GGL_TYPE_BUF);
if (ret != GGL_ERR_OK) {
GGL_LOGE("Received invalid paramters.");
return GGL_ERR_INVALID;
}

if ((key_path_obj->list.len >= 1)
&& ggl_buffer_eq(
key_path_obj->list.items[0].buf, GGL_STR("accessControl")
)) {
GGL_LOGE("Received invalid paramters. Can not change component "
"accessControl over IPC.");
return GGL_ERR_INVALID;
}
}

if ((key_path_obj->list.len < 1)
|| ggl_buffer_eq(
key_path_obj->list.items[0].buf, GGL_STR("accessControl")
)) {
GGL_LOGE("Received invalid paramters.");
return GGL_ERR_INVALID;
if ((key_path_obj->list.len == 0)
&& value_to_merge_obj->type == GGL_TYPE_MAP) {
for (size_t i = 0; i < value_to_merge_obj->map.len; i++) {
if (ggl_buffer_eq(
value_to_merge_obj->map.pairs[i].key,
GGL_STR("accessControl")
)) {
GGL_LOGE("Received invalid paramters. Can not change component "
"accessControl over IPC.");
return GGL_ERR_INVALID;
}
}
}

GglBuffer component_name = { 0 };
Expand Down
Loading