mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-15 02:36:16 +02: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
3 changed files with 9 additions and 0 deletions
|
@ -243,6 +243,9 @@ static void parse(FileSystemObjectSink & sink, Source & source, const CanonPath
|
||||||
debug("case collision between '%1%' and '%2%'", i->first, name);
|
debug("case collision between '%1%' and '%2%'", i->first, name);
|
||||||
name += caseHackSuffix;
|
name += caseHackSuffix;
|
||||||
name += std::to_string(++i->second);
|
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
|
} else
|
||||||
names[name] = 0;
|
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).
|
# removal of the suffix).
|
||||||
touch "$TEST_ROOT/case/xt_CONNMARK.h~nix~case~hack~3"
|
touch "$TEST_ROOT/case/xt_CONNMARK.h~nix~case~hack~3"
|
||||||
(! nix-store "${opts[@]}" --dump "$TEST_ROOT/case" > /dev/null)
|
(! 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 a new issue