mirror of
https://github.com/mudler/LocalAI.git
synced 2025-06-29 22:20:43 +00:00
refactor: use fmt.Errorf
This commit is contained in:
parent
e88949d9c3
commit
a90b324fb8
1 changed files with 3 additions and 4 deletions
|
@ -2,7 +2,6 @@ package gallery
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -85,7 +84,7 @@ func inTrustedRoot(path string, trustedRoot string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return errors.New("path is outside of trusted root")
|
return fmt.Errorf("path is outside of trusted root")
|
||||||
}
|
}
|
||||||
|
|
||||||
func verifyPath(path, basePath string) error {
|
func verifyPath(path, basePath string) error {
|
||||||
|
@ -93,12 +92,12 @@ func verifyPath(path, basePath string) error {
|
||||||
|
|
||||||
r, err := filepath.EvalSymlinks(c)
|
r, err := filepath.EvalSymlinks(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.New("unsafe or invalid path specified")
|
return fmt.Errorf("unsafe or invalid path specified")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = inTrustedRoot(r, basePath)
|
err = inTrustedRoot(r, basePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.New("unsafe or invalid path specified")
|
return fmt.Errorf("unsafe or invalid path specified")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue