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

Integrating go-fuzz... #77

Merged
merged 5 commits into from
Feb 22, 2018
Merged

Integrating go-fuzz... #77

merged 5 commits into from
Feb 22, 2018

Conversation

pascallouisperez
Copy link
Contributor

and fixing two small bugs: limiting to no more than 65536 fields, and no more than a scale of 32.

(We can lift the scale limitation when we implement arbitrary precision... though having some limit makes sense.)

@workmajj
Copy link
Contributor

Looking now! 👁

Copy link
Contributor

@workmajj workmajj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! I have just a couple comments about clarity, but I'm happy to accept now and have you make those changes if/when you see fit.

I'm excited to try this out and find all kinds of weird bugs we couldn't've anticipated before. :-D

worksheets.go Outdated
@@ -93,6 +93,8 @@ func NewDefinitions(reader io.Reader, opts ...Options) (*Definitions, error) {
// Any bad index?
if field.index == 0 {
return nil, fmt.Errorf("%s.%s: index cannot be zero", def.name, field.name)
} else if field.index > 65536 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think most code-readers will understand the significance of 65536, but it might be more literate to express this as math.MaxUint16 + 1, so your intent is clear. Same thing for other instances of this.

parser_test.go Outdated
`bool`: &BoolType{},
`number[5]`: &NumberType{5},
`number[32]`: &NumberType{32},
`[]bool`: &SliceType{&BoolType{}},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have simple (non fuzz) tests for other types of slices? If not, might be nice to add those while we're in here. (Not directly related to your PR, but occurred to me from looking through the tests recently.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't! We could definitely beef up TestParser_parseType to have more examples like []number[4] or [][]foo, etc. Will add to my TODO list #73.

parser.go Outdated
panic(err)
}
}
if scale > 32 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be +1 on farming this (32) out to a constant somewhere, so it's easy to reference consistently.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we definitely should. We also need to apply this consistently so that round down 33 errors out with the same message around scale being to large. I'll address as part of this change, might as well.

parser.go Outdated
if err != nil {
// unexpected since sIndex should conform to pIndex
panic(err)
index := 65536 + 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Same note here about 65536.)

parser.go Outdated
if len(sScale) <= len("32") {
scale, err = strconv.Atoi(sScale)
if err != nil {
// unexpected since sIndex should conform to pIndex
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this comment be about scales instead of indexes? Looks like maybe just bad copypasta from above. :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, fixing

and fixing two small bugs: limiting to no more than 65536 fields, and no more than a scale of 32.

(We can lift the scale limitation when we implement arbitrary precision... though having some limit makes sense.)
@pascallouisperez pascallouisperez merged commit ee5de15 into master Feb 22, 2018
@lgonzalez-silen lgonzalez-silen deleted the go-fuzz branch June 2, 2018 14:01
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

Successfully merging this pull request may close these issues.

2 participants