emancu / toml-rb

A parser for TOML using Citrus library.
MIT License
104 stars 40 forks source link

Unexpected exception #150

Open mschwager opened 7 months ago

mschwager commented 7 months ago

Hi there,

I've been working on a new fuzzer for Ruby, and I used your library as a test harness. I was able to produce an "unexpected" exception. In this situation, I consider "unexpected" to be parsing exceptions that don't produce a TomlRB::* exception.

So far, I've been able to produce one of these exceptions:

Running: crash-de5bd93bdf57a240c692061f4c248221bc118965
/var/lib/gems/3.1.0/gems/citrus-3.0.2/lib/citrus.rb:890:in `scan': incompatible encoding regexp match (UTF-8 regexp with ASCII-8BIT string) (Encoding::CompatibilityError)
    from /var/lib/gems/3.1.0/gems/citrus-3.0.2/lib/citrus.rb:890:in `exec'
    from /var/lib/gems/3.1.0/gems/citrus-3.0.2/lib/citrus.rb:288:in `apply_rule'
    from /var/lib/gems/3.1.0/gems/citrus-3.0.2/lib/citrus.rb:250:in `exec'
    from /var/lib/gems/3.1.0/gems/citrus-3.0.2/lib/citrus.rb:1087:in `exec'
    from /var/lib/gems/3.1.0/gems/citrus-3.0.2/lib/citrus.rb:288:in `apply_rule'
    from /var/lib/gems/3.1.0/gems/citrus-3.0.2/lib/citrus.rb:250:in `exec'
    from /var/lib/gems/3.1.0/gems/citrus-3.0.2/lib/citrus.rb:1149:in `exec'
    from /var/lib/gems/3.1.0/gems/citrus-3.0.2/lib/citrus.rb:288:in `apply_rule'
    from /var/lib/gems/3.1.0/gems/citrus-3.0.2/lib/citrus.rb:250:in `exec'
    from /var/lib/gems/3.1.0/gems/citrus-3.0.2/lib/citrus.rb:1206:in `exec'
    from /var/lib/gems/3.1.0/gems/citrus-3.0.2/lib/citrus.rb:288:in `apply_rule'
    from /var/lib/gems/3.1.0/gems/citrus-3.0.2/lib/citrus.rb:250:in `exec'
    from /var/lib/gems/3.1.0/gems/citrus-3.0.2/lib/citrus.rb:780:in `exec'
    from /var/lib/gems/3.1.0/gems/citrus-3.0.2/lib/citrus.rb:288:in `apply_rule'
    from /var/lib/gems/3.1.0/gems/citrus-3.0.2/lib/citrus.rb:250:in `exec'
    from /var/lib/gems/3.1.0/gems/citrus-3.0.2/lib/citrus.rb:1244:in `exec'
    from /var/lib/gems/3.1.0/gems/citrus-3.0.2/lib/citrus.rb:288:in `apply_rule'
    from /var/lib/gems/3.1.0/gems/citrus-3.0.2/lib/citrus.rb:250:in `exec'
    from /var/lib/gems/3.1.0/gems/citrus-3.0.2/lib/citrus.rb:1149:in `exec'
    from /var/lib/gems/3.1.0/gems/citrus-3.0.2/lib/citrus.rb:288:in `apply_rule'
    from /var/lib/gems/3.1.0/gems/citrus-3.0.2/lib/citrus.rb:250:in `exec'
    from /var/lib/gems/3.1.0/gems/citrus-3.0.2/lib/citrus.rb:665:in `parse'
    from /var/lib/gems/3.1.0/gems/citrus-3.0.2/lib/citrus.rb:392:in `parse'
    from /var/lib/gems/3.1.0/gems/toml-rb-3.0.1/lib/toml-rb/parser.rb:13:in `initialize'
    from /var/lib/gems/3.1.0/gems/toml-rb-3.0.1/lib/toml-rb.rb:47:in `new'
    from /var/lib/gems/3.1.0/gems/toml-rb-3.0.1/lib/toml-rb.rb:47:in `parse'

Reproducer: crash-de5bd93bdf57a240c692061f4c248221bc118965.txt

This exception occur when running TomlRB.parse(data) against the data in the reproducer file.

emancu commented 2 months ago

Thanks for reporting, I will take a look over next week