From 6ce8a80816b06b3f3c5e61553ee4efb1c578e4a1 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Thu, 17 Nov 2016 18:45:34 +0100 Subject: [PATCH] Fix panic when length of varints is greater than 8 It can be 16 --- cid.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cid.go b/cid.go index 2fd43e7..3436501 100644 --- a/cid.go +++ b/cid.go @@ -187,7 +187,8 @@ func (c *Cid) bytesV0() []byte { } func (c *Cid) bytesV1() []byte { - buf := make([]byte, 8+len(c.hash)) + // two 8 bytes (max) numbers plus hash + buf := make([]byte, 2*8+len(c.hash)) n := binary.PutUvarint(buf, c.version) n += binary.PutUvarint(buf[n:], c.codec) copy(buf[n:], c.hash)