Skip to content
Open
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
33 changes: 33 additions & 0 deletions logsrvd/logsrvd_local.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,33 @@ struct logsrvd_info_closure {
size_t infolen;
};

/*
* Keys that format_json() writes itself for accept and reject events.
* These must not be overridden by the client.
*/
static const char *reserved_json_keys[] = {
"iolog_offset",
"iolog_path",
"peeraddr",
"reason",
"server_time",
"submit_time",
"uuid",
NULL
};

static bool
reserved_json_key(const char *key)
{
const char **kp;

for (kp = reserved_json_keys; *kp != NULL; kp++) {
if (strcmp(key, *kp) == 0)
return true;
}
return false;
}

static bool
logsrvd_json_log_cb(struct json_container *jsonc, void *v)
{
Expand All @@ -75,6 +102,12 @@ logsrvd_json_log_cb(struct json_container *jsonc, void *v)
for (idx = 0; idx < closure->infolen; idx++) {
InfoMessage *info = closure->info_msgs[idx];

if (reserved_json_key(info->key)) {
sudo_warnx(U_("%s: protocol error: reserved key %s"),
"local", info->key);
continue;
}

switch (info->value_case) {
case INFO_MESSAGE__VALUE_NUMVAL:
json_value.type = JSON_NUMBER;
Expand Down
Loading