From 0c3abacb1c8cf11b914eb6be46dacaff0a993ebf Mon Sep 17 00:00:00 2001 From: Ayush Ranjan Date: Wed, 29 Jun 2022 22:38:08 -0700 Subject: [PATCH] Limit the lisafs buffer that are printed with strace. Otherwise, in case case read request asks for a lot of bytes but response contains fewer bytes, we end up printing a lot of garbage. PiperOrigin-RevId: 458140547 --- pkg/lisafs/message.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/lisafs/message.go b/pkg/lisafs/message.go index f0a732dee..9ffe755ee 100644 --- a/pkg/lisafs/message.go +++ b/pkg/lisafs/message.go @@ -880,7 +880,8 @@ func (r *PReadResp) CheckedUnmarshal(src []byte) ([]byte, bool) { // We expect the client to have already allocated r.Buf. r.Buf probably // (optimally) points to usermem. Directly copy into that. - return srcRemain[copy(r.Buf[:r.NumBytes], srcRemain[:r.NumBytes]):], true + r.Buf = r.Buf[:r.NumBytes] + return srcRemain[copy(r.Buf, srcRemain[:r.NumBytes]):], true } // PWriteReq is used to pwrite(2) on an FD.