From 2f7093704b25b219423d848f46a02e24d931415b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matev=C5=BE=20Jekovec?= Date: Wed, 29 Jan 2020 13:37:56 +0100 Subject: [PATCH] go/storage/mkvs/urkel: fix invalid memory access when unmarshalling --- .changelog/2611.bugfix.md | 1 + go/storage/mkvs/urkel/node/node.go | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 .changelog/2611.bugfix.md diff --git a/.changelog/2611.bugfix.md b/.changelog/2611.bugfix.md new file mode 100644 index 00000000000..7100cca75f4 --- /dev/null +++ b/.changelog/2611.bugfix.md @@ -0,0 +1 @@ +go/storage: Fix invalid memory access crash in Urkel tree diff --git a/go/storage/mkvs/urkel/node/node.go b/go/storage/mkvs/urkel/node/node.go index 8fcfaa59969..35f711d4e64 100644 --- a/go/storage/mkvs/urkel/node/node.go +++ b/go/storage/mkvs/urkel/node/node.go @@ -622,7 +622,8 @@ func (n *LeafNode) SizedUnmarshalBinary(data []byte) (int, error) { valueSize := int(binary.LittleEndian.Uint32(data[pos : pos+ValueLengthSize])) pos += ValueLengthSize - value := data[pos : pos+valueSize] + value := make([]byte, valueSize) + copy(value, data[pos:pos+valueSize]) pos += valueSize n.Clean = true