Import fixes from an internal repo.

* Fix buffer size requirement calculation
* Fix negative tests not checking relevant extensions

Change-Id: Ibc6759b6b4f0ef811a25eef88c4b5fe5964e9349
8 files changed