Unfortunately, two more subtle bugs to fix:

Unfortunately, two more subtle bugs to fix:

- If the encoded protobuf message is only three bytes long (or less),
  not only the whole protobuf will fit into headerBuf, but also the
  beginning of the next length varint. This will completely wreak
  havoc in the read process. (This bug never bit us in Prometheus
  because the protobuf messages were all long enough. But protobufs in
  general can be very small (0 bytes in fact). I added a test for
  that.)

- If the reader stops in the middle of a length varint, it will
  interpret the null byte that is already in headerBuf as the final
  byte of the varint, which again wreaks havoc. (This bug only shows
  up in Prometheus after
  prometheus/prometheus@dfb9c2a
  , and it is very rare... needs very unlucky fragmentation on the
  network.)

Solution to the first bug is to read byte-wise, which is slightly less
effective, but simplifies the code later, because we don't "overshoot"
anymore. Solution to the second bug is to only read the parts of
headerBuf that have been written to.
Merge pull request #4 from u-c-l/bug/decode

Fix two more bugs.