From ba1ce996bb7c140a84b064112e519d0090f6b975 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 28 Feb 2023 13:50:06 +0530 Subject: [PATCH] Fix WriteWithSize() on shm_syscall --- tools/utils/shm/shm_syscall.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/utils/shm/shm_syscall.go b/tools/utils/shm/shm_syscall.go index 3a7aa53c9..4e0eb8154 100644 --- a/tools/utils/shm/shm_syscall.go +++ b/tools/utils/shm/shm_syscall.go @@ -114,7 +114,11 @@ func (self *syscall_based_mmap) Write(b []byte) (int, error) { } func (self *syscall_based_mmap) WriteWithSize(b []byte) error { - return write_with_size(self.f, b) + szbuf := []byte{0, 0, 0, 0} + binary.BigEndian.PutUint32(szbuf, uint32(len(b))) + copy(self.Slice(), szbuf) + copy(self.Slice()[4:], b) + return nil } func (self *syscall_based_mmap) ReadWithSize() ([]byte, error) {