Skip to content

Crash because of storage.List #4271

Closed
Closed
@secsys-go

Description

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(TestInMemoryRepositoryListing) data, and then the following crash appeared. We debugged and eventually found the crash point is at line 300 of internal/repository/json.go. We feel that this could be an out-of-boundary bug.

How to reproduce

The simplified test code is in Example code

Screenshots

Crash log

panic: runtime error: index out of range [-1] [recovered]
	panic: runtime error: index out of range [-1]

goroutine 19 [running]:
testing.tRunner.func1.2({0x3f3d60, 0xc0000a2780})
	D:/.../go1.19/src/testing/testing.go:1396 +0x24e
testing.tRunner.func1()
	D:/.../go1.19/src/testing/testing.go:1399 +0x39f
panic({0x3f3d60, 0xc0000a2780})
	D:/.../go1.19/src/runtime/panic.go:884 +0x212
fyne.io/fyne/v2/internal/repository.(*InMemoryRepository).List(0xc00009c258, {0x4b9518?, 0xc0000e4690?})
	D:/.../fyne/internal/repository/memory.go:300 +0x32e
fyne.io/fyne/v2/storage.List({0x4b9518, 0xc0000e4690})
	D:/.../fyne/storage/uri.go:479 +0x58
fyne.io/fyne/v2/internal/repository.TestInMemoryRepositoryListing2(0x0?)
	D:/.../fyne/internal/repository/InMemoryRepositoryListing_fuzz_test.go:41 +0xfc
testing.tRunner(0xc000084d00, 0x44c160)
	D:/.../go1.19/src/testing/testing.go:1446 +0x10b
created by testing.(*T).Run
	D:/.../go1.19/src/testing/testing.go:1493 +0x35f

Example code

m := NewInMemoryRepository("mem")
repository.Register("mem", m)
m.Data[""] = []byte{1, 2, 3}
foo, _ := storage.ParseURI("mem:")
storage.List(foo)

Fyne version

commit cfb88d7

Go compiler version

1.19

Operating system and version

Windows 10

Additional Information

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    unverifiedA bug that has been reported but not verified

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions