From 560a127ce66ebc637aa9331385248315ab8bd1da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 19 Jan 2021 18:53:37 +0100 Subject: [PATCH] fsutil: Defensive check for Stat cast --- extern/sector-storage/fsutil/filesize_unix.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/extern/sector-storage/fsutil/filesize_unix.go b/extern/sector-storage/fsutil/filesize_unix.go index aadf93acc..7df8dae4c 100644 --- a/extern/sector-storage/fsutil/filesize_unix.go +++ b/extern/sector-storage/fsutil/filesize_unix.go @@ -21,7 +21,10 @@ func FileSize(path string) (SizeInfo, error) { return err } if !info.IsDir() { - stat := info.Sys().(*syscall.Stat_t) + stat, ok := info.Sys().(*syscall.Stat_t) + if !ok { + return xerrors.New("FileInfo.Sys of wrong type") + } // NOTE: stat.Blocks is in 512B blocks, NOT in stat.Blksize return SizeInfo{size}, nil // See https://www.gnu.org/software/libc/manual/html_node/Attribute-Meanings.html