[PATCH] dd: fix corrupted/incomplete reads/skips.
Denys Vlasenko
vda.linux at googlemail.com
Thu Nov 9 15:26:28 UTC 2017
On Wed, Nov 1, 2017 at 10:37 PM, Nicholas Clark
<nicholas.clark at gmail.com> wrote:
>
> Busybox dd expects that read() calls (as provided by safe_read) will
> always return the requested amount of data unless at EOF. This isn't
> true for safe_read(), but it is true for full_read() (which loops
> over safe_read until enough data has been retrieved).
>
> This patch replaces dd's safe_read() calls with full_read() to make
> sure that the underlying assumptions about read-length always hold
> true.
coreutils dd performs short reads:
while sleep 1; do echo -n "."; done | strace -oLOG -s99 -tt dd bs=2
16:23:23.806219 read(0, ".", 2) = 1
16:23:24.794404 write(1, ".", 1) = 1
16:23:24.794833 read(0, ".", 2) = 1
16:23:25.796523 write(1, ".", 1) = 1
16:23:25.796784 read(0, ".", 2) = 1
16:23:26.798174 write(1, ".", 1) = 1
16:23:26.798562 read(0, ".", 2) = 1
16:23:27.800102 write(1, ".", 1) = 1
16:23:27.800267 read(0, ".", 2) = 1
16:23:28.802201 write(1, ".", 1) = 1
16:23:28.802440 read(0, ".", 2) = 1
16:23:29.804255 write(1, ".", 1) = 1
More information about the busybox
mailing list