mirror of
https://github.com/TECHNOFAB11/zfs-localpv.git
synced 2025-12-12 06:20:11 +01:00
fix(filepath): fixes of potential file inclusion via variable (#322)
Signed-off-by: nisarg1499 <nisshah1499@gmail.com>
This commit is contained in:
parent
a8376796b7
commit
0ebab22224
2 changed files with 4 additions and 3 deletions
|
|
@ -62,7 +62,7 @@ func Get() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
path := filepath.Join(os.Getenv("GOPATH") + versionFile)
|
path := filepath.Join(os.Getenv("GOPATH") + versionFile)
|
||||||
vBytes, err := ioutil.ReadFile(path)
|
vBytes, err := ioutil.ReadFile(filepath.Clean(path))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Errorf("failed to get version: %s", err.Error())
|
klog.Errorf("failed to get version: %s", err.Error())
|
||||||
return ""
|
return ""
|
||||||
|
|
@ -81,7 +81,7 @@ func GetBuildMeta() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
path := filepath.Join(os.Getenv("GOPATH") + buildMetaFile)
|
path := filepath.Join(os.Getenv("GOPATH") + buildMetaFile)
|
||||||
vBytes, err := ioutil.ReadFile(path)
|
vBytes, err := ioutil.ReadFile(filepath.Clean(path))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Errorf("failed to get build version: %s", err.Error())
|
klog.Errorf("failed to get build version: %s", err.Error())
|
||||||
return ""
|
return ""
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
mnt "github.com/openebs/lib-csi/pkg/mount"
|
mnt "github.com/openebs/lib-csi/pkg/mount"
|
||||||
apis "github.com/openebs/zfs-localpv/pkg/apis/openebs.io/zfs/v1"
|
apis "github.com/openebs/zfs-localpv/pkg/apis/openebs.io/zfs/v1"
|
||||||
|
|
@ -297,7 +298,7 @@ func MountBlock(vol *apis.ZFSVolume, mountinfo *MountInfo) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeFile(pathname string) error {
|
func makeFile(pathname string) error {
|
||||||
f, err := os.OpenFile(pathname, os.O_CREATE, os.FileMode(0644))
|
f, err := os.OpenFile(filepath.Clean(pathname), os.O_CREATE, os.FileMode(0644))
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !os.IsExist(err) {
|
if !os.IsExist(err) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue