]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
(dd_out): Fix handling of all-zeroes block at end of input with
authorThomas Quinot <thomas@FreeBSD.org>
Wed, 7 May 2014 19:33:29 +0000 (19:33 +0000)
committerThomas Quinot <thomas@FreeBSD.org>
Wed, 7 May 2014 19:33:29 +0000 (19:33 +0000)
commitaa7a161b407bcfc565396e93138f38ab059467c0
tree4706b9b8d40564ba7f2cf3a7979e41bc05a4ff61
parentf8a6c905bf5f61ea6e21c1991ff74326cafef8fa
(dd_out): Fix handling of all-zeroes block at end of input with
conv=sparse.

This change fixes two separate issues observed when the last output
block is all zeroes, and conv=sparse is in use. In this case, care
must be taken to roll back the last seek and write the entire last zero
block at the original offset where it should have occurred: when the
destination file is a block device, it is not possible to roll back
by just one character as the write would then not be properly aligned.

Furthermore, the buffer used to write this last all-zeroes block
needs to be properly zeroed-out. This was not the case previously,
resulting in a junk data byte appearing instead of a zero in the
output stream.

PR: bin/189174
PR: bin/189284
Reviewed by: kib
MFC after: 2 weeks
bin/dd/dd.c