dd: conv=sync repeats bytes from the previous block when a byte count ends mid-block

オープン 初心者向け
#16,770 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
rust
領域
cli

調査の方向性

バグは src/uu/dd/src/dd.rs の fill_blocks にあり、553〜588行目付近で、読み取った長さと残りのスライス長が比較されています。issue の再現手順(bs=4 count=5B conv=sync)を uutils のバイナリと GNU dd の両方で実行し、出力バイトを比較してください。ブロックの途中で終端に達した後のパディングが GNU dd と同じ NUL バイトになり、そのケースを dd のテストがカバーしていれば完了です。

索引モデルが issue の本文から書いたものです。

説明

With bs=4 count=5B conv=sync, uutils dd writes eight bytes, but the last three repeat bytes 2–4 of the first block. GNU dd pads with three NUL bytes.

Reproduction

Run in an empty directory with the uutils multicall binary as coreutils and GNU dd as dd.

printf ABCDEFGH > input
coreutils dd if=input bs=4 count=5B conv=sync status=none | od -An -tx1
# 41 42 43 44 45 42 43 44
dd if=input bs=4 count=5B conv=sync status=none | od -An -tx1
# 41 42 43 44 45 00 00 00

Verified with official uutils 0.12.0 and 0.13.0 x86_64 Linux musl binaries and GNU coreutils 9.7. Using count=5 iflag=count_bytes gives the same result. With a five-byte input and no count operand, both implementations pad correctly.

Source

On main at 7913995, fill_blocks compares the read length with the remaining slice length. The final one-byte read fills that slice, so it skips padding but advances the output length by four. The unused positions still contain BCD.

https://github.com/uutils/coreutils/blob/791399596cc7214e76c0c6bd022332ab6048ec65/src/uu/dd/src/dd.rs#L553-L588

Related: #13435 corrected input byte-budget accounting. Here the input limit is respected and the output padding is incorrect.

主要言語
Rust
スター
24.4k
フォーク
2.2k
平均マージ
2日 23時間
マージ済み PR(30日)
402

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

uutils/coreutils のほかの issue

uutils/coreutils の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。