rlp: fix string size check in readKind (#15625)

Issue found by @guidovranken
This commit is contained in:
Felix Lange
2017-12-11 22:47:10 +01:00
committed by GitHub
parent e7610eadfe
commit 2499b1b139
2 changed files with 2 additions and 1 deletions

View File

@ -98,7 +98,7 @@ func readKind(buf []byte) (k Kind, tagsize, contentsize uint64, err error) {
tagsize = 1
contentsize = uint64(b - 0x80)
// Reject strings that should've been single bytes.
if contentsize == 1 && buf[1] < 128 {
if contentsize == 1 && len(buf) > 1 && buf[1] < 128 {
return 0, 0, 0, ErrCanonSize
}
case b < 0xC0: