]> git.proxmox.com Git - pve-container.git/commitdiff
add check for newlines before writing configuration
authorDietmar Maurer <dietmar@proxmox.com>
Fri, 18 Sep 2015 09:01:42 +0000 (11:01 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Fri, 18 Sep 2015 09:01:42 +0000 (11:01 +0200)
src/PVE/LXC.pm

index 4b4dd2d5398d04e3833fd176734969f7c66f7018..ae8342b0acb5ba0e5f085e3c5f6dbcd8a956f172 100644 (file)
@@ -292,7 +292,9 @@ sub write_pct_config {
        foreach my $key (sort keys %$conf) {
            next if $key eq 'digest' || $key eq 'description' || $key eq 'pending' || 
                $key eq 'snapshots' || $key eq 'snapname' || $key eq 'lxc';
-           $raw .= "$key: $conf->{$key}\n";
+           my $value = $conf->{$key};
+           die "detected invalid newline inside property '$key'\n" if $value =~ m/\n/;
+           $raw .= "$key: $value\n";
        }
 
        if (my $lxcconf = $conf->{lxc}) {
@@ -387,7 +389,7 @@ sub parse_pct_config {
            next;
        }
 
-       if ($line =~ m/^(lxc\.[a-z0-9_\.]+)(:|\s*=)\s*(.*?)\s*$/) {
+       if ($line =~ m/^(lxc\.[a-z0-9_\-\.]+)(:|\s*=)\s*(.*?)\s*$/) {
            my $key = $1;
            my $value = $3;
            if ($valid_lxc_conf_keys->{$key} || $key =~ m/^lxc\.cgroup\./) {