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

Segmentation fault while parsing a TOML file #243

Open
cactusBalll opened this issue May 10, 2024 · 0 comments
Open

Segmentation fault while parsing a TOML file #243

cactusBalll opened this issue May 10, 2024 · 0 comments

Comments

@cactusBalll
Copy link

program

#include "toml.hpp"
#include <iostream>
int main(int argc, char* argv[]) {
    if (argc != 2) {
        return 0;
    }
    try {
        auto data = toml::parse(argv[1]);
        std::cout << std::setw(80) << data << std::endl;
    }
    catch(const std::exception& e)
    {
        std::cerr << e.what() << '\n';
    }
    return 0;
}

file name is passed to program with argv[1].

input file

b =0b11     #= [ 8000,owner]
name = "Wom Preston-Werner"
dob = 1979-05-27T07:32:00-08:00 # First class dateabase]
server =[  ]
connection_mdx = 5000
eKabled = true

[servers]
################################/or spaces) is allowed but not red
  [server.alpha]
  ip = "10.0.0.1"
  dc = "eqdc10"

  [servers.beta]
  ip = "10.8:00 # First class dateabas##################################################################################################################################################] ]

# Line breaks are OK when inside arrays
hosts = [
  "alpha","omega"
]

the TOML above was generated by a fuzzer and lead to a crash of the parser.

stack trace

#0  0x00005555555a562b in toml::basic_value<toml::discard_comments, std::unordered_map, std::vector>::is (this=0xffffffffffffffb8, t=toml::value_t::table)
    at toml/value.hpp:1165
#1  0x0000555555596fc3 in toml::basic_value<toml::discard_comments, std::unordered_map, std::vector>::is_table (this=0xffffffffffffffb8)
    at toml/value.hpp:1177
#2  0x00005555555944fc in toml::detail::insert_nested_key<toml::basic_value<toml::discard_comments, std::unordered_map, std::vector>, __gnu_cxx::__normal_iterator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const*, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > > > (
    root=std::unordered_map with 7 elements = {...}, v=..., iter="server", 
    last=<error reading variable: Cannot create a lazy string with address 0x0, and a non-zero length.>, key_reg=..., is_array_of_table=false)
    at toml/parser.hpp:1773
--Type <RET> for more, q to quit, c to continue without paging--
#3  0x00005555555828e4 in toml::detail::parse_toml_file<toml::basic_value<toml::discard_comments, std::unordered_map, std::vector> > (loc=...)
    at toml/parser.hpp:2438
#4  0x00005555555a547e in toml::detail::parse<toml::discard_comments, std::unordered_map, std::vector> (letters=std::vector of length 0, capacity 0, 
    fname="./crashes/id:000000,sig:11,src:001941+001131,op:splice,rep:4") at toml/parser.hpp:2489
#5  0x0000555555596ebd in toml::parse<toml::discard_comments, std::unordered_map, std::vector> (is=..., 
    fname="./crashes/id:000000,sig:11,src:001941+001131,op:splice,rep:4") at toml/parser.hpp:2558
#6  0x0000555555583622 in toml::parse<toml::discard_comments, std::unordered_map, std::vector> (fname="") at toml/parser.hpp:2573
#7  0x000055555555a20f in main (argc=2, argv=0x7fffffffdf18) at driver.cpp:8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant