[gnome-remote-desktop] settings: Don't crash, when parsing the credentials string fails



commit 7b71c11b26206fc90ed41bad9ee88cfd518c9c51
Author: Pascal Nowack <Pascal Nowack gmx de>
Date:   Sat Apr 23 10:26:41 2022 +0200

    settings: Don't crash, when parsing the credentials string fails
    
    When parsing the credential string fails, g_variant_parse() returns
    NULL and g_variant_lookup() is not NULL-safe, resulting into a crash of
    gnome-remote-desktop.
    
    To fix this issue, set the error and return NULL, when the parsed
    credentials are NULL.
    
    Fixes: https://errors.ubuntu.com/problem/67e9c08fb049d25a21212bccc4c8bc41e5ed8516

 src/grd-settings.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
---
diff --git a/src/grd-settings.c b/src/grd-settings.c
index c8f28fb4..dad5d570 100644
--- a/src/grd-settings.c
+++ b/src/grd-settings.c
@@ -142,6 +142,13 @@ grd_settings_get_rdp_username (GrdSettings  *settings,
     }
 
   credentials = g_variant_parse (NULL, credentials_string, NULL, NULL, NULL);
+  if (!credentials)
+    {
+      g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
+                   "Unable to parse credentials");
+      return NULL;
+    }
+
   g_variant_lookup (credentials, "username", "s", &username);
   if (!username)
     {
@@ -177,6 +184,13 @@ grd_settings_get_rdp_password (GrdSettings  *settings,
     }
 
   credentials = g_variant_parse (NULL, credentials_string, NULL, NULL, NULL);
+  if (!credentials)
+    {
+      g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
+                   "Unable to parse credentials");
+      return NULL;
+    }
+
   g_variant_lookup (credentials, "password", "s", &password);
   if (!password)
     {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]