5
0
mirror of git://git.proxmox.com/git/pve-storage.git synced 2025-01-24 02:04:13 +03:00

content path overrides: allow single dots and enforce max-lengths

Allow a dot as long as its not followed by another dot and enforce
max component and (a reduced) max path length checking already at
schema level.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2023-03-20 15:11:40 +01:00
parent a3c30c6871
commit 13e1af437a

View File

@ -355,8 +355,14 @@ PVE::JSONSchema::register_format('pve-dir-override', \&verify_dir_override);
sub verify_dir_override {
my ($value, $noerr) = @_;
if ($value =~ m/^([a-z]+)=[^.]+$/ && verify_content($1, $noerr)) {
return $value;
if ($value =~ m/^([a-z]+)=([^.]*(?:\.?[^.]+)+)$/) {
my ($content_type, $relative_path) = ($1, $2);
if (verify_content($content_type, $noerr)) {
# linux has 4k max-path, but limit total length to lower as its concat'd for full path
if (length($relative_path) < 1023 && !(grep { length($_) >= 255 } split('/', $relative_path))) {
return $value;
}
}
}
return undef if $noerr;