diff: handle read(2) failures
MFC After: 1 week
(cherry picked from commit 9b98c4b053917cad42e26596b37df72efab6dc39)