Skip to content

Commit

Permalink
parser: validate buffer reallocation
Browse files Browse the repository at this point in the history
Signed-off-by: Eduardo Silva <[email protected]>
  • Loading branch information
edsiper committed Jun 8, 2018
1 parent 0509015 commit cf10af5
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/flb_parser_decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -519,15 +519,18 @@ int flb_parser_decoder_do(struct mk_list *decoders,
* We got a match: 'key name' == 'decoder field name', validate
* that we have enough space in our temporal buffer.
*/
if (flb_sds_alloc(dec->buffer) < v.via.str.size) {
if (flb_sds_alloc(dec->buffer) < flb_sds_alloc(data_sds)) {
/* Increase buffer size */
size_t diff = (v.via.str.size - flb_sds_alloc(dec->buffer));
size_t diff;
diff = (flb_sds_alloc(data_sds) - flb_sds_alloc(dec->buffer));
tmp_sds = flb_sds_increase(dec->buffer, diff);
if (!tmp_sds) {
flb_errno();
break;
}
dec->buffer = tmp_sds;
if (tmp_sds != dec->buffer) {
dec->buffer = tmp_sds;
}
}

/* Process decoder rules */
Expand Down

0 comments on commit cf10af5

Please sign in to comment.