Don't attempt to write out more bytes than we have (bb #1857). Otherwise write() returns EFAULT, since we are trying to read more from a map than what there is.