[gnome-remote-desktop] settings: Set error if username or password is NULL



commit b17d0befe5e6d70466ac9d0110a6247499b92227
Author: Pascal Nowack <Pascal Nowack gmx de>
Date:   Wed Nov 24 17:20:51 2021 +0100

    settings: Set error if username or password is NULL
    
    When looking up the username or password for an RDP session,
    gnome-remote-desktop will parse the credentials string, returned via
    libsecret.
    This credentials string may exist, but it can contain garbage values,
    when e.g. the user changed them to such garbage values.
    In such case, the parsed username or password may be NULL, leading into
    gnome-remote-desktop to crash, as the error is not set.
    
    Fix this behaviour by always setting the GError, when the username or
    password is NULL.

 src/grd-settings.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
---
diff --git a/src/grd-settings.c b/src/grd-settings.c
index 54007a1..23b54bd 100644
--- a/src/grd-settings.c
+++ b/src/grd-settings.c
@@ -158,6 +158,12 @@ grd_settings_get_rdp_username (GrdSettings  *settings,
 
   credentials = g_variant_parse (NULL, credentials_string, NULL, NULL, NULL);
   g_variant_lookup (credentials, "username", "s", &username);
+  if (!username)
+    {
+      g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
+                   "Username not set");
+      return NULL;
+    }
 
   g_variant_unref (credentials);
   g_free (credentials_string);
@@ -190,6 +196,12 @@ grd_settings_get_rdp_password (GrdSettings  *settings,
 
   credentials = g_variant_parse (NULL, credentials_string, NULL, NULL, NULL);
   g_variant_lookup (credentials, "password", "s", &password);
+  if (!password)
+    {
+      g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
+                   "Password not set");
+      return NULL;
+    }
 
   g_variant_unref (credentials);
   g_free (credentials_string);


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