[PATCH 1/3] authz-list-file: Fix crash when filename is not set

Eduardo Habkost posted 3 patches 5 years, 1 month ago
Maintainers: Vikram Garhwal <fnu.vikram@xilinx.com>, Pavel Pisa <pisa@cmp.felk.cvut.cz>, Jason Wang <jasowang@redhat.com>
[PATCH 1/3] authz-list-file: Fix crash when filename is not set
Posted by Eduardo Habkost 5 years, 1 month ago
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 <ehabkost@redhat.com>
---
Cc: "Daniel P. Berrangé" <berrange@redhat.com>
Cc: qemu-devel@nongnu.org
---
 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) {
-- 
2.26.2


Re: [PATCH 1/3] authz-list-file: Fix crash when filename is not set
Posted by Cleber Rosa 5 years, 1 month ago
On Thu, Oct 08, 2020 at 04:27:11PM -0400, Eduardo Habkost wrote:
> 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 <ehabkost@redhat.com>
> ---
> Cc: "Daniel P. Berrangé" <berrange@redhat.com>
> Cc: qemu-devel@nongnu.org

Out of curiosity, are those notes intended for git-publish? (If so, I
didn't realize it would read them).

> ---
>  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");

Nitpick: all other similar error messages start capitalized.

- Cleber.
Re: [PATCH 1/3] authz-list-file: Fix crash when filename is not set
Posted by Daniel P. Berrangé 5 years, 1 month ago
On Thu, Oct 08, 2020 at 04:27:11PM -0400, Eduardo Habkost wrote:
> 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 <ehabkost@redhat.com>
> ---
> Cc: "Daniel P. Berrangé" <berrange@redhat.com>
> Cc: qemu-devel@nongnu.org
> ---
>  authz/listfile.c | 5 +++++
>  1 file changed, 5 insertions(+)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|


Re: [PATCH 1/3] authz-list-file: Fix crash when filename is not set
Posted by Li Qiang 5 years, 1 month ago
Eduardo Habkost <ehabkost@redhat.com> 于2020年10月9日周五 上午4:28写道:
>
> 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 <ehabkost@redhat.com>

Reviewed-by: Li Qiang <liq3ea@gmail.com>

> ---
> Cc: "Daniel P. Berrangé" <berrange@redhat.com>
> Cc: qemu-devel@nongnu.org
> ---
>  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) {
> --
> 2.26.2
>
>

Re: [PATCH 1/3] authz-list-file: Fix crash when filename is not set
Posted by Philippe Mathieu-Daudé 5 years, 1 month ago
On 10/8/20 10:27 PM, Eduardo Habkost wrote:
> 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 <ehabkost@redhat.com>
> ---
> Cc: "Daniel P. Berrangé" <berrange@redhat.com>
> Cc: qemu-devel@nongnu.org
> ---
>   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) {
> 

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>