Better handling of truncated data when reading containers

Summary:
Currently we read the container size and blindly pre-allocate the container of that size. This allows malicious attacker to send few bytes message and cause server to allocate GBs of memory.

This diff changes the logic to check if we have at least 1b/element in our buffer, thus forcing attacker to send that much data.

This is a partial fix for CVE-2019-3553.

Reviewed By: yfeldblum, vitaut

Differential Revision: D14392438

fbshipit-source-id: b92e300a98e29faee564e2f5069027b28cb2cca4