about summary refs log tree commit diff
path: root/tvix/nix-compat/src/store_path
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/nix-compat/src/store_path')
-rw-r--r--tvix/nix-compat/src/store_path/mod.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/tvix/nix-compat/src/store_path/mod.rs b/tvix/nix-compat/src/store_path/mod.rs
index 781e32932563..0ed6b2ba0754 100644
--- a/tvix/nix-compat/src/store_path/mod.rs
+++ b/tvix/nix-compat/src/store_path/mod.rs
@@ -151,6 +151,16 @@ impl StorePath {
 /// Checks a given &[u8] to match the restrictions for store path names, and
 /// returns the name as string if successful.
 pub(crate) fn validate_name(s: &[u8]) -> Result<String, Error> {
+    // Empty names are not allowed.
+    if s.is_empty() {
+        return Err(Error::InvalidLength());
+    }
+
+    // First character cannot be a period
+    if s[0] == b'.' {
+        return Err(Error::InvalidName(s.to_vec(), 0));
+    }
+
     for (i, c) in s.iter().enumerate() {
         if c.is_ascii_alphanumeric()
             || *c == b'-'