summaryrefslogtreecommitdiffhomepage
path: root/pkg
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2020-04-03 05:07:57 +0000
committergVisor bot <gvisor-bot@google.com>2020-04-03 05:07:57 +0000
commit3409906aa317ff08367d1f7c135f818a6096eaf9 (patch)
tree3be6cc6d98fb2f75324ad1d6be8b4ed3a986bd21 /pkg
parent2aa08b300235a3b09c3736b4efd6ddd87d8941c5 (diff)
parentd151693530db68db43188ce0fbc9f81aa5f27e2e (diff)
Merge release-20200323.0-63-gd151693 (automated)
Diffstat (limited to 'pkg')
-rw-r--r--pkg/p9/messages.go14
1 files changed, 6 insertions, 8 deletions
diff --git a/pkg/p9/messages.go b/pkg/p9/messages.go
index 3863ad1f5..57b89ad7d 100644
--- a/pkg/p9/messages.go
+++ b/pkg/p9/messages.go
@@ -1926,19 +1926,17 @@ func (r *Rreaddir) decode(b *buffer) {
// encode implements encoder.encode.
func (r *Rreaddir) encode(b *buffer) {
entriesBuf := buffer{}
+ payloadSize := 0
for _, d := range r.Entries {
d.encode(&entriesBuf)
- if len(entriesBuf.data) >= int(r.Count) {
+ if len(entriesBuf.data) > int(r.Count) {
break
}
+ payloadSize = len(entriesBuf.data)
}
- if len(entriesBuf.data) < int(r.Count) {
- r.Count = uint32(len(entriesBuf.data))
- r.payload = entriesBuf.data
- } else {
- r.payload = entriesBuf.data[:r.Count]
- }
- b.Write32(uint32(r.Count))
+ r.Count = uint32(payloadSize)
+ r.payload = entriesBuf.data[:payloadSize]
+ b.Write32(r.Count)
}
// Type implements message.Type.