]> git.ipfire.org Git - thirdparty/coreutils.git/commit
Fix bug reported by Buciuman Adrian in
authorJim Meyering <jim@meyering.net>
Thu, 3 Jun 2004 16:03:32 +0000 (16:03 +0000)
committerJim Meyering <jim@meyering.net>
Thu, 3 Jun 2004 16:03:32 +0000 (16:03 +0000)
commit6f31b14a6d32a12a03cc6cae5844b06c505d2834
tree8b270bd36613574de3e64e55aae471469d50a8ab
parent6e81a1d9476b1cc46b5862a2c48a219aa68e8739
Fix bug reported by Buciuman Adrian in
<http://mail.gnu.org/archive/html/bug-coreutils/2003-08/msg00105.html>
where 'dd' created a file that was too large.  The bug was that dd
assumed that the input file offset does not advance after a failed
read; but POSIX says that the input file offset is undefined after
a failed read.

(MAX_BLOCKSIZE): New macro.
(input_seekable, input_seek_errno, input_offset,
input_offset_overflow): New vars.
(scanargs): Reject block sizes greater than MAX_BLOCKSIZE.
(advance_input_offset): New function.
(skip_via_lseek): Set errno to zero when reporting our failure,
so that we don't report based on garbage errno.
(skip): If fdesc is standard input, advance the input offset.
Do not quit if reading, and if noerror was specified;
POSIX seems to require this.
If read fails on output file, report the earlier lseek failure
instead; this fixes a FIXME in dd_copy.
(advance_input_after_read_error): New function.
(dd_copy): Use it, instead of assuming that failed reads
do not advance the file pointer.  Advance input offset
after nonfailed reads.  Advance only a partial block if
the previous read (before the failed read) succeeded, and
do not generate an output block of zeros in this case.
(main): Determine initial input offset, seekability of input,
and error if it wasn't seekable.
src/dd.c