summaryrefslogtreecommitdiff
path: root/src/lib/libressl/ressl.c
diff options
context:
space:
mode:
authortedu <>2014-09-28 06:24:00 +0000
committertedu <>2014-09-28 06:24:00 +0000
commit9db6a5b9d7bcae094827d75a94a39b0626456b92 (patch)
tree572254b10f62c9115d52cc5b067e5bf17ecb93ce /src/lib/libressl/ressl.c
parent15ab81987c18dd77372bb5bdd8b201d0aa2f72b3 (diff)
downloadopenbsd-9db6a5b9d7bcae094827d75a94a39b0626456b92.tar.gz
openbsd-9db6a5b9d7bcae094827d75a94a39b0626456b92.tar.bz2
openbsd-9db6a5b9d7bcae094827d75a94a39b0626456b92.zip
revamp the config interface to own memory. easier to use correctly without
caller worrying about leaks or lifetimes. after feedback from jsing
Diffstat (limited to 'src/lib/libressl/ressl.c')
-rw-r--r--src/lib/libressl/ressl.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/lib/libressl/ressl.c b/src/lib/libressl/ressl.c
index c5e28a4f36..1bf971419b 100644
--- a/src/lib/libressl/ressl.c
+++ b/src/lib/libressl/ressl.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ressl.c,v 1.12 2014/08/15 16:55:32 tedu Exp $ */ 1/* $OpenBSD: ressl.c,v 1.13 2014/09/28 06:24:00 tedu Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -29,7 +29,7 @@
29#include <ressl.h> 29#include <ressl.h>
30#include "ressl_internal.h" 30#include "ressl_internal.h"
31 31
32extern struct ressl_config ressl_config_default; 32static struct ressl_config *ressl_config_default;
33 33
34int 34int
35ressl_init(void) 35ressl_init(void)
@@ -42,6 +42,9 @@ ressl_init(void)
42 SSL_load_error_strings(); 42 SSL_load_error_strings();
43 SSL_library_init(); 43 SSL_library_init();
44 44
45 if ((ressl_config_default = ressl_config_new()) == NULL)
46 return (-1);
47
45 ressl_initialised = 1; 48 ressl_initialised = 1;
46 49
47 return (0); 50 return (0);
@@ -78,7 +81,7 @@ ressl_new(void)
78 if ((ctx = calloc(1, sizeof(*ctx))) == NULL) 81 if ((ctx = calloc(1, sizeof(*ctx))) == NULL)
79 return (NULL); 82 return (NULL);
80 83
81 ctx->config = &ressl_config_default; 84 ctx->config = ressl_config_default;
82 85
83 ressl_reset(ctx); 86 ressl_reset(ctx);
84 87
@@ -89,7 +92,7 @@ int
89ressl_configure(struct ressl *ctx, struct ressl_config *config) 92ressl_configure(struct ressl *ctx, struct ressl_config *config)
90{ 93{
91 if (config == NULL) 94 if (config == NULL)
92 config = &ressl_config_default; 95 config = ressl_config_default;
93 96
94 ctx->config = config; 97 ctx->config = config;
95 98