Commit e98b6688 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Fix bug: don't use cap() for max dirlist size, since we may use a

larger buffer.
parent 20b92a9a
...@@ -23,12 +23,14 @@ type DirEntry struct { ...@@ -23,12 +23,14 @@ type DirEntry struct {
type DirEntryList struct { type DirEntryList struct {
buf []byte buf []byte
size int
offset uint64 offset uint64
} }
func NewDirEntryList(data []byte, off uint64) *DirEntryList { func NewDirEntryList(data []byte, off uint64) *DirEntryList {
return &DirEntryList{ return &DirEntryList{
buf: data[:0], buf: data[:0],
size: len(data),
offset: off, offset: off,
} }
} }
...@@ -43,7 +45,7 @@ func (l *DirEntryList) Add(name string, inode uint64, mode uint32) bool { ...@@ -43,7 +45,7 @@ func (l *DirEntryList) Add(name string, inode uint64, mode uint32) bool {
oldLen := len(l.buf) oldLen := len(l.buf)
newLen := delta + oldLen newLen := delta + oldLen
if newLen > cap(l.buf) { if newLen > l.size {
return false return false
} }
l.buf = l.buf[:newLen] l.buf = l.buf[:newLen]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment