Skip to content

Commit

Permalink
parser: initialize decoders with NULL to avoid SIGSEGV
Browse files Browse the repository at this point in the history
When Fluent Bit encounters with a partial parser definition, it
crashes badly with a segmentation fault.

    $ ./bin/fluent-bit -R parser.conf -c tail.conf
    ...
    [2020/01/15 16:11:21] [error] [parser] no parser 'format' found for 'simple' in file 'conf/timestamp.parser'
    [engine] caught signal (SIGSEGV)
    #0  0x558bc4a0a226      in  flb_parser_decoder_list_destroy() at src/flb_parser_decoder.c:700
    #1  0x558bc4a05d75      in  flb_parser_conf_file() at src/flb_parser.c:566
    #2  0x558bc49f4bdd      in  flb_config_set_property() at src/flb_config.c:406
    #3  0x558bc49e24ae      in  flb_service_conf() at src/fluent-bit.c:446
    #4  0x558bc49e2f90      in  main() at src/fluent-bit.c:807
    #5  0x7fa1cb7f109a      in  ???() at ???:0
    #6  0x558bc49e13a9      in  ???() at ???:0
    #7  0xffffffffffffffff  in  ???() at ???:0
    Aborted

This is just because `decoders` is not being initialized properly,
and that confuses Fluent Bit to deallocate a random memmory block
on the cleanup path. Fix it.

Signed-off-by: Fujimoto Seiji <[email protected]>
  • Loading branch information
Fujimoto Seiji authored and edsiper committed Jan 17, 2020
1 parent 22546d3 commit 7d058ce
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/flb_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ int flb_parser_conf_file(const char *file, struct flb_config *config)
struct mk_list *head;
struct stat st;
struct flb_parser_types *types = NULL;
struct mk_list *decoders;
struct mk_list *decoders = NULL;

#ifndef FLB_HAVE_STATIC_CONF
ret = stat(file, &st);
Expand Down

0 comments on commit 7d058ce

Please sign in to comment.