Skip to content

Commit

Permalink
mp: updated the format check to accept the new format released with 2.1
Browse files Browse the repository at this point in the history
Signed-off-by: Leonardo Alminana <[email protected]>
  • Loading branch information
leonardo-albertovich authored and edsiper committed May 2, 2023
1 parent bdcaec2 commit 17cdf9f
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/flb_mp.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ int flb_mp_validate_log_chunk(const void *data, size_t bytes,
unsigned char *ptr;
msgpack_object array;
msgpack_object ts;
msgpack_object header;
msgpack_object record;
msgpack_object metadata;
msgpack_unpacked result;

msgpack_unpacked_init(&result);
Expand Down Expand Up @@ -162,9 +164,25 @@ int flb_mp_validate_log_chunk(const void *data, size_t bytes,
goto error;
}

ts = array.via.array.ptr[0];
header = array.via.array.ptr[0];
record = array.via.array.ptr[1];

if (header.type == MSGPACK_OBJECT_ARRAY) {
if (header.via.array.size != 2) {
goto error;
}

ts = header.via.array.ptr[0];
metadata = header.via.array.ptr[1];

if (metadata.type != MSGPACK_OBJECT_MAP) {
goto error;
}
}
else {
ts = header;
}

if (ts.type != MSGPACK_OBJECT_POSITIVE_INTEGER &&
ts.type != MSGPACK_OBJECT_FLOAT &&
ts.type != MSGPACK_OBJECT_EXT) {
Expand Down

0 comments on commit 17cdf9f

Please sign in to comment.