Upstream refresh for v1.5.0-rc1 : Upstream 19.07 : 4fb6b8c553f692eeb5bcb203e0f8ee8df0...
[librecmc/librecmc.git] / package / network / services / tinc / patches / 020-Fix-compilation-without-deprecated-OpenSSL-APIs.patch
1 From 5e0e401dc69b9c25e5f85de7484a70ea97862e16 Mon Sep 17 00:00:00 2001
2 From: Rosen Penev <rosenp@gmail.com>
3 Date: Wed, 12 Dec 2018 13:45:59 -0800
4 Subject: [PATCH 2/2] Fix compilation without deprecated OpenSSL APIs
5
6 This is an optional part of OpenWrt designed to save space.
7 ---
8  src/connection.c | 4 ++--
9  src/connection.h | 4 ++++
10  src/net_setup.c  | 1 +
11  src/tincd.c      | 5 +++++
12  4 files changed, 12 insertions(+), 2 deletions(-)
13
14 diff --git a/src/connection.c b/src/connection.c
15 index 38b3ccfe..d137af12 100644
16 --- a/src/connection.c
17 +++ b/src/connection.c
18 @@ -96,13 +96,13 @@ void free_connection_partially(connection_t *c) {
19         c->outbudget = 0;
20  
21         if(c->inctx) {
22 -               EVP_CIPHER_CTX_cleanup(c->inctx);
23 +               EVP_CIPHER_CTX_reset(c->inctx);
24                 free(c->inctx);
25                 c->inctx = NULL;
26         }
27  
28         if(c->outctx) {
29 -               EVP_CIPHER_CTX_cleanup(c->outctx);
30 +               EVP_CIPHER_CTX_reset(c->outctx);
31                 free(c->outctx);
32                 c->outctx = NULL;
33         }
34 diff --git a/src/connection.h b/src/connection.h
35 index 629e16b9..4f554672 100644
36 --- a/src/connection.h
37 +++ b/src/connection.h
38 @@ -24,6 +24,10 @@
39  #include <openssl/rsa.h>
40  #include <openssl/evp.h>
41  
42 +#if OPENSSL_VERSION_NUMBER < 0x10100000L
43 +#define EVP_CIPHER_CTX_reset(c)        EVP_CIPHER_CTX_cleanup(c)
44 +#endif
45 +
46  #include "avl_tree.h"
47  
48  #define OPTION_INDIRECT         0x0001
49 diff --git a/src/net_setup.c b/src/net_setup.c
50 index cac7455d..f26007bd 100644
51 --- a/src/net_setup.c
52 +++ b/src/net_setup.c
53 @@ -27,6 +27,7 @@
54  #include <openssl/rand.h>
55  #include <openssl/err.h>
56  #include <openssl/evp.h>
57 +#include <openssl/bn.h>
58  
59  #include "avl_tree.h"
60  #include "conf.h"
61 diff --git a/src/tincd.c b/src/tincd.c
62 index bdac0c9d..e8a60449 100644
63 --- a/src/tincd.c
64 +++ b/src/tincd.c
65 @@ -40,6 +40,7 @@
66  #ifndef OPENSSL_NO_ENGINE
67  #include <openssl/engine.h>
68  #endif
69 +#include <openssl/bn.h>
70  
71  #ifdef HAVE_LZO
72  #include LZO1X_H
73 @@ -692,7 +693,9 @@ int main(int argc, char **argv) {
74         ENGINE_register_all_complete();
75  #endif
76  
77 +#if OPENSSL_VERSION_NUMBER < 0x10100000L
78         OpenSSL_add_all_algorithms();
79 +#endif
80  
81         if(generate_keys) {
82                 read_server_config();
83 @@ -811,10 +814,12 @@ end:
84  
85         free(priority);
86  
87 +#if OPENSSL_VERSION_NUMBER < 0x10100000L
88         EVP_cleanup();
89         ERR_free_strings();
90  #ifndef OPENSSL_NO_ENGINE
91         ENGINE_cleanup();
92 +#endif
93  #endif
94  
95         exit_configuration(&config_tree);
96 -- 
97 2.20.0
98