Skip to content
This repository has been archived by the owner on Aug 5, 2021. It is now read-only.

Crash when parsing bootstrap #17

Open
msclecram opened this issue Jul 5, 2018 · 1 comment
Open

Crash when parsing bootstrap #17

msclecram opened this issue Jul 5, 2018 · 1 comment

Comments

@msclecram
Copy link

Hi,

I'm trying to get some style properties of Gumbo nodes. I load the css included in the html file, however when I try to load Bootstrap the program crashes inside the katana parse function. It crashes inside the katanaerror funcion when it tries to print an error with text "syntax error at ".

This is the css I'm trying to load: https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css

Stack:

image

Thanks!

@jonathanmcdougall
Copy link

jonathanmcdougall commented Aug 12, 2018

I just ran into this myself, katana crashes on any parse error. Introduced in this commit, this:

snprintf(e->message, KATANA_ERROR_MESSAGE_SIZE, "%s at %s", error,
         katanaget_text(parser->scanner));

should be

snprintf(e->message, KATANA_ERROR_MESSAGE_SIZE, "%s at %s", error,
         katanaget_text(*parser->scanner));

because parser->scanner is a yyscan_t*, and katanaget_text() expects a yyscan_t. Since all that stuff is actually a bunch of void*, everything compiles. Adding the dereference fixes the crash.

Also, first_line and last_line in the KatanaError are broken because they're not initialized in the buffer state. Adding the following to katana_scan_buffer() (katana.lex.c:3309), just before the call to katana_switch_to_buffer(), fixes it:

b->yy_buffer_status = YY_BUFFER_NEW;

// add:
b->yy_bs_lineno = 0;
b->yy_bs_column = 0;

katana_switch_to_buffer(b ,yyscanner );

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants