mirror of
https://github.com/NixOS/nix
synced 2025-07-02 21:51:50 +02:00
Ensure error messages don't leak private key
Since #8766, invalid base64 is rendered in errors, but we don't actually want to show this in the case of an invalid private keys. Co-Authored-By: Eelco Dolstra <edolstra@gmail.com>
This commit is contained in:
parent
d0c351bf43
commit
2b6b03d8df
10 changed files with 68 additions and 22 deletions
|
@ -245,7 +245,12 @@ Hash::Hash(std::string_view rest, HashAlgorithm algo, bool isSRI)
|
|||
}
|
||||
|
||||
else if (isSRI || rest.size() == base64Len()) {
|
||||
auto d = base64Decode(rest);
|
||||
std::string d;
|
||||
try {
|
||||
d = base64Decode(rest);
|
||||
} catch (Error & e) {
|
||||
e.addTrace({}, "While decoding hash '%s'", rest);
|
||||
}
|
||||
if (d.size() != hashSize)
|
||||
throw BadHash("invalid %s hash '%s'", isSRI ? "SRI" : "base-64", rest);
|
||||
assert(hashSize);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue