mirror of
https://github.com/golang/go
synced 2024-11-23 04:30:03 -07:00
internal/safefilepath: use bytealg to search for zero byte
Change-Id: I20e72d421d89095c460495001969291b99cdf59e Reviewed-on: https://go-review.googlesource.com/c/go/+/563139 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
This commit is contained in:
parent
0336d5eb43
commit
2a59041420
@ -6,7 +6,10 @@
|
||||
|
||||
package safefilepath
|
||||
|
||||
import "runtime"
|
||||
import (
|
||||
"internal/bytealg"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
func fromFS(path string) (string, error) {
|
||||
if runtime.GOOS == "plan9" {
|
||||
@ -14,10 +17,8 @@ func fromFS(path string) (string, error) {
|
||||
return "", errInvalidPath
|
||||
}
|
||||
}
|
||||
for i := range path {
|
||||
if path[i] == 0 {
|
||||
return "", errInvalidPath
|
||||
}
|
||||
if bytealg.IndexByteString(path, 0) >= 0 {
|
||||
return "", errInvalidPath
|
||||
}
|
||||
return path, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user