Result::Write::write_embedded_file_entry assumes that read(2) never
performs a “short read” (fewer bytes than the supplied count) for files.
A short read can however happen if the process is interrupted by a
signal, for instance on NFS with the “intr” mount option.
Fix this by properly reducing the remaining bytes counter by the amount
of actually read bytes.
if (bytes_read == 0) {
throw Error("Error reading from {}: end of file", path);
}
- writer.write(buf, n);
- remain -= n;
+ writer.write(buf, bytes_read);
+ remain -= bytes_read;
}
}