metrics: Add a check for abnormally small messages to prevent crashes

In some situations the |message_size| read from |fd| comes up as 0. In this
case we try to read a negative size for the message body and this leads for
crashes. Add a check to make sure that message_size is at least 4 bytes long
to account for the required 32-bit integer message size field.

TEST=`FEATURES=test emerge-link metrics`

Change-Id: Ie9adbc8e0e6a9f2c80450bf7ebcb3e05ad1f1f8e
Trybot-Ready: Alex Vakulenko <>
Tested-by: Alex Vakulenko <>
Reviewed-by: Bertrand Simonnet <>
Commit-Queue: Alex Vakulenko <>
1 file changed
tree: c2e4af8aeb298e28297184c420152525b4febcf4
  1. metrics/