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

Đang mở Phù hợp với người mới
#16,770 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
72/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
rust
Lĩnh vực
cli

Hướng nghiên cứu

Lỗi nằm ở fill_blocks trong src/uu/dd/src/dd.rs, quanh các dòng 553-588, nơi độ dài đã đọc được so sánh với độ dài còn lại của slice. Chạy lại bước tái hiện từ issue (bs=4 count=5B conv=sync) với binary uutils và GNU dd, rồi so sánh các byte đầu ra. Hoàn thành khi phần đệm sau điểm kết thúc giữa khối là các byte NUL giống GNU dd và có một bài kiểm thử dd bao phủ trường hợp này.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Rust
Star
24.4k
Fork
2.2k
Merge trung bình
2 ngày 23 giờ
Pull request đã merge (30 ngày)
402

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của uutils/coreutils

Tất cả issue của uutils/coreutils

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.