fix(3p/nix): fix usage error of absl::Base64Unescape
The source and destination strings cannot be the same string - absl will write to the destination in a streaming manner, causing the source to become invalid. Change-Id: I3578cf1f8789a51d85e0950f7987c398f0a00953 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1659 Tested-by: BuildkiteCI Reviewed-by: glittershark <grfn@gws.fyi>
This commit is contained in:
parent
f10d60a454
commit
f9df9b4733
1 changed files with 4 additions and 3 deletions
7
third_party/nix/src/libstore/crypto.cc
vendored
7
third_party/nix/src/libstore/crypto.cc
vendored
|
@ -11,6 +11,7 @@
|
|||
|
||||
namespace nix {
|
||||
|
||||
// TODO(riking): convert to string_view to reduce allocations
|
||||
static std::pair<std::string, std::string> split(const std::string& s) {
|
||||
size_t colon = s.find(':');
|
||||
if (colon == std::string::npos || colon == 0) {
|
||||
|
@ -23,13 +24,13 @@ Key::Key(const std::string& s) {
|
|||
auto ss = split(s);
|
||||
|
||||
name = ss.first;
|
||||
key = ss.second;
|
||||
std::string keyb64 = ss.second;
|
||||
|
||||
if (name.empty() || key.empty()) {
|
||||
if (name.empty() || keyb64.empty()) {
|
||||
throw Error("secret key is corrupt");
|
||||
}
|
||||
|
||||
if (!absl::Base64Unescape(key, &key)) {
|
||||
if (!absl::Base64Unescape(keyb64, &key)) {
|
||||
// TODO(grfn): replace this with StatusOr
|
||||
throw Error("Invalid Base64");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue