mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 17:33:47 +00:00
swarm/storage: Catch c<0 for varint read overflows
This commit is contained in:
parent
08fc950a2e
commit
d10516b47e
1 changed files with 2 additions and 2 deletions
|
|
@ -861,14 +861,14 @@ func isMultihash(data []byte) int {
|
||||||
cursor := 0
|
cursor := 0
|
||||||
hashtype, c := binary.Uvarint(data)
|
hashtype, c := binary.Uvarint(data)
|
||||||
log.Trace("ismultihash", "hashtype", hashtype, "c", c)
|
log.Trace("ismultihash", "hashtype", hashtype, "c", c)
|
||||||
if c == 0 {
|
if c <= 0 {
|
||||||
log.Debug("Corrupt multihash data, hashtype is unreadable")
|
log.Debug("Corrupt multihash data, hashtype is unreadable")
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
cursor += c
|
cursor += c
|
||||||
hashlength, c := binary.Uvarint(data[cursor:])
|
hashlength, c := binary.Uvarint(data[cursor:])
|
||||||
log.Trace("ismultihash", "hashlength", hashlength, "c", c)
|
log.Trace("ismultihash", "hashlength", hashlength, "c", c)
|
||||||
if c == 0 {
|
if c <= 0 {
|
||||||
log.Debug("Corrupt multihash data, hashlength is unreadable")
|
log.Debug("Corrupt multihash data, hashlength is unreadable")
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue