rust/src
Laurence Tratt 2c44195895 Make temporary directory names non-deterministic.
The previous scheme made it possible for another user/attacker to cause the
temporary directory creation scheme to panic. All you needed to know was the pid
of the process you wanted to target ('other_pid') and the suffix it was using
(let's pretend it's 'sfx') and then code such as this would, in essence, DOS it:

    for i in range(0u, 1001) {
        let tp = &Path::new(format!("/tmp/rs-{}-{}-sfx", other_pid, i));
        match fs::mkdir(tp, io::USER_RWX) { _ => () }
    }

Since the scheme retried only 1000 times to create a temporary directory before
dying, the next time the attacked process called TempDir::new("sfx") after that
would typically cause a panic. Of course, you don't necessarily need an attacker
to cause such a DOS: creating 1000 temporary directories without closing any of
the previous would be enough to DOS yourself.

This patch broadly follows the OpenBSD implementation of mkstemp. It uses the
operating system's random number generator to produce random directory names
that are impractical to guess (and, just in case someone manages to do that, it
retries creating the directory for a long time before giving up; OpenBSD
retries INT_MAX times, although 1<<31 seems enough to thwart even the most
patient attacker).

As a small additional change, this patch also makes the argument that
TempDir::new takes a prefix rather than a suffix. This is because 1) it more
closely matches what mkstemp and friends do 2) if you're going to have a
deterministic part of a filename, you really want it at the beginning so that
shell completion is useful.
2015-01-05 10:19:19 +00:00
..
compiler-rt@62a4ca6055
compiletest Remove deprecated functionality 2015-01-03 23:43:57 -08:00
doc Merge pull request #20520 from nhowell/patch-1 2015-01-04 21:36:41 +00:00
driver Separate the driver into its own crate that uses trans, typeck. 2014-12-04 10:04:52 -05:00
etc Merge pull request #20452 from brson/rustup 2015-01-04 21:36:35 +00:00
grammar Remove deprecated functionality 2015-01-03 23:43:57 -08:00
jemalloc@b001609960 update jemalloc 2014-10-05 22:17:25 -04:00
liballoc auto merge of #20393 : japaric/rust/impl-any, r=aturon 2015-01-04 11:01:04 +00:00
libarena sed -i -s 's/#\[deriving(/#\[derive(/g' **/*.rs 2015-01-03 22:54:18 -05:00
libbacktrace
libcollections auto merge of #20395 : huonw/rust/char-stab-2, r=aturon 2015-01-05 06:45:39 +00:00
libcore char: small tweak since is_some > equivalent match. 2015-01-05 12:30:51 +11:00
libcoretest Remove deprecated functionality 2015-01-03 23:43:57 -08:00
libflate Rename TaskRng to ThreadRng 2014-12-28 13:46:35 +02:00
libfmt_macros sed -i -s 's/#\[deriving(/#\[derive(/g' **/*.rs 2015-01-03 22:54:18 -05:00
libgetopts sed -i -s 's/#\[deriving(/#\[derive(/g' **/*.rs 2015-01-03 22:54:18 -05:00
libgraphviz Merge pull request #20457 from frewsxcv/rm-reexports 2015-01-04 21:36:36 +00:00
liblibc sed -i -s 's/#\[deriving(/#\[derive(/g' **/*.rs 2015-01-03 22:54:18 -05:00
liblog sed -i -s 's/#\[deriving(/#\[derive(/g' **/*.rs 2015-01-03 22:54:18 -05:00
librand Remove deprecated functionality 2015-01-03 23:43:57 -08:00
librbml Remove deprecated functionality 2015-01-03 23:43:57 -08:00
libregex Remove deprecated functionality 2015-01-03 23:43:57 -08:00
librustc auto merge of #20285 : FlaPer87/rust/oibit-send-and-friends, r=nikomatsakis 2015-01-05 04:20:46 +00:00
librustc_back sed -i -s 's/#\[deriving(/#\[derive(/g' **/*.rs 2015-01-03 22:54:18 -05:00
librustc_borrowck Merge pull request #20457 from frewsxcv/rm-reexports 2015-01-04 21:36:36 +00:00
librustc_driver auto merge of #20393 : japaric/rust/impl-any, r=aturon 2015-01-04 11:01:04 +00:00
librustc_llvm sed -i -s 's/#\[deriving(/#\[derive(/g' **/*.rs 2015-01-03 22:54:18 -05:00
librustc_resolve auto merge of #20285 : FlaPer87/rust/oibit-send-and-friends, r=nikomatsakis 2015-01-05 04:20:46 +00:00
librustc_trans auto merge of #20285 : FlaPer87/rust/oibit-send-and-friends, r=nikomatsakis 2015-01-05 04:20:46 +00:00
librustc_typeck auto merge of #20285 : FlaPer87/rust/oibit-send-and-friends, r=nikomatsakis 2015-01-05 04:20:46 +00:00
librustdoc auto merge of #20395 : huonw/rust/char-stab-2, r=aturon 2015-01-05 06:45:39 +00:00
libserialize Remove deprecated functionality 2015-01-03 23:43:57 -08:00
libstd Make temporary directory names non-deterministic. 2015-01-05 10:19:19 +00:00
libsyntax auto merge of #20285 : FlaPer87/rust/oibit-send-and-friends, r=nikomatsakis 2015-01-05 04:20:46 +00:00
libterm sed -i -s 's/#\[deriving(/#\[derive(/g' **/*.rs 2015-01-03 22:54:18 -05:00
libtest [breaking change] Update entry API as part of RFC 509. 2015-01-04 15:55:54 -05:00
libunicode Apply explicit stabilities to unicode parts of CharExt. 2015-01-05 12:30:51 +11:00
llvm@ec1fdb3b9d Update LLVM to get slightly better memcpy elision 2014-10-17 17:16:18 +02:00
rt Initial version of AArch64 support. 2015-01-03 15:16:10 +00:00
rust-installer@3a37981744 Fallout from stabilization 2014-12-30 17:06:08 -08:00
rustllvm Initial version of AArch64 support. 2015-01-03 15:16:10 +00:00
test Make temporary directory names non-deterministic. 2015-01-05 10:19:19 +00:00
snapshots.txt Register new snapshots 2015-01-03 09:34:05 -05:00