Merge pull request #981 from tanjianfeng:fix-898

PiperOrigin-RevId: 282669859
This commit is contained in:
gVisor bot 2019-11-26 17:21:43 -08:00
commit 4a620c436d
1 changed files with 2 additions and 2 deletions

View File

@ -956,14 +956,14 @@ func (l *localFile) Readdir(offset uint64, count uint32) ([]p9.Dirent, error) {
}
func (l *localFile) readDirent(f int, offset uint64, count uint32, skip uint64) ([]p9.Dirent, error) {
var dirents []p9.Dirent
// Limit 'count' to cap the slice size that is returned.
const maxCount = 100000
if count > maxCount {
count = maxCount
}
dirents := make([]p9.Dirent, 0, count)
// Pre-allocate buffers that will be reused to get partial results.
direntsBuf := make([]byte, 8192)
names := make([]string, 0, 100)