[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH for-5.2? 2/2] authz-simple: Check that 'identity' property is set
From: |
Kevin Wolf |
Subject: |
[PATCH for-5.2? 2/2] authz-simple: Check that 'identity' property is set |
Date: |
Tue, 17 Nov 2020 17:30:45 +0100 |
If the 'identify' property is not set, we'll pass a NULL pointer to
g_str_equal() and crash. Catch the error condition during the creation
of the object.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
authz/simple.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/authz/simple.c b/authz/simple.c
index 18db0355f4..0597dcd8ea 100644
--- a/authz/simple.c
+++ b/authz/simple.c
@@ -65,11 +65,25 @@ qauthz_simple_finalize(Object *obj)
}
+static void
+qauthz_simple_complete(UserCreatable *uc, Error **errp)
+{
+ QAuthZSimple *sauthz = QAUTHZ_SIMPLE(uc);
+
+ if (!sauthz->identity) {
+ error_setg(errp, "The 'identity' property must be set");
+ return;
+ }
+}
+
+
static void
qauthz_simple_class_init(ObjectClass *oc, void *data)
{
QAuthZClass *authz = QAUTHZ_CLASS(oc);
+ UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc);
+ ucc->complete = qauthz_simple_complete;
authz->is_allowed = qauthz_simple_is_allowed;
object_class_property_add_str(oc, "identity",
--
2.28.0