[seahorse] Bug 604494: Don't use fixed MAXPATHLEN size buffers



commit b497a91cfeea3d24eab10e39ba6485754c92717f
Author: Emilio Pozuelo Monfort <pochu27 gmail com>
Date:   Mon Dec 14 16:18:02 2009 +0100

    Bug 604494: Don't use fixed MAXPATHLEN size buffers
    
    Use dynamic allocation instead, since MAXPATHLEN may not be
    defined on some platforms. Fixes the build on GNU/Hurd.

 pgp/seahorse-gpg-options.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/pgp/seahorse-gpg-options.c b/pgp/seahorse-gpg-options.c
index 2731e9e..9a37d9b 100644
--- a/pgp/seahorse-gpg-options.c
+++ b/pgp/seahorse-gpg-options.c
@@ -43,7 +43,7 @@
 #define  GPG_VERSION_PREFIX1   "1."
 #define  GPG_VERSION_PREFIX2   "2."
 
-static gchar gpg_homedir[MAXPATHLEN];
+static gchar *gpg_homedir;
 static gboolean gpg_options_inited = FALSE;
 
 static gboolean
@@ -77,6 +77,9 @@ find_config_file (gboolean read, GError **err)
     g_assert (gpg_options_inited);
     g_assert (!err || !*err);
 
+    if (!gpg_homedir)
+        return NULL;
+
     /* Check for and open ~/.gnupg/gpg.conf */
     conf = g_strconcat (gpg_homedir, "/gpg.conf", NULL);
     if (g_file_test (conf, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_EXISTS)) 
@@ -208,16 +211,14 @@ parse_home_directory (gpgme_engine_info_t engine, GError **err)
                     *x = 0;
                     g_strstrip (t);
 
-                    gpg_homedir[0] = 0;
+                    g_free (gpg_homedir);
 
                     /* If it's not a rooted path then expand */
                     if (t[0] == '~') {
-                        g_strlcpy (gpg_homedir, g_get_home_dir (),
-                                   sizeof (gpg_homedir));
-                        t++;
+                        gpg_homedir = g_strconcat (g_get_home_dir(), ++t);
+                    } else {
+                        gpg_homedir = g_strdup (t);
                     }
-
-                    g_strlcat (gpg_homedir, t, sizeof (gpg_homedir));
                     found = TRUE;
                 }
             }



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