bug-cpio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-cpio] wrong handling of write(2) errors


From: Vasiliy Kulikov
Subject: [Bug-cpio] wrong handling of write(2) errors
Date: Sat, 17 Sep 2011 18:37:06 +0400
User-agent: Mutt/1.5.20 (2009-06-14)

Hi,

The functions disk_empty_output_buffer() and sparse_write() don't
properly check write(2) return code, which can lead to data loss.

disk_empty_output_buffer() doesn't handle partial writes, but it should.
On partial write it prints error message with wrong errno as write(2)
doesn't set errno on partial writes.  In (bytes_written != output_size)
case the code should properly reset errno on both write() and
sparse_write() partial writes.

sparse_write() doesn't actually check write(2) return code at all -
write_rc is not used.  It should check both for write(2) errors and
partial writes and properly handle the latter in a loop.  Also it should
propagate errno on write() failure and return correct written bytes
count, as write(2) does.  (The comment says it has the same semantics as
write(2).)

The patch with partial fix (no partial writes handling and no errno
setting on partial writes) is attached.  Is it OK to include my fix in
sense of copyright handling?  (I didn't pass any copyright rights to GNU.)
If so, tell me and I'll make a patch with the complete fix.


Also you may want to look at other patches from Owl:

http://cvsweb.openwall.com/cgi/cvsweb.cgi/Owl/packages/cpio/


Please keep me and Solar Designer CC'ed (we're not subscribed to bug-cpio@).

Thanks,

-- 
Vasiliy Kulikov
http://www.openwall.com - bringing security into open computing environments



reply via email to

[Prev in Thread] Current Thread [Next in Thread]