mirror of
https://github.com/NixOS/nix.git
synced 2024-11-21 14:22:29 +00:00
Detect NAR directory entries that collide with another path after case-hacking
The test was made by @puckipedia.
This commit is contained in:
parent
77c090cdbd
commit
3557587381
@ -243,6 +243,9 @@ static void parse(FileSystemObjectSink & sink, Source & source, const CanonPath
|
||||
debug("case collision between '%1%' and '%2%'", i->first, name);
|
||||
name += caseHackSuffix;
|
||||
name += std::to_string(++i->second);
|
||||
auto j = names.find(name);
|
||||
if (j != names.end())
|
||||
throw Error("NAR contains file name '%s' that collides with case-hacked file name '%s'", prevName, j->first);
|
||||
} else
|
||||
names[name] = 0;
|
||||
}
|
||||
|
BIN
tests/functional/case-collision.nar
Normal file
BIN
tests/functional/case-collision.nar
Normal file
Binary file not shown.
@ -37,3 +37,9 @@ cmp case.nar "$TEST_ROOT/case.nar"
|
||||
# removal of the suffix).
|
||||
touch "$TEST_ROOT/case/xt_CONNMARK.h~nix~case~hack~3"
|
||||
(! nix-store "${opts[@]}" --dump "$TEST_ROOT/case" > /dev/null)
|
||||
|
||||
# Detect NARs that have a directory entry that after case-hacking
|
||||
# collides with another entry (e.g. a directory containing 'Test',
|
||||
# 'Test~nix~case~hack~1' and 'test').
|
||||
rm -rf "$TEST_ROOT/case"
|
||||
expectStderr 1 nix-store "${opts[@]}" --restore "$TEST_ROOT/case" < case-collision.nar | grepQuiet "NAR contains file name 'test' that collides with case-hacked file name 'Test~nix~case~hack~1'"
|
||||
|
Loading…
Reference in New Issue
Block a user