Repository navigation
dd: keep unblock state across reads so records are not split at read boundaries - #15876
Open
mavrodikomsd-eng wants to merge 1 commit into
Open
mavrodikomsd-eng wants to merge 1 commit into
mavrodikomsd-eng wants to merge 1 commit into
Conversation
…boundaries unblock() was stateless and ran buf.chunks(cbs) on each read buffer separately, so every buffer was assumed to start at a record boundary: a read ending partway through a record turned the leftover into a short line and cut every later record in that buffer at the wrong column, for example with cbs=80 and the default 512-byte block, or with short reads from a pipe. The Converter now carries the partial record between calls, like the conv=block path already does, and pads the final incomplete record at EOF the way GNU dd does. Fixes uutils#15818
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #15818
unblock()was a stateless helper called once per read buffer and ranbuf.chunks(cbs)on that buffer alone, so every buffer was assumed to start at a record boundary. A read ending partway through a record turned the leftover partial chunk into its own short line, and every later record in that buffer was cut at the wrong column (e.g.cbs=80with the default 512-byte block, or short reads from a pipe), while GNU dd prints one line per record.The
Converternow carries the partial record between calls — the same approach theconv=blockpath already uses withrecord_len— andfinish()pads the final incomplete record with spaces the way GNU does, whichunblockthen trims.Testing: added unit tests in
blocks.rsfeeding records in several reads: record spanning reads, exact records (no extra newline at EOF), EOF partial record, trailing-space trimming across reads and an all-space record. All 90 dd unit tests and the dd integration tests pass;test_ls::test_ls_hidden_link_windowsfails on this branch but also fails on current main (pre-existing Windows failure, unrelated).