diff options
author | 2017-01-22 03:50:45 +0000 | |
---|---|---|
committer | 2017-01-22 03:50:45 +0000 | |
commit | 8462f4049c325e5c72084b499c250e7cb627d44b (patch) | |
tree | 4f793d9eb1c556b25dc66205a31e61cc32369ceb /lib/libssl/d1_lib.c | |
parent | Zap some bad whitespace. (diff) | |
download | wireguard-openbsd-8462f4049c325e5c72084b499c250e7cb627d44b.tar.xz wireguard-openbsd-8462f4049c325e5c72084b499c250e7cb627d44b.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 'lib/libssl/d1_lib.c')
-rw-r--r-- | lib/libssl/d1_lib.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/libssl/d1_lib.c b/lib/libssl/d1_lib.c index 56c79f30aa8..3bc1b42583e 100644 --- a/lib/libssl/d1_lib.c +++ b/lib/libssl/d1_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: d1_lib.c,v 1.34 2016/11/04 18:33:11 guenther Exp $ */ +/* $OpenBSD: d1_lib.c,v 1.35 2017/01/22 03:50:45 jsing Exp $ */ /* * DTLS implementation written by Nagendra Modadugu * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. @@ -105,7 +105,12 @@ dtls1_new(SSL *s) if (!ssl3_new(s)) return (0); - if ((d1 = calloc(1, sizeof *d1)) == NULL) { + if ((d1 = calloc(1, sizeof(*d1))) == NULL) { + ssl3_free(s); + return (0); + } + if ((d1->internal = calloc(1, sizeof(*d1->internal))) == NULL) { + free(d1); ssl3_free(s); return (0); } @@ -199,14 +204,19 @@ dtls1_free(SSL *s) pqueue_free(s->d1->sent_messages); pqueue_free(s->d1->buffered_app_data.q); - explicit_bzero(s->d1, sizeof *s->d1); + explicit_bzero(s->d1->internal, sizeof(*s->d1->internal)); + free(s->d1->internal); + + explicit_bzero(s->d1, sizeof(*s->d1)); free(s->d1); + s->d1 = NULL; } void dtls1_clear(SSL *s) { + struct dtls1_state_internal_st *internal; pqueue unprocessed_rcds; pqueue processed_rcds; pqueue buffered_messages; @@ -224,7 +234,10 @@ dtls1_clear(SSL *s) dtls1_clear_queues(s); - memset(s->d1, 0, sizeof(*(s->d1))); + memset(s->d1->internal, 0, sizeof(*s->d1->internal)); + internal = s->d1->internal; + memset(s->d1, 0, sizeof(*s->d1)); + s->d1->internal = internal; if (s->server) { s->d1->cookie_len = sizeof(s->d1->cookie); |