From d10516b47eacca3a368232d6d82f7ae9b2b9ad4d Mon Sep 17 00:00:00 2001 From: lash Date: Fri, 26 Jan 2018 02:53:31 +0100 Subject: [PATCH] swarm/storage: Catch c<0 for varint read overflows --- swarm/storage/resource.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/swarm/storage/resource.go b/swarm/storage/resource.go index 77942a0ccb..9f8d78c21b 100644 --- a/swarm/storage/resource.go +++ b/swarm/storage/resource.go @@ -861,14 +861,14 @@ func isMultihash(data []byte) int { cursor := 0 hashtype, c := binary.Uvarint(data) log.Trace("ismultihash", "hashtype", hashtype, "c", c) - if c == 0 { + if c <= 0 { log.Debug("Corrupt multihash data, hashtype is unreadable") return 0 } cursor += c hashlength, c := binary.Uvarint(data[cursor:]) log.Trace("ismultihash", "hashlength", hashlength, "c", c) - if c == 0 { + if c <= 0 { log.Debug("Corrupt multihash data, hashlength is unreadable") return 0 }