Code

14b803fbf1ef95be2359c95a5a78a7641e9d93ed
[pkg-collectd.git] / debian / patches / bts832577-gcry-control.patch
1 Description: network plugin: Don't abort() if gcrypt initialization failed.
2 Author: Sebastian Harl <sh@tokkee.org>
3 Origin: upstream,
4  commit:a3000cbe3a12163148a28c818269bbdabda1cf5c
5 Bug-Debian: https://bugs.debian.org/832577
6 Last-Update: 2016-07-28
8 diff a/src/network.c b/src/network.c
9 --- a/src/network.c
10 +++ b/src/network.c
11 @@ -498,7 +498,7 @@
12  } /* }}} int network_dispatch_notification */
13  
14  #if HAVE_LIBGCRYPT
15 -static void network_init_gcrypt (void) /* {{{ */
16 +static int network_init_gcrypt (void) /* {{{ */
17  {
18    gcry_error_t err;
19  
20 @@ -506,7 +506,7 @@
21     * Because you can't know in a library whether another library has
22     * already initialized the library */
23    if (gcry_control (GCRYCTL_ANY_INITIALIZATION_P))
24 -    return;
25 +    return (0);
26  
27   /* http://www.gnupg.org/documentation/manuals/gcrypt/Multi_002dThreading.html
28    * To ensure thread-safety, it's important to set GCRYCTL_SET_THREAD_CBS
29 @@ -520,7 +520,7 @@
30    if (err)
31    {
32      ERROR ("network plugin: gcry_control (GCRYCTL_SET_THREAD_CBS) failed: %s", gcry_strerror (err));
33 -    abort ();
34 +    return (-1);
35    }
36  # endif
37  
38 @@ -530,11 +530,11 @@
39    if (err)
40    {
41      ERROR ("network plugin: gcry_control (GCRYCTL_SET_THREAD_CBS) failed: %s", gcry_strerror (err));
42 -    abort ();
43 +    return (-1);
44    }
45  
46    gcry_control (GCRYCTL_INITIALIZATION_FINISHED);
47 -} /* }}} void network_init_gcrypt */
48 +} /* }}} int network_init_gcrypt */
49  
50  static gcry_cipher_hd_t network_get_aes256_cypher (sockent_t *se, /* {{{ */
51      const void *iv, size_t iv_size, const char *username)
52 @@ -2077,7 +2077,12 @@
53         {
54                 if (se->data.client.security_level > SECURITY_LEVEL_NONE)
55                 {
56 -                       network_init_gcrypt ();
57 +                       if (network_init_gcrypt () < 0)
58 +                       {
59 +                               ERROR ("network plugin: Cannot configure client socket with "
60 +                                               "security: Failed to initialize crypto library.");
61 +                               return (-1);
62 +                       }
63  
64                         if ((se->data.client.username == NULL)
65                                         || (se->data.client.password == NULL))
66 @@ -2097,7 +2102,12 @@
67         {
68                 if (se->data.server.security_level > SECURITY_LEVEL_NONE)
69                 {
70 -                       network_init_gcrypt ();
71 +                       if (network_init_gcrypt () < 0)
72 +                       {
73 +                               ERROR ("network plugin: Cannot configure server socket with "
74 +                                               "security: Failed to initialize crypto library.");
75 +                               return (-1);
76 +                       }
77  
78                         if (se->data.server.auth_file == NULL)
79                         {
80 @@ -3548,7 +3558,11 @@
81         have_init = 1;
82  
83  #if HAVE_LIBGCRYPT
84 -       network_init_gcrypt ();
85 +       if (network_init_gcrypt () < 0)
86 +       {
87 +               ERROR ("network plugin: Failed to initialize crypto library.");
88 +               return (-1);
89 +       }
90  #endif
91  
92         if (network_config_stats != 0)