Merge pull request #2355 from thaJeztah/fix_bind_panic

fix panic on single-character volumes
This commit is contained in:
Silvin Lubecki 2020-02-21 14:48:37 +01:00 committed by GitHub
commit 59eee68015
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View File

@ -111,6 +111,9 @@ func isFilePath(source string) bool {
case '.', '/', '~':
return true
}
if len([]rune(source)) == 1 {
return false
}
// windows named pipes
if strings.HasPrefix(source, `\\`) {

View File

@ -162,6 +162,8 @@ func TestParseVolumeWindowsNamedPipe(t *testing.T) {
func TestIsFilePath(t *testing.T) {
assert.Check(t, !isFilePath("a界"))
assert.Check(t, !isFilePath("1"))
assert.Check(t, !isFilePath("c"))
}
// Preserve the test cases for VolumeSplitN