diff options
author | Joey Hess <joeyh@joeyh.name> | 2019-01-09 11:13:54 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2019-01-09 11:13:54 -0400 |
commit | c8086c5f8803cef57b3e6bad30f25d6544b618c2 (patch) | |
tree | e228415126ca03edfa4ff80309f6f04876db6c72 | |
parent | d63bb12bb6c354d15e57e4642dee3d143bb78895 (diff) | |
download | moreutils-c8086c5f8803cef57b3e6bad30f25d6544b618c2.tar.gz |
sponge: Fix bug in -a mode that doubled original content of file
Occurred when the temp file is located on a different filesystem.
It seems that append mode was put in on that file open without realizing
the consequences of it. Bug has been present since the first -a patch.
This commit was sponsored by Peter on Patreon.
-rw-r--r-- | debian/changelog | 2 | ||||
-rw-r--r-- | sponge.c | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/debian/changelog b/debian/changelog index 3a62905..f933dc7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,8 @@ moreutils (0.63) UNRELEASED; urgency=medium Thanks, Stig Palmquist. * ts: Fix ts -m %.s to not output negative microseconds. Thanks, Dima Kogan + * sponge: Fix bug in -a mode that doubled original content of file when + the temp file is located on a different filesystem. -- Joey Hess <id@joeyh.name> Wed, 22 Aug 2018 21:00:58 -0400 @@ -372,7 +372,7 @@ int main (int argc, char **argv) { } else { /* Fall back to slow copy. */ - outfile = fopen(outname, append ? "a" : "w"); + outfile = fopen(outname, "w"); if (!outfile) { perror("error opening output file"); exit(1); |