397dc2
From fa5b4100c32d3125eeb0d6b0024892af86ecddb0 Mon Sep 17 00:00:00 2001
397dc2
Message-Id: <fa5b4100c32d3125eeb0d6b0024892af86ecddb0@dist-git>
397dc2
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
397dc2
Date: Tue, 29 Sep 2020 14:43:03 +0200
397dc2
Subject: [PATCH] rpc: gendispatch: handle empty flags
397dc2
MIME-Version: 1.0
397dc2
Content-Type: text/plain; charset=UTF-8
397dc2
Content-Transfer-Encoding: 8bit
397dc2
397dc2
CVE-2020-25637
397dc2
397dc2
Prepare for omission of the <flagname> in remote_protocol.x
397dc2
@acl annotations:
397dc2
 @acl: <object>:<permission>:<flagname>
397dc2
so that we can add more fields after, e.g.:
397dc2
 @acl: <object>:<permission>::<field>
397dc2
397dc2
Signed-off-by: Ján Tomko <jtomko@redhat.com>
397dc2
(cherry picked from commit 955029bd0ad7ef96000f529ac38204a8f4a96401)
397dc2
Signed-off-by: Ján Tomko <jtomko@redhat.com>
397dc2
Message-Id: <5fda9fc6cfe45eace10b8c2565a8b0c46b51f46c.1601383236.git.jtomko@redhat.com>
397dc2
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
397dc2
---
397dc2
 src/rpc/gendispatch.pl | 4 ++--
397dc2
 1 file changed, 2 insertions(+), 2 deletions(-)
397dc2
397dc2
diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl
397dc2
index 8656c8f205..4cb9701e59 100755
397dc2
--- a/src/rpc/gendispatch.pl
397dc2
+++ b/src/rpc/gendispatch.pl
397dc2
@@ -2112,7 +2112,7 @@ elsif ($mode eq "client") {
397dc2
                 if ($acl[$i]->{object} ne $acl[0]->{object}) {
397dc2
                     die "acl for '$call->{ProcName}' cannot check different objects";
397dc2
                 }
397dc2
-                if (defined $acl[$i]->{flags}) {
397dc2
+                if (defined $acl[$i]->{flags} && length $acl[$i]->{flags}) {
397dc2
                     $checkflags = 1;
397dc2
                 }
397dc2
             }
397dc2
@@ -2200,7 +2200,7 @@ elsif ($mode eq "client") {
397dc2
                     my $method = "virAccessManagerCheck" . $object;
397dc2
                     my $space = ' ' x length($method);
397dc2
                     print "    if (";
397dc2
-                    if (defined $acl->{flags}) {
397dc2
+                    if (defined $acl->{flags} && length $acl->{flags}) {
397dc2
                         my $flags = $acl->{flags};
397dc2
                         if ($flags =~ /^\!/) {
397dc2
                             $flags = substr $flags, 1;
397dc2
-- 
397dc2
2.28.0
397dc2