diff options
Diffstat (limited to 'src/lib/libssl/d1_lib.c')
| -rw-r--r-- | src/lib/libssl/d1_lib.c | 21 |
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 | ||
| 207 | void | 216 | void |
| 208 | dtls1_clear(SSL *s) | 217 | dtls1_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); |
