Skip to content

Commit c2c33b3

Browse files
nokute78edsiper
authored andcommitted
filter_record_modifier: set the limit of bool_map
Signed-off-by: Takahiro Yamashita <[email protected]>
1 parent 425d247 commit c2c33b3

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

plugins/filter_record_modifier/filter_modifier.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ static int make_bool_map(struct record_modifier_ctx *ctx, msgpack_object *map,
249249
return ret;
250250
}
251251

252+
#define BOOL_MAP_LIMIT 65535
252253
static int cb_modifier_filter(const void *data, size_t bytes,
253254
const char *tag, int tag_len,
254255
void **out_buf, size_t *out_size,
@@ -298,6 +299,11 @@ static int cb_modifier_filter(const void *data, size_t bytes,
298299
/* grep keys */
299300
if (obj->type == MSGPACK_OBJECT_MAP) {
300301
map_num = obj->via.map.size;
302+
if (map_num > BOOL_MAP_LIMIT) {
303+
flb_plg_error(ctx->ins, "The number of elements exceeds limit %d",
304+
BOOL_MAP_LIMIT);
305+
return -1;
306+
}
301307
/* allocate map_num + guard byte */
302308
bool_map = flb_calloc(map_num+1, sizeof(bool_map_t));
303309
if (bool_map == NULL) {

0 commit comments

Comments
 (0)