Package: frogr / 0.10-2

fix-gcrypt-crash.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
From: Mario Sanchez Prada <msanchez@gnome.org>
Subject: Fix initialization of gcrypt to avoid crashes
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=732475
Origin: https://git.gnome.org/browse/frogr/commit/?id=d7f4e944aa691244e57a8fcc8f4f0e5f91da8686
Index: frogr/src/flicksoup/fsp-session.c
===================================================================
--- frogr.orig/src/flicksoup/fsp-session.c
+++ frogr/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
   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 ();