fileutil: linter fixes.

This commit is contained in:
2025-11-15 15:58:51 -08:00
parent a37d28e3d7
commit 876a0a2c2b
2 changed files with 6 additions and 3 deletions

View File

@@ -1,10 +1,10 @@
//go:build !windows //go:build !windows
// +build !windows
// Package fileutil contains common file functions. // Package fileutil contains common file functions.
package fileutil package fileutil
import ( import (
"math"
"os" "os"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
@@ -46,5 +46,9 @@ const (
// Access returns a boolean indicating whether the mode being checked // Access returns a boolean indicating whether the mode being checked
// for is valid. // for is valid.
func Access(path string, mode int) error { func Access(path string, mode int) error {
return unix.Access(path, uint32(mode)) // Validate the conversion to avoid potential integer overflow (gosec G115).
if mode < 0 || uint64(mode) > uint64(math.MaxUint32) {
return unix.EINVAL
}
return unix.Access(path, uint32(mode)) // #nosec G115 - handled above.
} }

View File

@@ -1,5 +1,4 @@
//go:build windows //go:build windows
// +build windows
// Package fileutil contains common file functions. // Package fileutil contains common file functions.
package fileutil package fileutil