diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2019-12-04 00:31:09 +0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2019-12-04 00:31:09 +0100 |
commit | c3c23a52ee1c5844343bc5ed075791ec7fec6413 (patch) | |
tree | baf65223d87d2a5a5030f88208ceebab790624da /src/libstore/store-api.cc | |
parent | e721f99817bb7154d8098c902e25f84521a90b7f (diff) | |
parent | c1d18050b4cfed9eba68d4d21b397c6cce035e37 (diff) |
Merge remote-tracking branch 'origin/master' into flakes
Diffstat (limited to 'src/libstore/store-api.cc')
-rw-r--r-- | src/libstore/store-api.cc | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index ea91bf20e..f134f7967 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -90,17 +90,22 @@ void checkStoreName(const string & name) "Path names are alphanumeric and can include the symbols %1% " "and must not begin with a period. " "Note: If '%2%' is a source file and you cannot rename it on " - "disk, builtins.path { name = ... } can be used to give it an " + "disk, 'builtins.path { name = ... }' can be used to give it an " "alternative name.") % validChars % name; + if (name.empty()) + throw Error(baseError % "it is an empty string"); + /* Disallow names starting with a dot for possible security reasons (e.g., "." and ".."). */ - if (string(name, 0, 1) == ".") + if (name[0] == '.') throw Error(baseError % "it is illegal to start the name with a period"); + /* Disallow names longer than 211 characters. ext4’s max is 256, but we need extra space for the hash and .chroot extensions. */ if (name.length() > 211) throw Error(baseError % "name must be less than 212 characters"); + for (auto & i : name) if (!((i >= 'A' && i <= 'Z') || (i >= 'a' && i <= 'z') || @@ -211,7 +216,7 @@ static std::string makeType(string && type, const PathSet & references) type += ":"; type += i; } - return type; + return std::move(type); } |