Skip to content

Commit b532fa8

Browse files
Merge pull request #1448 from alexcrichton/no-hard-links
Forbid tarballs with hard links being uploaded
2 parents ef9e704 + abb6ead commit b532fa8

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/uploaders.rs

+11
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,17 @@ fn verify_tarball(
271271
if !entry.path()?.starts_with(&prefix) {
272272
return Err(human("invalid tarball uploaded"));
273273
}
274+
275+
// Historical versions of the `tar` crate which Cargo uses internally
276+
// don't properly prevent hard links from overwriting arbitrary files on
277+
// the filesystem.
278+
//
279+
// As a bit of a hammer we reject any tarball with a hard link. Cargo
280+
// doesn't currently ever generate a tarball with a hard link so this
281+
// should work for now.
282+
if entry.header().entry_type().is_hard_link() {
283+
return Err(human("invalid tarball uploaded"));
284+
}
274285
}
275286
Ok(())
276287
}

0 commit comments

Comments
 (0)