summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjsing <>2014-04-25 13:55:25 +0000
committerjsing <>2014-04-25 13:55:25 +0000
commit6f66ef3fe9dd594859a8814d18cbab4249bf5d10 (patch)
tree51d994ec4c1283494d5f56f646c71ff3b3374417 /src
parentf9479ea94ed8e42b0bbd8e1b187250e0ef9be9a8 (diff)
downloadopenbsd-6f66ef3fe9dd594859a8814d18cbab4249bf5d10.tar.gz
openbsd-6f66ef3fe9dd594859a8814d18cbab4249bf5d10.tar.bz2
openbsd-6f66ef3fe9dd594859a8814d18cbab4249bf5d10.zip
The apps_{startup,shutdown} macro mess is now only used in openssl.c -
reduce the macro to two functions and just call them instead. ok miod@
Diffstat (limited to 'src')
-rw-r--r--src/lib/libssl/src/apps/apps.h30
-rw-r--r--src/lib/libssl/src/apps/openssl.c48
2 files changed, 42 insertions, 36 deletions
diff --git a/src/lib/libssl/src/apps/apps.h b/src/lib/libssl/src/apps/apps.h
index a79bdc9436..1f013e358b 100644
--- a/src/lib/libssl/src/apps/apps.h
+++ b/src/lib/libssl/src/apps/apps.h
@@ -140,36 +140,6 @@ extern BIO *bio_err;
140#define zlib_cleanup() COMP_zlib_cleanup() 140#define zlib_cleanup() COMP_zlib_cleanup()
141#endif 141#endif
142 142
143#if !defined(OPENSSL_C)
144# define apps_startup() \
145 do_pipe_sig()
146# define apps_shutdown()
147#else
148# ifndef OPENSSL_NO_ENGINE
149# define apps_startup() \
150 do { do_pipe_sig(); CRYPTO_malloc_init(); \
151 ERR_load_crypto_strings(); OpenSSL_add_all_algorithms(); \
152 ENGINE_load_builtin_engines(); setup_ui_method(); } while(0)
153# define apps_shutdown() \
154 do { CONF_modules_unload(1); destroy_ui_method(); \
155 OBJ_cleanup(); EVP_cleanup(); ENGINE_cleanup(); \
156 CRYPTO_cleanup_all_ex_data(); ERR_remove_thread_state(NULL); \
157 RAND_cleanup(); \
158 ERR_free_strings(); zlib_cleanup();} while(0)
159# else
160# define apps_startup() \
161 do { do_pipe_sig(); CRYPTO_malloc_init(); \
162 ERR_load_crypto_strings(); OpenSSL_add_all_algorithms(); \
163 setup_ui_method(); } while(0)
164# define apps_shutdown() \
165 do { CONF_modules_unload(1); destroy_ui_method(); \
166 OBJ_cleanup(); EVP_cleanup(); \
167 CRYPTO_cleanup_all_ex_data(); ERR_remove_thread_state(NULL); \
168 RAND_cleanup(); \
169 ERR_free_strings(); zlib_cleanup(); } while(0)
170# endif
171#endif
172
173typedef struct args_st { 143typedef struct args_st {
174 char **data; 144 char **data;
175 int count; 145 int count;
diff --git a/src/lib/libssl/src/apps/openssl.c b/src/lib/libssl/src/apps/openssl.c
index 5778191cb1..7070b4c896 100644
--- a/src/lib/libssl/src/apps/openssl.c
+++ b/src/lib/libssl/src/apps/openssl.c
@@ -112,8 +112,6 @@
112#include <stdio.h> 112#include <stdio.h>
113#include <string.h> 113#include <string.h>
114#include <stdlib.h> 114#include <stdlib.h>
115#define OPENSSL_C /* tells apps.h to use complete
116 * apps_startup() */
117#include "apps.h" 115#include "apps.h"
118#include <openssl/bio.h> 116#include <openssl/bio.h>
119#include <openssl/crypto.h> 117#include <openssl/crypto.h>
@@ -130,13 +128,16 @@
130#include "s_apps.h" 128#include "s_apps.h"
131#include <openssl/err.h> 129#include <openssl/err.h>
132 130
131static void openssl_startup(void);
132static void openssl_shutdown(void);
133
133/* The LHASH callbacks ("hash" & "cmp") have been replaced by functions with the 134/* The LHASH callbacks ("hash" & "cmp") have been replaced by functions with the
134 * base prototypes (we cast each variable inside the function to the required 135 * base prototypes (we cast each variable inside the function to the required
135 * type of "FUNCTION*"). This removes the necessity for macro-generated wrapper 136 * type of "FUNCTION*"). This removes the necessity for macro-generated wrapper
136 * functions. */ 137 * functions. */
137 138
138static LHASH_OF(FUNCTION) * prog_init(void); 139static LHASH_OF(FUNCTION) *prog_init(void);
139static int do_cmd(LHASH_OF(FUNCTION) * prog, int argc, char *argv[]); 140static int do_cmd(LHASH_OF(FUNCTION) *prog, int argc, char *argv[]);
140static void list_pkey(BIO * out); 141static void list_pkey(BIO * out);
141static void list_cipher(BIO * out); 142static void list_cipher(BIO * out);
142static void list_md(BIO * out); 143static void list_md(BIO * out);
@@ -195,6 +196,41 @@ err:
195 } 196 }
196} 197}
197 198
199static void
200openssl_startup(void)
201{
202 do_pipe_sig();
203
204 CRYPTO_malloc_init();
205 ERR_load_crypto_strings();
206 OpenSSL_add_all_algorithms();
207
208#ifndef OPENSSL_NO_ENGINE
209 ENGINE_load_builtin_engines();
210#endif
211
212 setup_ui_method();
213}
214
215static void
216openssl_shutdown(void)
217{
218 CONF_modules_unload(1);
219 destroy_ui_method();
220 OBJ_cleanup();
221 EVP_cleanup();
222
223#ifndef OPENSSL_NO_ENGINE
224 ENGINE_cleanup();
225#endif
226
227 CRYPTO_cleanup_all_ex_data();
228 ERR_remove_thread_state(NULL);
229 RAND_cleanup();
230 ERR_free_strings();
231 zlib_cleanup();
232}
233
198int 234int
199main(int argc, char **argv) 235main(int argc, char **argv)
200{ 236{
@@ -237,7 +273,7 @@ main(int argc, char **argv)
237 CRYPTO_set_locking_callback(lock_dbg_cb); 273 CRYPTO_set_locking_callback(lock_dbg_cb);
238 } 274 }
239 275
240 apps_startup(); 276 openssl_startup();
241 277
242 /* Lets load up our environment a little */ 278 /* Lets load up our environment a little */
243 p = getenv("OPENSSL_CONF"); 279 p = getenv("OPENSSL_CONF");
@@ -348,7 +384,7 @@ end:
348 if (arg.data != NULL) 384 if (arg.data != NULL)
349 free(arg.data); 385 free(arg.data);
350 386
351 apps_shutdown(); 387 openssl_shutdown();
352 388
353 CRYPTO_mem_leaks(bio_err); 389 CRYPTO_mem_leaks(bio_err);
354 if (bio_err != NULL) { 390 if (bio_err != NULL) {