[almanah] Bug 599598 — Segmentation fault in debian unstable



commit 79bfb759a57212d589201467581f30ec3a952d64
Author: Philip Withnall <philip tecnocode co uk>
Date:   Mon Oct 26 19:46:37 2009 +0000

    Bug 599598 â?? Segmentation fault in debian unstable
    
    Fix a crash if initialisation of libgpgme fails, and also change GPGME
    initialisation so it works for GPGME 1.2.x. Closes: bgo#599598

 configure.ac          |    2 ++
 src/storage-manager.c |   15 +++++++++++++--
 src/storage-manager.h |    3 ++-
 3 files changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 352656c..81b3995 100644
--- a/configure.ac
+++ b/configure.ac
@@ -111,6 +111,8 @@ if test $encryption = "true"; then
 		fi
 	fi
 
+	AC_DEFINE_UNQUOTED([MIN_GPGME_VERSION],"${min_gpgme_version}",[The minimum required version of GPGME])
+
 	if test $ok = "yes"; then
 		ENCRYPTION_CFLAGS="$ENCRYPTION_CFLAGS `$GPGME_CONFIG --cflags`"
 		ENCRYPTION_LIBS="$ENCRYPTION_LIBS `$GPGME_CONFIG --libs`"
diff --git a/src/storage-manager.c b/src/storage-manager.c
index f69189f..5b4c4f7 100644
--- a/src/storage-manager.c
+++ b/src/storage-manager.c
@@ -231,6 +231,14 @@ prepare_gpgme (AlmanahStorageManager *self, gboolean encrypting, CipherOperation
 {
 	gpgme_error_t error_gpgme;
 
+	/* Check for a minimum GPGME version (bgo#599598) */
+	if (gpgme_check_version (MIN_GPGME_VERSION) == NULL) {
+		g_set_error (error, ALMANAH_STORAGE_MANAGER_ERROR, ALMANAH_STORAGE_MANAGER_ERROR_BAD_VERSION,
+			     _("GPGME is not at least version %s"),
+			     MIN_GPGME_VERSION);
+		return FALSE;
+	}
+
 	/* Check OpenPGP's supported */
 	error_gpgme = gpgme_engine_check_version (GPGME_PROTOCOL_OpenPGP);
 	if (error_gpgme != GPG_ERR_NO_ERROR) {
@@ -318,8 +326,11 @@ cipher_operation_free (CipherOperation *operation)
 		g_io_channel_unref (operation->plain_io_channel);
 	}
 
-	gpgme_signers_clear (operation->context);
-	gpgme_release (operation->context);
+	/* We could free the operation before the context is even created (bgo#599598) */
+	if (operation->context != NULL) {
+		gpgme_signers_clear (operation->context);
+		gpgme_release (operation->context);
+	}
 
 	g_object_unref (operation->storage_manager);
 	g_free (operation);
diff --git a/src/storage-manager.h b/src/storage-manager.h
index 14a3cf9..de14656 100644
--- a/src/storage-manager.h
+++ b/src/storage-manager.h
@@ -54,7 +54,8 @@ typedef enum {
 	ALMANAH_STORAGE_MANAGER_ERROR_DECRYPTING,
 	ALMANAH_STORAGE_MANAGER_ERROR_ENCRYPTING,
 	ALMANAH_STORAGE_MANAGER_ERROR_GETTING_KEY,
-	ALMANAH_STORAGE_MANAGER_ERROR_RUNNING_QUERY
+	ALMANAH_STORAGE_MANAGER_ERROR_RUNNING_QUERY,
+	ALMANAH_STORAGE_MANAGER_ERROR_BAD_VERSION
 } AlmanahStorageManagerError;
 
 typedef gint (*AlmanahQueryCallback) (gpointer user_data, gint columns, gchar **data, gchar **column_names);



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