1
0
mirror of https://github.com/golang/go synced 2024-11-21 20:54:45 -07:00

os: check for valid arguments in windows Readdir

Fixes #1129.

R=rsc, brainman
CC=Joe Poirier, golang-dev
https://golang.org/cl/2211045
This commit is contained in:
Peter Mundy 2010-09-23 22:06:59 -04:00 committed by Russ Cox
parent 7c9f0f0109
commit bfb127612a

View File

@ -113,6 +113,12 @@ func (file *File) Stat() (fi *FileInfo, err Error) {
// A negative count means to read until EOF.
// Readdir returns the array and an Error, if any.
func (file *File) Readdir(count int) (fi []FileInfo, err Error) {
if file == nil || file.fd < 0 {
return nil, EINVAL
}
if !file.isdir() {
return nil, &PathError{"Readdir", file.name, ENOTDIR}
}
di := file.dirinfo
size := count
if size < 0 {