-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dd: writes null bytes to device if stdout is redirect to device #3542
Labels
Comments
jhscheer
changed the title
dd: seek does not respect device size if stdout is a redirect to device
dd: writes null bytes to device if stdout is redirect to device
May 18, 2022
Thank you for creating a new issue 👍 |
jfinkels
added a commit
to jfinkels/coreutils
that referenced
this issue
Aug 27, 2022
Fix a bug in `dd` where null bytes would be unintentionally written if stdout were redirected to a seekable file. For example, before this commit, if `dd` were invoked from the command-line as dd if=infile bs=1 count=10 seek=5 > /dev/sda1 then five zeros would be written to `/dev/sda1` before copying ten bytes of `infile` to `/dev/sda1`. After this commit, `dd` will correctly seek five bytes forward in `/dev/sda1` before copying the ten bytes of `infile`. Fixes uutils#3542.
jfinkels
added a commit
to jfinkels/coreutils
that referenced
this issue
Aug 27, 2022
Fix a bug in `dd` where null bytes would be unintentionally written if stdout were redirected to a seekable file. For example, before this commit, if `dd` were invoked from the command-line as dd if=infile bs=1 count=10 seek=5 > /dev/sda1 then five zeros would be written to `/dev/sda1` before copying ten bytes of `infile` to `/dev/sda1`. After this commit, `dd` will correctly seek five bytes forward in `/dev/sda1` before copying the ten bytes of `infile`. Fixes uutils#3542.
sylvestre
pushed a commit
to jfinkels/coreutils
that referenced
this issue
Sep 5, 2022
Fix a bug in `dd` where null bytes would be unintentionally written if stdout were redirected to a seekable file. For example, before this commit, if `dd` were invoked from the command-line as dd if=infile bs=1 count=10 seek=5 > /dev/sda1 then five zeros would be written to `/dev/sda1` before copying ten bytes of `infile` to `/dev/sda1`. After this commit, `dd` will correctly seek five bytes forward in `/dev/sda1` before copying the ten bytes of `infile`. Fixes uutils#3542.
sylvestre
pushed a commit
that referenced
this issue
Sep 18, 2022
* dd: move argument parsing outside of Input, Output Move the argument parsing code out of the `Input::new()` and `Output::new()` functions and into the calling code. This allows the calling code to make decisions about how to instantiate the `Input` and `Output` objects if necessary. * dd: handle stdout redirected to seekable file Fix a bug in `dd` where null bytes would be unintentionally written if stdout were redirected to a seekable file. For example, before this commit, if `dd` were invoked from the command-line as dd if=infile bs=1 count=10 seek=5 > /dev/sda1 then five zeros would be written to `/dev/sda1` before copying ten bytes of `infile` to `/dev/sda1`. After this commit, `dd` will correctly seek five bytes forward in `/dev/sda1` before copying the ten bytes of `infile`. Fixes #3542.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@jfinkels I took the liberty to open a new issue with a summary for all the findings you published in #3447
gnu/tests/dd/skip-seek-past-dev.sh
runsand expects
$?
=1 and stderr=dd: 'standard output': cannot seek: Invalid argument
.However, uu_tail does not check if
stdout
is a redirect to a seekable device and then writes null bytes to$device
!coreutils/src/uu/dd/src/dd.rs
Lines 301 to 309 in d894847
possible fix
Haven't looked into it much but a possible fix could be to get the redirect for
/dev/stdout
similar to this:coreutils/src/uu/stat/src/stat.rs
Lines 558 to 562 in d894847
and then apply the seek checks for the new path.
The text was updated successfully, but these errors were encountered: