parser: json: restrict packaging to one record
@@ -36,6 +36,7 @@ int flb_parser_json_do(struct flb_parser *parser,
int ret;
int slen;
int root_type;
+ int records;
double tmfrac = 0;
char *mp_buf = NULL;
char *time_key;
@@ -57,11 +58,17 @@ int flb_parser_json_do(struct flb_parser *parser,
struct flb_time *t;
/* Convert incoming in_buf JSON message to message pack format */
- ret = flb_pack_json(in_buf, in_size, &mp_buf, &mp_size, &root_type);
+ ret = flb_pack_json_recs(in_buf, in_size, &mp_buf, &mp_size, &root_type,
+ &records);
if (ret != 0) {
return -1;
}
+ if (records != 1) {
+ flb_free(mp_buf);
+ return -1;
+ }
+
/* Make sure object is a map */
msgpack_unpacked_init(&result);
if (msgpack_unpack_next(&result, mp_buf, mp_size, &off) == MSGPACK_UNPACK_SUCCESS) {
