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

Cannot use the null byte (\0) as delimiter in tcp input plugin. #1358

Closed
myungjae1 opened this issue Dec 8, 2016 · 2 comments
Closed

Cannot use the null byte (\0) as delimiter in tcp input plugin. #1358

myungjae1 opened this issue Dec 8, 2016 · 2 comments
Labels
feature request *Deprecated Label* Use enhancement label in general

Comments

@myungjae1
Copy link

myungjae1 commented Dec 8, 2016

  • fluentd or td-agent version.
    fluentd v0.12.29

  • Environment information, e.g. OS.
    macOS sierra + docker (dockerized fluentd using alpine linux)
    But I figure this issue does not matter with environment.

  • Your configuration

<source>
  @type tcp

  tag log
  keep_time_key true
  delimiter "\0"
  port 5170
  bind 0.0.0.0
  format none
</source>

The important part in my configuration is delimiter. I just wanted to use the null byte ("\0" in ruby) as my delimter of tcp input.

  • Your problem explanation. If you have an error logs, write it together.

Error logs

/opt/ruby/lib/ruby/gems/2.2.0/gems/fluentd-0.12.29/lib/fluent/config/basic_parser.rb:92:in `parse_error!': unexpected back-slash escape character '0' at fluentd.conf line 18,15 (Fluent::ConfigParseError)
 17:   keep_time_key true
 18:   delimiter "\0"

     ---------------^
 19:   port 5170
	from /opt/ruby/lib/ruby/gems/2.2.0/gems/fluentd-0.12.29/lib/fluent/config/literal_parser.rb:185:in `eval_escape_char'
	from /opt/ruby/lib/ruby/gems/2.2.0/gems/fluentd-0.12.29/lib/fluent/config/literal_parser.rb:90:in `scan_double_quoted_string'
	from /opt/ruby/lib/ruby/gems/2.2.0/gems/fluentd-0.12.29/lib/fluent/config/literal_parser.rb:71:in `scan_string'
	from /opt/ruby/lib/ruby/gems/2.2.0/gems/fluentd-0.12.29/lib/fluent/config/literal_parser.rb:64:in `parse_literal'
	from /opt/ruby/lib/ruby/gems/2.2.0/gems/fluentd-0.12.29/lib/fluent/config/v1_parser.rb:130:in `parse_element'
	from /opt/ruby/lib/ruby/gems/2.2.0/gems/fluentd-0.12.29/lib/fluent/config/v1_parser.rb:95:in `parse_element'
	from /opt/ruby/lib/ruby/gems/2.2.0/gems/fluentd-0.12.29/lib/fluent/config/v1_parser.rb:43:in `parse!'
	from /opt/ruby/lib/ruby/gems/2.2.0/gems/fluentd-0.12.29/lib/fluent/config/v1_parser.rb:33:in `parse'
	from /opt/ruby/lib/ruby/gems/2.2.0/gems/fluentd-0.12.29/lib/fluent/config.rb:30:in `parse'
	from /opt/ruby/lib/ruby/gems/2.2.0/gems/fluentd-0.12.29/lib/fluent/supervisor.rb:480:in `read_config'
	from /opt/ruby/lib/ruby/gems/2.2.0/gems/fluentd-0.12.29/lib/fluent/supervisor.rb:144:in `start'
	from /opt/ruby/lib/ruby/gems/2.2.0/gems/fluentd-0.12.29/lib/fluent/command/fluentd.rb:173:in `<top (required)>'
	from /opt/ruby/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /opt/ruby/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
	from /opt/ruby/lib/ruby/gems/2.2.0/gems/fluentd-0.12.29/bin/fluentd:5:in `<top (required)>'
	from /opt/ruby/bin/fluentd:22:in `load'
	from /opt/ruby/bin/fluentd:22:in `<main>'

I figure this is because fluentd does not accept the null byte expression when it tries to parse its configurations. There is code like below in lib/fluentd/config/literal_parser.rb.

      def eval_escape_char(c)
        case c
        when '"'
          '"'
        when "'"
          "'"
        when "r"
          "\r"
        when "n"
          "\n"
        when "t"
          "\t"
        when "f"
          "\f"
        when "b"
          "\b"
        when /[a-zA-Z0-9]/
          parse_error! "unexpected back-slash escape character '#{c}'"
        else  # symbols
          c
        end
      end

The null byte expression ("\0") is declined by the regex /[a-zA-Z0-9]/. Is this intented? Is there way to use the null byte as delimiter of tcp input plugin?

@tagomoris tagomoris added the bug Something isn't working label Dec 14, 2016
@tagomoris
Copy link
Member

It's just missed, and looks good to add.
@repeatedly how do you think about this?

@tagomoris tagomoris added feature request *Deprecated Label* Use enhancement label in general and removed bug Something isn't working labels Dec 14, 2016
@repeatedly
Copy link
Member

It seems good.

repeatedly added a commit that referenced this issue Apr 28, 2017
Allow null byte in double-quoted string. fix #1358
repeatedly added a commit that referenced this issue May 22, 2017
Allow null byte in double-quoted string. fix #1358
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request *Deprecated Label* Use enhancement label in general
Projects
None yet
Development

No branches or pull requests

3 participants