[gnome-notes] own-cloud-provider: Guard against possible NULL dereferences



commit cf72a78d55ad5ace1f30cc4860528c428f9d7ff7
Author: Mohammed Sadiq <sadiq sadiqpk org>
Date:   Fri Jul 27 19:50:21 2018 +0530

    own-cloud-provider: Guard against possible NULL dereferences
    
    goa_account_get_presentation_identity() may return NULL.
    Also, g_strsplit() returns a NULL vector, at minimum, for any valid string.
    So here, identity, as returned by g_strsplit() will always be non NULL.
    And we have to check for identity[0].
    
    Also, free identity right in such cases.

 src/libbiji/provider/biji-own-cloud-provider.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
---
diff --git a/src/libbiji/provider/biji-own-cloud-provider.c b/src/libbiji/provider/biji-own-cloud-provider.c
index e4b6d91..34df299 100644
--- a/src/libbiji/provider/biji-own-cloud-provider.c
+++ b/src/libbiji/provider/biji-own-cloud-provider.c
@@ -774,19 +774,25 @@ biji_own_cloud_provider_constructed (GObject *obj)
 
   if (self->account != NULL)
   {
+    const gchar *presentation_identity;
 
     self->info.unique_id = goa_account_get_id (self->account);
     self->info.datasource = g_strdup_printf ("gn:goa-account:%s",
                                              self->info.unique_id);
     self->info.name = g_strdup (goa_account_get_provider_name (self->account));
 
-    identity = g_strsplit (goa_account_get_presentation_identity (self->account),
-                           "@", 2);
-    if (identity)
+    presentation_identity = goa_account_get_presentation_identity (self->account);
+
+    if (presentation_identity)
       {
-        self->info.user = g_strdup (identity[0]);
-        if (identity[1])
-          self->info.domain = g_strdup (identity[1]);
+        identity = g_strsplit (presentation_identity, "@", 2);
+
+        if (identity[0])
+          {
+            self->info.user = g_strdup (identity[0]);
+            if (identity[1])
+              self->info.domain = g_strdup (identity[1]);
+          }
 
         g_strfreev(identity);
       }


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