-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
go/vt/sqlparser: index out of range #767
Comments
@sougou This appears to be a bug in the yacc-generated code. Is there anything we can do? Try a newer version of yacc? |
I've been meaning to look at it once I'm done with my benchmark work. Looking at the test, it most likely is a stack overflow due high level of nesting. I'll either have to change to grammar to reduce more aggressively rather than shifting, or limit the nesting count and return a meaningful error. |
Well, the "go tool yacc" version has been improving: https://github.com/golang/go/commits/master/src/cmd/yacc :) |
Here are two more reproducers with slightly different stacks (one of them is probably the same as original):
|
I don't know what changed, but I wasn't able to reproduce this from the latest pull. In any case, I have a CL that limits nesting of anything parenthesized to a fixed number. I'll hard code that to 200. |
This addresses #767 as well as other situations where there's possibility of indefinite nesting of SQL constructs. There may be other non-aprentheszed constructs that allow nesting, but this fix doesn't address them for now. I've also made a few lint fixes. sql.go is still in violation, but that requires bigger work.
Otherwise it's yacc generated code is vulnerable to DOS. vitessio/vitess#767
The following program crashes with the panic:
on commit
discovered with https://github.com/dvyukov/go-fuzz
The text was updated successfully, but these errors were encountered: