Skip to content

Commit

Permalink
update type assertion to prevent panic (#50)
Browse files Browse the repository at this point in the history
Signed-off-by: Brian Downs <[email protected]>
  • Loading branch information
briandowns authored Aug 23, 2021
1 parent 20d93d3 commit 7662889
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 0 additions & 2 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,9 @@ func Parse(path string, result interface{}) error {
}

f, err := os.Open(path)

if err != nil {
return err
}

defer f.Close()

file := filepath.Base(path)
Expand Down
7 changes: 6 additions & 1 deletion pkg/config/config_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@
package config

import (
"errors"
"fmt"
"os"
"syscall"
)

func pathOwnedByRoot(fi os.FileInfo, path string) error {
if fi.Sys().(*syscall.Stat_t).Uid != 0 || fi.Sys().(*syscall.Stat_t).Gid != 0 {
stat, ok := fi.Sys().(*syscall.Stat_t)
if !ok {
return errors.New("failed type assertion for *syscall.Stat_t")
}
if stat.Uid != 0 || stat.Gid != 0 {
return fmt.Errorf("file %s had was not owned by root:root", path)
}
return nil
Expand Down
1 change: 0 additions & 1 deletion pkg/image/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ func NewUtility(imagesDir, imageCredentialProviderConfig, imageCredentialProvide
}

func (u *Utility) Stage(destDir string, imgString string) error {

if err := os.MkdirAll(destDir, 0755); err != nil {
return err
}
Expand Down
1 change: 0 additions & 1 deletion pkg/prober/prober.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ func DoProbe(probe Probe, probeStatus *ProbeStatus, initial bool) error {
}

caCertPool, err := x509.SystemCertPool()

if err != nil {
caCertPool = x509.NewCertPool()
logrus.Errorf("error loading system cert pool: %v", err)
Expand Down

0 comments on commit 7662889

Please sign in to comment.