summaryrefslogtreecommitdiff
path: root/src/lib/libssl/d1_lib.c
diff options
context:
space:
mode:
authorjsing <>2017-01-22 03:50:45 +0000
committerjsing <>2017-01-22 03:50:45 +0000
commitda11794e3abdcddc9079bb28bb8e44547030b01f (patch)
tree1305cf6ae8a5e82d3473b44db775f816b47c9554 /src/lib/libssl/d1_lib.c
parentbcd4033a22e1bf44686805b7d0fd9c2560c44eb4 (diff)
downloadopenbsd-da11794e3abdcddc9079bb28bb8e44547030b01f.tar.gz
openbsd-da11794e3abdcddc9079bb28bb8e44547030b01f.tar.bz2
openbsd-da11794e3abdcddc9079bb28bb8e44547030b01f.zip
Convert publically visible structs to translucent structs.
This change adds an internal opaque struct for each of the significant publically visible structs. The opaque struct is then allocated and attached to the publically visible struct when the appropriate *_new() function is called, then cleared and freed as necessary. This will allow for changes to be made to the internals of libssl, without requiring a major bump each time the publically visible structs are modified. ok beck@
Diffstat (limited to 'src/lib/libssl/d1_lib.c')
-rw-r--r--src/lib/libssl/d1_lib.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/lib/libssl/d1_lib.c b/src/lib/libssl/d1_lib.c
index 56c79f30aa..3bc1b42583 100644
--- a/src/lib/libssl/d1_lib.c
+++ b/src/lib/libssl/d1_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: d1_lib.c,v 1.34 2016/11/04 18:33:11 guenther Exp $ */ 1/* $OpenBSD: d1_lib.c,v 1.35 2017/01/22 03:50:45 jsing Exp $ */
2/* 2/*
3 * DTLS implementation written by Nagendra Modadugu 3 * DTLS implementation written by Nagendra Modadugu
4 * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. 4 * (nagendra@cs.stanford.edu) for the OpenSSL project 2005.
@@ -105,7 +105,12 @@ dtls1_new(SSL *s)
105 105
106 if (!ssl3_new(s)) 106 if (!ssl3_new(s))
107 return (0); 107 return (0);
108 if ((d1 = calloc(1, sizeof *d1)) == NULL) { 108 if ((d1 = calloc(1, sizeof(*d1))) == NULL) {
109 ssl3_free(s);
110 return (0);
111 }
112 if ((d1->internal = calloc(1, sizeof(*d1->internal))) == NULL) {
113 free(d1);
109 ssl3_free(s); 114 ssl3_free(s);
110 return (0); 115 return (0);
111 } 116 }
@@ -199,14 +204,19 @@ dtls1_free(SSL *s)
199 pqueue_free(s->d1->sent_messages); 204 pqueue_free(s->d1->sent_messages);
200 pqueue_free(s->d1->buffered_app_data.q); 205 pqueue_free(s->d1->buffered_app_data.q);
201 206
202 explicit_bzero(s->d1, sizeof *s->d1); 207 explicit_bzero(s->d1->internal, sizeof(*s->d1->internal));
208 free(s->d1->internal);
209
210 explicit_bzero(s->d1, sizeof(*s->d1));
203 free(s->d1); 211 free(s->d1);
212
204 s->d1 = NULL; 213 s->d1 = NULL;
205} 214}
206 215
207void 216void
208dtls1_clear(SSL *s) 217dtls1_clear(SSL *s)
209{ 218{
219 struct dtls1_state_internal_st *internal;
210 pqueue unprocessed_rcds; 220 pqueue unprocessed_rcds;
211 pqueue processed_rcds; 221 pqueue processed_rcds;
212 pqueue buffered_messages; 222 pqueue buffered_messages;
@@ -224,7 +234,10 @@ dtls1_clear(SSL *s)
224 234
225 dtls1_clear_queues(s); 235 dtls1_clear_queues(s);
226 236
227 memset(s->d1, 0, sizeof(*(s->d1))); 237 memset(s->d1->internal, 0, sizeof(*s->d1->internal));
238 internal = s->d1->internal;
239 memset(s->d1, 0, sizeof(*s->d1));
240 s->d1->internal = internal;
228 241
229 if (s->server) { 242 if (s->server) {
230 s->d1->cookie_len = sizeof(s->d1->cookie); 243 s->d1->cookie_len = sizeof(s->d1->cookie);