[frogr] Fix initialization of gcrypt to avoid crashes if other libraries fail to do it so
- From: Mario Sanchez Prada <msanchez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [frogr] Fix initialization of gcrypt to avoid crashes if other libraries fail to do it so
- Date: Mon, 8 Sep 2014 08:40:01 +0000 (UTC)
commit d7f4e944aa691244e57a8fcc8f4f0e5f91da8686
Author: Mario Sanchez Prada <msanchez gnome org>
Date: Sun Sep 7 02:21:15 2014 +0100
Fix initialization of gcrypt to avoid crashes if other libraries fail to do it so
https://bugzilla.gnome.org/show_bug.cgi?id=732475
src/flicksoup/fsp-session.c | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/src/flicksoup/fsp-session.c b/src/flicksoup/fsp-session.c
index c2fe07f..57a6613 100644
--- a/src/flicksoup/fsp-session.c
+++ b/src/flicksoup/fsp-session.c
@@ -26,11 +26,16 @@
#include "fsp-session.h"
#include <config.h>
+#include <errno.h>
#include <gcrypt.h>
#include <libsoup/soup.h>
+#include <pthread.h>
#include <stdarg.h>
#include <string.h>
+/* We need this macro defined to properly initialize gcrypt */
+GCRY_THREAD_OPTION_PTHREAD_IMPL;
+
#define FLICKR_API_BASE_URL "https://api.flickr.com/services/rest"
#define FLICKR_API_UPLOAD_URL "https://up.flickr.com/services/upload"
#define FLICKR_REQUEST_TOKEN_OAUTH_URL "https://www.flickr.com/services/oauth/request_token"
@@ -492,6 +497,16 @@ fsp_session_init (FspSession *self)
self->priv->using_default_proxy = TRUE;
self->priv->proxy_uri = NULL;
+ /* Apparently, we need to initialize gcrypt not to get a crash:
+ http://lists.gnupg.org/pipermail/gcrypt-devel/2003-August/000458.html */
+ if (!gcry_control (GCRYCTL_ANY_INITIALIZATION_P))
+ {
+ gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
+ gcry_check_version (NULL);
+ gcry_control (GCRYCTL_INIT_SECMEM, 32768);
+ gcry_control (GCRYCTL_INITIALIZATION_FINISHED);
+ }
+
#ifdef SOUP_VERSION_2_42
/* soup_session_async_new() deprecated in lisoup 2.42 */
self->priv->soup_session = soup_session_new ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]