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

Index out of range error in expect function #561

Closed
CT-Zer0 opened this issue Jun 17, 2021 · 2 comments
Closed

Index out of range error in expect function #561

CT-Zer0 opened this issue Jun 17, 2021 · 2 comments
Labels
bug Issues describing a bug in go-toml. good first issue Issues that are suitable for first-time contributors.
Milestone

Comments

@CT-Zer0
Copy link

CT-Zer0 commented Jun 17, 2021

Describe the bug
Hi there. While I was fuzzing go-tomlv2, I am encountered with index out of range error. My test case is s=[ and I have assumed that parseValArray function doesn't check if '[' is the last element before performing parser.go:401 :

b = b[1:]

To Reproduce
This is my code (you can also find it in here) :

package main

import(
"github.com/pelletier/go-toml/v2"
"fmt"
)

type MyConfig struct {
      Version int
      Name    string
      Tags    []string
}


func main(){


doc := `s=[`

var cfg MyConfig
err := toml.Unmarshal([]byte(doc), &cfg)
if err != nil {
      fmt.Println("error")
}
fmt.Println("version:", cfg.Version)
fmt.Println("name:", cfg.Name)
fmt.Println("tags:", cfg.Tags)
}

Expected behavior
parseValArray should control boundaries and special characters before performing.
Versions

  • go-toml: github.com/pelletier/go-toml/v2 v2.0.0-beta.3 h1:PNCTU4naEJ8mKal97P3A2qDU74QRQGlv4FXiL1XDqi4=
  • go: 1.16.5
  • operating system: e.g. Ubuntu 20

Additional context
This bug is found by offical dev.fuzz

@CT-Zer0 CT-Zer0 changed the title Index out of range error in expect Index out of range error in expect function Jun 17, 2021
@pelletier pelletier added the bug Issues describing a bug in go-toml. label Jun 18, 2021
@pelletier
Copy link
Owner

Good catch, thank you! Will look into it.

@pelletier pelletier added the good first issue Issues that are suitable for first-time contributors. label Jun 23, 2021
@pelletier pelletier added this to the v2.0.0-beta.4 milestone Jul 29, 2021
@pelletier
Copy link
Owner

This has been fixed by 40cfb6f!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues describing a bug in go-toml. good first issue Issues that are suitable for first-time contributors.
Projects
None yet
Development

No branches or pull requests

2 participants