bug-coreutils
[Top][All Lists]
Advanced

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

Re: dd does not handle input from pipes correctly (coreutils-5.93)


From: Paul Eggert
Subject: Re: dd does not handle input from pipes correctly (coreutils-5.93)
Date: Thu, 17 Nov 2005 22:51:16 -0800
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

Paul Mielke <address@hidden> writes:

> The problem is this:  if input is from stdin and stdin is a pipe, the
> routine dd_copy assumes that a short read returned from "iread"
> means that it has read a partial record.

I think that's what dd is supposed to do.  See, for example,
<http://www.opengroup.org/onlinepubs/000095399/utilities/dd.html>.

> The easiest way to see the bug is to do something like:
>
> dd if=/dev/urandom of=foo count=3
> dd if=/dev/urandom of=pad bs=16k count=1
>
> cat foo pad | dd of=foo.padded bs=16k count=1
>
> When the failure occurs, foo.padded ends up being shorter than 16k.

Solaris 10 dd does something similar to GNU dd (so if GNU dd is wrong
at least it's in good company :-):

575-otter $ dd if=/dev/urandom of=foo count=3
3+0 records in
3+0 records out
576-otter $ dd if=/dev/urandom of=pad bs=16k count=1
0+1 records in
0+1 records out
577-otter $ cat foo pad | dd of=foo.padded bs=16k count=1
0+1 records in
0+1 records out
578-otter $ ls -l foo pad foo.padded 
-rw-rw-r--   1 eggert   faculty     1536 Nov 17 22:47 foo
-rw-rw-r--   1 eggert   faculty     1536 Nov 17 22:47 foo.padded
-rw-rw-r--   1 eggert   faculty     1040 Nov 17 22:47 pad




reply via email to

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