Skip to content

Commit

Permalink
authz-simple: Check that 'identity' property is set
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Daniel P. Berrangé <[email protected]>
  • Loading branch information
kevmw authored and berrange committed Nov 18, 2020
1 parent 3428455 commit c2aa8a3
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions authz/simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit c2aa8a3

Please sign in to comment.