Skip to content

Commit

Permalink
filter_kubernetes: fix index adjustment and validate object type (#611)
Browse files Browse the repository at this point in the history
Signed-off-by: Eduardo Silva <[email protected]>
  • Loading branch information
edsiper committed Jun 15, 2018
1 parent d3bf2c2 commit 85a5c6e
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions plugins/filter_kubernetes/kubernetes.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ static int merge_log_handler(msgpack_object o,
for (i = size - 1; i > 0; i--) {
if (o.via.str.ptr[i] == '\n') {
size -= 1;
i--;
continue;
}

Expand Down Expand Up @@ -189,7 +188,7 @@ static int pack_map_content(msgpack_packer *pck, msgpack_sbuffer *sbuf,
struct flb_kube *ctx)
{
int i;
int map_size;
int map_size = 0;
int merge_status = -1;
int new_map_size = 0;
int log_index = -1;
Expand Down Expand Up @@ -241,9 +240,6 @@ static int pack_map_content(msgpack_packer *pck, msgpack_sbuffer *sbuf,
merge_status = MERGE_BINARY;
}
}
else {

}

/* Determinate the size of the new map */
new_map_size = map_size;
Expand All @@ -255,7 +251,9 @@ static int pack_map_content(msgpack_packer *pck, msgpack_sbuffer *sbuf,
msgpack_unpacked_init(&result);
msgpack_unpack_next(&result, log_buf, log_size, &off);
root = result.data;
log_buf_entries = root.via.map.size;
if (root.type == MSGPACK_OBJECT_MAP) {
log_buf_entries = root.via.map.size;
}
msgpack_unpacked_destroy(&result);
}
else if (merge_status == MERGE_BINARY) {
Expand All @@ -277,6 +275,7 @@ static int pack_map_content(msgpack_packer *pck, msgpack_sbuffer *sbuf,
else {
new_map_size += log_buf_entries;
}

msgpack_pack_map(pck, new_map_size);

/* Original map */
Expand Down

0 comments on commit 85a5c6e

Please sign in to comment.