landley / toybox

toybox
http://landley.net/toybox
BSD Zero Clause License
2.44k stars 340 forks source link

xsendfile error checking #487

Open dlegaultbbry opened 7 months ago

dlegaultbbry commented 7 months ago

I've noticed that commands like cp, for example, will fail silently when they encounter an error such as ENOSPC on a filesystem.

I've added and tested adding a simple addition equivalent of if (len == -1) perror_exit("write error"); in xsendfile to trap the error and re-ran the full test suite and haven't noticed any glaring issues and it does fix that cp problem.

I also noticed tar was using sendfile_len directly instead of xsendfile_len. Not sure if this is an issue in practice.