-
Notifications
You must be signed in to change notification settings - Fork 2.9k
cargo package does not truncate old file content #16683
Copy link
Copy link
Closed
Labels
C-bugCategory: bugCategory: bugS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or reviewStatus: Issue or feature is accepted, and has a team member available to help mentor or reviewregression-from-stable-to-stableRegression in stable that worked in a previous stable release.Regression in stable that worked in a previous stable release.
Metadata
Metadata
Assignees
Labels
C-bugCategory: bugCategory: bugS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or reviewStatus: Issue or feature is accepted, and has a team member available to help mentor or reviewregression-from-stable-to-stableRegression in stable that worked in a previous stable release.Regression in stable that worked in a previous stable release.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Problem
cargo packagedoesn't truncate any existing file content when writing a.cratefile. If the new content of the file is shorter than the existing content then it will have trailing garbage.Steps
Possible Solution(s)
I'm guessing this is the relevant part of the code:
cargo/src/cargo/ops/cargo_package/mod.rs
Lines 223 to 225 in c63475b
cargo/src/cargo/util/flock.rs
Lines 239 to 241 in c63475b
It could open the file with
truncate(true)or callset_len()either before or after writing.Another part of the same module does call
set_len(0)before writing:cargo/src/cargo/ops/cargo_package/mod.rs
Line 175 in c63475b
Notes
There could be other features with the same problem, this is just the case that I hit.
Version