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

Crash parsing invalid file URI #3275

Closed
2 tasks done
secsys-go opened this issue Sep 21, 2022 · 4 comments · Fixed by #3308
Closed
2 tasks done

Crash parsing invalid file URI #3275

secsys-go opened this issue Sep 21, 2022 · 4 comments · Fixed by #3308
Labels
bug Something isn't working good first issue Good for newcomers Hacktoberfest

Comments

@secsys-go
Copy link

Checklist

  • I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
  • This issue only relates to a single bug. I will open new issues for any other problems.

Describe the bug

We used the Fuzz engine to modify some Test(TestFromJSON) data, and then the following crash appeared. We hope to get the help of the developer to confirm whether it is a real bug.

How to reproduce

The simplified test code is in Example code

Screenshots

crash log:

panic: runtime error: slice bounds out of range [5:4] [recovered]
        panic: runtime error: slice bounds out of range [5:4]

goroutine 35 [running]:
testing.tRunner.func1.2({0x62e6c0, 0xc0001d43d8})
        /home/zjx/.local/go/src/testing/testing.go:1211 +0x24e
testing.tRunner.func1()
        /home/zjx/.local/go/src/testing/testing.go:1214 +0x218
panic({0x62e6c0, 0xc0001d43d8})
        /home/zjx/.local/go/src/runtime/panic.go:1038 +0x215
fyne.io/fyne/v2/storage/repository.ParseURI({0xc0001b9770, 0x4})
        /home/zjx/workspace/gowork/src/purelib/fyne/storage/repository/parse.go:63 +0x737
fyne.io/fyne/v2/storage.ParseURI(...)
        /home/zjx/workspace/gowork/src/purelib/fyne/storage/uri.go:35
fyne.io/fyne/v2/theme.uriString.resource({0xc0001b9770, 0xc00019a128})
        /home/zjx/workspace/gowork/src/purelib/fyne/theme/json.go:82 +0x1f
fyne.io/fyne/v2/theme.(*jsonTheme).Font(0xc0001b0528, {0x0, 0x0, 0x1, 0x0, 0x0})
        /home/zjx/workspace/gowork/src/purelib/fyne/theme/json.go:146 +0xbb
fyne.io/fyne/v2/theme.FuzzTestFromJSON({0xc00036f600, 0x22, 0x200})
        /home/zjx/workspace/gowork/src/purelib/fyne/theme/json_test.go_TestFromJSON_test.go:74 +0x143

Example code

        var1:="0000"
	var2:=`{"Fonts":{"monospace":"file"}}0000{"Fonts":{"monospace":"file"}}0000{"Fonts":{"monospace":"file"}}0000{"Fonts":{"monospace":"file"}}0000{"Fonts":{"monospace":"file"}}0000{"Fonts":{"monospace":"file"}}0000{"Fonts":{"monospace":"file"}}0000{"F`
	repository.Register(var1, intRepo.NewFileRepository())
	th, err := FromJSON(var2)
	assert.Nil(t, err)
	th.Font(fyne.TextStyle{Monospace: true}).Name()

Fyne version

638ae24

Go compiler version

1.17.8

Operating system

Linux

Operating system version

Linux r920 4.15.0-159-generic #167-Ubuntu

Additional Information

No response

@secsys-go secsys-go added the unverified A bug that has been reported but not verified label Sep 21, 2022
@andydotxyz andydotxyz changed the title slice bounds out of range Crash parsing invalid file URI Sep 21, 2022
@andydotxyz andydotxyz added bug Something isn't working and removed unverified A bug that has been reported but not verified labels Sep 21, 2022
@andydotxyz andydotxyz added the good first issue Good for newcomers label Sep 21, 2022
@ChandanChainani
Copy link
Contributor

@secsys-go Please can you attach implementation for FromJSON

@Jacalz
Copy link
Member

Jacalz commented Oct 4, 2022

@secsys-go Please can you attach implementation for FromJSON

What do you mean? This is a about a crash when using the theme test for FromJSON:

func FromJSON(data string) (fyne.Theme, error) {
.

ChandanChainani added a commit to ChandanChainani/fyne that referenced this issue Oct 4, 2022
@ChandanChainani
Copy link
Contributor

ChandanChainani commented Oct 4, 2022

@Jacalz Thanks, I was working on old branch so was not able to find the file. raised PR with the fix please review

ChandanChainani added a commit to ChandanChainani/fyne that referenced this issue Oct 5, 2022
@andydotxyz
Copy link
Member

This was resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers Hacktoberfest
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants