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

"slice bounds out of range" in glob.matchElement #1220

Closed
mrlzh opened this issue Jan 14, 2021 · 1 comment
Closed

"slice bounds out of range" in glob.matchElement #1220

mrlzh opened this issue Jan 14, 2021 · 1 comment

Comments

@mrlzh
Copy link

mrlzh commented Jan 14, 2021

Reappearance:
Decoding tCsrMDMyM9X4pf7r5w== with Base64 as filename and creating a file.

Executing the 'ls *.a' command causes a crash

panic: runtime error: slice bounds out of range [14:13]

goroutine 170 [running]:
github.com/elves/elvish/pkg/glob.matchElement(0xc000393960, 0x2, 0x2, 0xc0003bf598, 0xd, 0x0)
        /Users/testingliu/Desktop/elvish-0.14.1/pkg/glob/glob.go:238 +0x716
mrlzh added a commit to mrlzh/elvish that referenced this issue Jan 14, 2021
xiaq added a commit that referenced this issue Jun 8, 2021
xiaq added a commit that referenced this issue Jun 8, 2021
The crash doesn't happen right now because the code has been fixed, but the test will
reproduce the crash if the change in glob.go is reverted.
@xiaq xiaq closed this as completed in 941cdf2 Jun 8, 2021
@xiaq
Copy link
Member

xiaq commented Jun 8, 2021

The issue is now fixed, but I thought I'd share some interesting facts I found when trying to test this:

  • macOS will not create a file whose name has invalid UTF-8 sequences.
  • Windows pretends to, but substitutes the invalid sequence with U+FFFD.
  • Linux seems to be the only OS that would happily create a file whose name contains anything but NUL.

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

No branches or pull requests

2 participants