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

Crash when passing empty json object to filterx for parsing #266

Open
mitzkia opened this issue Aug 31, 2024 · 0 comments
Open

Crash when passing empty json object to filterx for parsing #266

mitzkia opened this issue Aug 31, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@mitzkia
Copy link
Contributor

mitzkia commented Aug 31, 2024

axosyslog version:

(dbld)micek@DESKTOP-0E9OKG3:/install/sbin$ ./syslog-ng -V
axosyslog 4 (4.8.0.217.g17b1fd8)
Config version: 4.2
Installer-Version: 4.8.0.217.g17b1fd8
Revision:
Compile-Date: Aug 26 2024 05:05:23

Reproduction:
Axosyslog got crahsed when started with the following configuration:

@version: 4.2

source genmsg {
    example-msg-generator(
        num(1)
        template("foobar")
        values(
            "values.json" => json(''),
        )
    );
};

destination dest_true {
        file (dest-true.log);
};

log {
    source(genmsg);
    if {
        filterx { 
            $olr = otel_logrecord();
            $olr.body = ${values.json};
            $MSG = format_json($olr.body);  
        };
        destination(dest_true);
    };
};

axosyslog start:

[2024-08-31T06:14:09.547009] syslog-ng starting up; version='4.8.0.217.g17b1fd8'
[2024-08-31T06:14:09.547009] Running application hooks; hook='2'
[2024-08-31T06:14:09.547009] Setting value; name='values.json', value='', type='json', msg='0x563bc7be50d0', rcptid='1199'
[2024-08-31T06:14:09.547009] Setting value; name='MESSAGE', value='-- Generated message. --', type='string', msg='0x563bc7be50d0', rcptid='1199'
[2024-08-31T06:14:09.547009] Setting value; name='MESSAGE', value='foobar', type='string', msg='0x563bc7be50d0', rcptid='1199'
[2024-08-31T06:14:09.547009] Incoming generated message; msg='foobar'
[2024-08-31T06:14:09.547009] >>>>>> Source side message processing begin; location='aaa.conf:5:5', msg='0x563bc7be50d0', rcptid='1199'
[2024-08-31T06:14:09.547009] Setting value; name='HOST_FROM', value='DESKTOP-0E9OKG3', type='string', msg='0x563bc7be50d0', rcptid='1199'
[2024-08-31T06:14:09.547009] Setting value; name='HOST', value='DESKTOP-0E9OKG3', type='string', msg='0x563bc7be50d0', rcptid='1199'
[2024-08-31T06:14:09.547009] Setting tag; name='.source.genmsg', value='1', msg='0x563bc7be50d0'
[2024-08-31T06:14:09.547009] Setting value; name='SOURCE', value='genmsg', type='string', msg='0x563bc7be50d0', rcptid='1199'
[2024-08-31T06:14:09.547009] >>>>>> filterx rule evaluation begin; rule='#anon-filter0', location='aaa.conf:21:16', msg='0x563bc7be50d0', rcptid='1199'
[2024-08-31T06:14:09.547009] FILTERX ESTEP; expr='aaa.conf:22:13|       $olr = otel_logrecord()', value='', truthy='1', type='otel_logrecord'
Segmentation fault

gdb:

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff62cd084 in filterx_object_is_type (object=0x0, type=0x7ffff7fba2e0 <filterx_type_dict>) at /source/lib/filterx/filterx-object.h:106
warning: Source file is more recent than executable.
106       FilterXType *self_type = object->type;
(gdb) bt
#0  0x00007ffff62cd084 in filterx_object_is_type (object=0x0, type=0x7ffff7fba2e0 <filterx_type_dict>) at /source/lib/filterx/filterx-object.h:106
#1  0x00007ffff62ceb3d in syslogng::grpc::otel::filterx::OtelKVListField::FilterXObjectSetter (this=0x7ffff630fb80 <syslogng::grpc::otel::filterx::otel_kvlist_converter>, message=0x555555621d10, reflectors=..., object=0x55555561e780,
    assoc_object=0x7fffffffdde8) at /source/modules/grpc/otel/filterx/object-otel-kvlist.cpp:515
#2  0x00007ffff62ca7bf in syslogng::grpc::otel::ProtobufField::Set (this=0x7ffff630fb80 <syslogng::grpc::otel::filterx::otel_kvlist_converter>, message=0x555555621d10, fieldName="kvlist_value", object=0x55555561e780, assoc_object=0x7fffffffdde8)
    at /source/modules/grpc/otel/filterx/protobuf-field.hpp:93
#3  0x00007ffff62d7166 in syslogng::grpc::otel::AnyField::FilterXObjectDirectSetter (this=0x7ffff630feb0 <syslogng::grpc::otel::any_field_converter>, anyValue=0x555555621d10, object=0x55555561e780, assoc_object=0x7fffffffdde8)
    at /source/modules/grpc/otel/filterx/otel-field.cpp:258
#4  0x00007ffff62d6985 in syslogng::grpc::otel::AnyField::FilterXObjectSetter (this=0x7ffff630feb0 <syslogng::grpc::otel::any_field_converter>, message=0x5555555e9f98, reflectors=..., object=0x55555561e780, assoc_object=0x7fffffffdde8)
    at /source/modules/grpc/otel/filterx/otel-field.cpp:124
#5  0x00007ffff62ca7bf in syslogng::grpc::otel::ProtobufField::Set (this=0x7ffff630feb0 <syslogng::grpc::otel::any_field_converter>, message=0x5555555e9f98, fieldName="body", object=0x55555561e780, assoc_object=0x7fffffffdde8)
    at /source/modules/grpc/otel/filterx/protobuf-field.hpp:93
#6  0x00007ffff62c9489 in syslogng::grpc::otel::filterx::LogRecord::set_subscript (this=0x5555555e9f90, key=0x555555567ed0, value=0x7fffffffdee8) at /source/modules/grpc/otel/filterx/object-otel-logrecord.cpp:85
#7  0x00007ffff62c9853 in _set_subscript (s=0x55555561e720, key=0x555555567ed0, new_value=0x7fffffffdee8) at /source/modules/grpc/otel/filterx/object-otel-logrecord.cpp:184
#8  0x00007ffff7edeec0 in _setattr (s=0x55555561e720, attr=0x555555567ed0, new_value=0x7fffffffdee8) at /source/lib/filterx/object-dict-interface.c:149
#9  0x00007ffff7ed2273 in filterx_object_setattr (self=0x55555561e720, attr=0x555555567ed0, new_value=0x7fffffffdee8) at /source/lib/filterx/filterx-object.h:230
#10 0x00007ffff7ed2413 in _eval (s=0x555555567f00) at /source/lib/filterx/expr-setattr.c:60
#11 0x00007ffff7ee2d1e in filterx_expr_eval (self=0x555555567f00) at /source/lib/filterx/filterx-expr.h:73
#12 0x00007ffff7ee2d49 in _eval_expr (expr=0x555555567f00, result=0x7fffffffdfe0) at /source/lib/filterx/expr-compound.c:43
#13 0x00007ffff7ee3006 in _eval_exprs (self=0x55555556ba90, result=0x7fffffffdfe0) at /source/lib/filterx/expr-compound.c:89
#14 0x00007ffff7ee3060 in _eval (s=0x55555556ba90) at /source/lib/filterx/expr-compound.c:102
#15 0x00007ffff7ed701b in filterx_expr_eval (self=0x55555556ba90) at /source/lib/filterx/filterx-expr.h:73
#16 0x00007ffff7ed7480 in filterx_eval_exec (context=0x7fffffffe0b0, expr=0x55555556ba90, msg=0x55555561e100) at /source/lib/filterx/filterx-eval.c:198
#17 0x00007ffff7edfa3f in log_filterx_pipe_queue (s=0x5555556135e0, msg=0x55555561e100, path_options=0x7fffffffe090) at /source/lib/filterx/filterx-pipe.c:65
#18 0x00007ffff7e685bb in log_pipe_queue (s=0x5555556135e0, msg=0x55555561e100, path_options=0x7fffffffe1f0) at /source/lib/logpipe.h:485
#19 0x00007ffff7e68820 in log_multiplexer_queue (s=0x55555561aec0, msg=0x55555561e100, path_options=0x7fffffffe3c0) at /source/lib/logmpx.c:115
#20 0x00007ffff7e685bb in log_pipe_queue (s=0x55555561aec0, msg=0x55555561e100, path_options=0x7fffffffe3c0) at /source/lib/logpipe.h:485
#21 0x00007ffff7e683f6 in log_pipe_forward_msg (self=0x55555561a260, msg=0x55555561e100, path_options=0x7fffffffe3c0) at /source/lib/logpipe.h:439
#22 0x00007ffff7e685d4 in log_pipe_queue (s=0x55555561a260, msg=0x55555561e100, path_options=0x7fffffffe3c0) at /source/lib/logpipe.h:489
#23 0x00007ffff7e683f6 in log_pipe_forward_msg (self=0x555555619dc0, msg=0x55555561e100, path_options=0x7fffffffe3c0) at /source/lib/logpipe.h:439
#24 0x00007ffff7e685d4 in log_pipe_queue (s=0x555555619dc0, msg=0x55555561e100, path_options=0x7fffffffe3c0) at /source/lib/logpipe.h:489
#25 0x00007ffff7e68820 in log_multiplexer_queue (s=0x555555619f80, msg=0x55555561e100, path_options=0x7fffffffe730) at /source/lib/logmpx.c:115
#26 0x00007ffff7e5f050 in log_pipe_queue (s=0x555555619f80, msg=0x55555561e100, path_options=0x7fffffffe730) at /source/lib/logpipe.h:485
#27 0x00007ffff7e5ee8b in log_pipe_forward_msg (self=0x555555619bf0, msg=0x55555561e100, path_options=0x7fffffffe730) at /source/lib/logpipe.h:439
#28 0x00007ffff7e5f069 in log_pipe_queue (s=0x555555619bf0, msg=0x55555561e100, path_options=0x7fffffffe730) at /source/lib/logpipe.h:489
#29 0x00007ffff7e5ee8b in log_pipe_forward_msg (self=0x555555619aa0, msg=0x55555561e100, path_options=0x7fffffffe730) at /source/lib/logpipe.h:439
#30 0x00007ffff7e5f069 in log_pipe_queue (s=0x555555619aa0, msg=0x55555561e100, path_options=0x7fffffffe730) at /source/lib/logpipe.h:489
#31 0x00007ffff7e5ee8b in log_pipe_forward_msg (self=0x5555555ee6e0, msg=0x55555561e100, path_options=0x7fffffffe730) at /source/lib/logpipe.h:439
#32 0x00007ffff7e5f9e4 in log_src_driver_queue_method (s=0x5555555ee6e0, msg=0x55555561e100, path_options=0x7fffffffe730) at /source/lib/driver.c:238
#33 0x00007ffff7e6f7f9 in log_pipe_queue (s=0x5555555ee6e0, msg=0x55555561e100, path_options=0x7fffffffe730) at /source/lib/logpipe.h:485
#34 0x00007ffff7e6f634 in log_pipe_forward_msg (self=0x55555561b870, msg=0x55555561e100, path_options=0x7fffffffe730) at /source/lib/logpipe.h:439
#35 0x00007ffff7e7174e in log_source_queue (s=0x55555561b870, msg=0x55555561e100, path_options=0x7fffffffe730) at /source/lib/logsource.c:674
#36 0x00007ffff7e6f7f9 in log_pipe_queue (s=0x55555561b870, msg=0x55555561e100, path_options=0x7fffffffe730) at /source/lib/logpipe.h:485
#37 0x00007ffff7e71391 in log_source_post (self=0x55555561b870, msg=0x55555561e100) at /source/lib/logsource.c:593
#38 0x00007ffff507d5e1 in _send_generated_message (self=0x55555561b870) at /source/modules/examples/sources/msg-generator/msg-generator-source.c:131
#39 0x00007ffff507d606 in _timer_expired (cookie=0x55555561b870) at /source/modules/examples/sources/msg-generator/msg-generator-source.c:139
#40 0x00007ffff7f34ec4 in iv_run_timers (st=0x555555561960) at /source/lib/ivykis/src/iv_timer.c:124
#41 0x00007ffff7f38266 in iv_main () at /source/lib/ivykis/src/iv_main_posix.c:98
#42 0x00007ffff7e7a500 in main_loop_run (self=0x7ffff7fbc460 <main_loop>) at /source/lib/mainloop.c:763
#43 0x0000555555556aac in main (argc=1, argv=0x7fffffffea18) at /source/syslog-ng/main.c:345
@mitzkia mitzkia added the bug Something isn't working label Aug 31, 2024
@axoflow axoflow deleted a comment Aug 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant