From ba97b640bd03ceecf2b3bb5b5ba1271e6ad0b4a3 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Thu, 17 Nov 2016 19:24:12 +0100 Subject: [PATCH] Check length of copy to be extra sure we are copying whole thing --- cid.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cid.go b/cid.go index 04cc09a..e3aab8c 100644 --- a/cid.go +++ b/cid.go @@ -191,7 +191,10 @@ func (c *Cid) bytesV1() []byte { buf := make([]byte, 2*binary.MaxVarintLen64+len(c.hash)) n := binary.PutUvarint(buf, c.version) n += binary.PutUvarint(buf[n:], c.codec) - copy(buf[n:], c.hash) + cn := copy(buf[n:], c.hash) + if cn != len(c.hash) { + panic("copy hash length is inconsistent") + } return buf[:n+len(c.hash)] }