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>
package safefilepath
-import "runtime"
+import (
+ "internal/bytealg"
+ "runtime"
+)
func fromFS(path string) (string, error) {
if runtime.GOOS == "plan9" {
return "", errInvalidPath
}
}
- for i := range path {
- if path[i] == 0 {
- return "", errInvalidPath
- }
+ if bytealg.IndexByteString(path, 0) >= 0 {
+ return "", errInvalidPath
}
return path, nil
}