From 14b394853606ab79f1d71f3bbbb4ccaab6538c8f Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Thu, 8 Oct 2020 16:27:11 -0400 Subject: [PATCH] authz-list-file: Fix crash when filename is not set MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix the following crash: $ qemu-system-x86_64 -object authz-list-file,id=obj0 qemu-system-x86_64: -object authz-list-file,id=obj0: GLib: g_file_get_contents: assertion 'filename != NULL' failed Segmentation fault (core dumped) Signed-off-by: Eduardo Habkost Reviewed-by: Daniel P. Berrangé Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Li Qiang Message-Id: <20201008202713.1416823-2-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- authz/listfile.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/authz/listfile.c b/authz/listfile.c index cd6163aa40..aaf930453d 100644 --- a/authz/listfile.c +++ b/authz/listfile.c @@ -122,6 +122,11 @@ qauthz_list_file_complete(UserCreatable *uc, Error **errp) QAuthZListFile *fauthz = QAUTHZ_LIST_FILE(uc); gchar *dir = NULL, *file = NULL; + if (!fauthz->filename) { + error_setg(errp, "filename not provided"); + return; + } + fauthz->list = qauthz_list_file_load(fauthz, errp); if (!fauthz->refresh) {