The official implementation does #1: It assumes that if there are 10 bytes
or more in a row with the high bit set when a varint is expected, then some
sort of corruption must have occurred. It's impossible to reasonably
recover from such corruption, so the parser just gives up and returns an
erro
When reading about the varint encoding I wondered if there was a
specific guidance on how to handle a badly encoded/out-of-bounds
varint. In particular, what if I get more than ten consecutive bytes
with the high bit set?
1) Treat the whole message as bad, and drop it
2) Treat the field as bad, d