Code

b4e324a5295c32af16b7fecb2164c4400f20a0fd
[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,12 @@
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 +  return (0);
49 +} /* }}} int network_init_gcrypt */
50  
51  static gcry_cipher_hd_t network_get_aes256_cypher (sockent_t *se, /* {{{ */
52      const void *iv, size_t iv_size, const char *username)
53 @@ -2077,7 +2078,12 @@
54         {
55                 if (se->data.client.security_level > SECURITY_LEVEL_NONE)
56                 {
57 -                       network_init_gcrypt ();
58 +                       if (network_init_gcrypt () < 0)
59 +                       {
60 +                               ERROR ("network plugin: Cannot configure client socket with "
61 +                                               "security: Failed to initialize crypto library.");
62 +                               return (-1);
63 +                       }
64  
65                         if ((se->data.client.username == NULL)
66                                         || (se->data.client.password == NULL))
67 @@ -2097,7 +2103,12 @@
68         {
69                 if (se->data.server.security_level > SECURITY_LEVEL_NONE)
70                 {
71 -                       network_init_gcrypt ();
72 +                       if (network_init_gcrypt () < 0)
73 +                       {
74 +                               ERROR ("network plugin: Cannot configure server socket with "
75 +                                               "security: Failed to initialize crypto library.");
76 +                               return (-1);
77 +                       }
78  
79                         if (se->data.server.auth_file == NULL)
80                         {
81 @@ -3548,7 +3559,11 @@
82         have_init = 1;
83  
84  #if HAVE_LIBGCRYPT
85 -       network_init_gcrypt ();
86 +       if (network_init_gcrypt () < 0)
87 +       {
88 +               ERROR ("network plugin: Failed to initialize crypto library.");
89 +               return (-1);
90 +       }
91  #endif
92  
93         if (network_config_stats != 0)