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

mp: updated the format check to accept the new format released with 2.1 #7287

Merged
merged 1 commit into from
May 2, 2023
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
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