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

"cd a\" raises exception (Windows) #2666

Open
pdg137 opened this issue Dec 18, 2022 · 2 comments · May be fixed by zyedidia/go-shellquote#1
Open

"cd a\" raises exception (Windows) #2666

pdg137 opened this issue Dec 18, 2022 · 2 comments · May be fixed by zyedidia/go-shellquote#1
Labels

Comments

@pdg137
Copy link

pdg137 commented Dec 18, 2022

Description of the problem or steps to reproduce

Type Ctrl+E, cd a\ , and Enter. Micro immediately terminates:

Micro encountered an error: runtime.boundsError runtime error: index out of range [0] with length 0
runtime/panic.go:89 (0xcf51bf)
github.com/kballard/go-shellquote@v0.0.0-20180428030007-95032a82bc51/unquote.go:88 (0x110293c)
github.com/kballard/go-shellquote@v0.0.0-20180428030007-95032a82bc51/unquote.go:59 (0x11020a5)
github.com/zyedidia/micro/v2/internal/action/command.go:967 (0x11341a9)
github.com/zyedidia/micro/v2/internal/action/actions.go:1470 (0x11252d2)
github.com/zyedidia/micro/v2/internal/info/infobuffer.go:147 (0x1104574)
github.com/zyedidia/micro/v2/internal/action/infopane.go:190 (0x113858c)
github.com/zyedidia/micro/v2/internal/action/infopane.go:54 (0x11377b6)
github.com/zyedidia/micro/v2/internal/action/infopane.go:125 (0x1137f22)
github.com/zyedidia/micro/v2/internal/action/infopane.go:93 (0x1137c7e)
github.com/zyedidia/micro/v2/cmd/micro/micro.go:443 (0x115df45)
github.com/zyedidia/micro/v2/cmd/micro/micro.go:382 (0x115d9ce)
runtime/proc.go:250 (0xcf9d9e)
runtime/asm_amd64.s:1571 (0xd24d21)

If you can reproduce this error, please report it at https://github.com/zyedidia/micro/issues

This is especially troubling since the cd command auto-completes directories with the terminal backslash that causes it to break.

Specifications

Version: 2.0.11
Commit hash: 225927b
Compiled on August 01, 2022
OS: Windows 11
Terminal: mintty 3.6.2 (x86_64-pc-msys) / git bash

@PThorpe92
Copy link
Contributor

Micro encountered an error: runtime.boundsError runtime error: index out of range [0] with length 0
C:/Program Files/Go/src/runtime/panic.go:113 (0x61715f)
goPanicIndex: panic(boundsError{x: int64(x), signed: true, y: y, code: boundsIndex})
C:/Users/************go/pkg/mod/github.com/zyedidia/go-shellquote@v0.0.0-20200613203517-eccd813c0655/unquote.go:88 (0xa4f977)
splitWord: next := rune(cur[0])
Split: word, input, err = splitWord(input, &buf)
C:/Files/micro-master/internal/action/command.go:963 (0xa823e9)
C:/Files/micro-master/internal/action/actions.go:1482 (0xa72d32)
C:/Files/micro-master/internal/info/infobuffer.go:147 (0xa51654)
C:/Files/micro-master/internal/action/infopane.go:190 (0xa867ec)
C:/Files/micro-master/internal/action/infopane.go:54 (0xa859b6)
C:/Files/micro-master/internal/action/infopane.go:125 (0xa86122)
C:/Files/micro-master/internal/action/infopane.go:93 (0xa85e7e)
C:/Files/micro-master/cmd/micro/micro.go:443 (0xaaca73)
C:/Files/micro-master/cmd/micro/micro.go:382 (0xaac4f2)
C:/Program Files/Go/src/runtime/proc.go:250 (0x61bf5e)
main: fn()
C:/Program Files/Go/src/runtime/asm_amd64.s:1594 (0x6479c1)

The go-shellquote pkg is supposed to just throw an error when the string it's trying to split ends with an escape character. It works for an unended quotation mark like it's supposed to, but micro crashes every time when you end the cd command with a backslash escape. Looking into it

@JoeKar
Copy link
Collaborator

JoeKar commented May 13, 2024

The crash has been introduced with the only commit added to the fork, where the out of bounds access takes place instead of checking the input length, finalize the string via with the instruction within the default case and then goto raw.

Fixing this isn't that hard, but unfortunately we can't do this by our own due to the lack of permissions there.

@zyedidia:
Can you please assist? 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants