Properly recover from shorter read.

(cherry picked from commit 66221417957963c1d2df8d79f43573e328df2275)
2 files changed