fix: Prevent calling readdir and readdirnames on files
This commit is contained in:
@@ -375,6 +375,9 @@ func (f *File) Readdir(count int) ([]os.FileInfo, error) {
|
||||
f.ioLock.Lock()
|
||||
defer f.ioLock.Unlock()
|
||||
|
||||
if !f.info.IsDir() {
|
||||
return []os.FileInfo{}, config.ErrIsFile
|
||||
}
|
||||
hdrs, err := inventory.List(
|
||||
f.metadata,
|
||||
|
||||
@@ -401,6 +404,10 @@ func (f *File) Readdirnames(n int) ([]string, error) {
|
||||
"n": n,
|
||||
})
|
||||
|
||||
if !f.info.IsDir() {
|
||||
return []string{}, config.ErrIsFile
|
||||
}
|
||||
|
||||
dirs, err := f.Readdir(n)
|
||||
if err != nil {
|
||||
return []string{}, err
|
||||
|
||||
Reference in New Issue
Block a user