Simple Cache: validate lengths before allocations.

This bug was most unfortunate. A corrupt entry could cause Chrome to
crash when opening it, without removing the entry. Not a good loop to
be in. Now we are much more careful with casts around the data coming
from disk to confirm sanity before proceeding.

R=juliatuttle@chromium.org
BUG=541720

Review-Url: https://codereview.chromium.org/2086053003
Cr-Commit-Position: refs/heads/master@{#408134}
5 files changed