Merge fixes from OpenBSD.

Check fstat return value.  Also, use off_t for file size and offsets.
Avoid iterating over end of string.

Obtained from:	OpenBSD (CVS rev. 1.41, 1.43)
MFC after:	1 week


git-svn-id: svn+ssh://svn.freebsd.org/base/head@275553 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f