diff options
| author | djm <> | 2011-11-03 02:32:23 +0000 |
|---|---|---|
| committer | djm <> | 2011-11-03 02:32:23 +0000 |
| commit | 113f799ec7d1728f0a5d7ab5b0e3b42e3de56407 (patch) | |
| tree | 26d712b25a8fa580b8f2dfc6df470ba5ffea9eb7 /src/lib/libssl/d1_lib.c | |
| parent | 829fd51d4f8dde4a7f3bf54754f3c1d1a502f5e2 (diff) | |
| download | openbsd-113f799ec7d1728f0a5d7ab5b0e3b42e3de56407.tar.gz openbsd-113f799ec7d1728f0a5d7ab5b0e3b42e3de56407.tar.bz2 openbsd-113f799ec7d1728f0a5d7ab5b0e3b42e3de56407.zip | |
import OpenSSL 1.0.0e
Diffstat (limited to 'src/lib/libssl/d1_lib.c')
| -rw-r--r-- | src/lib/libssl/d1_lib.c | 65 |
1 files changed, 57 insertions, 8 deletions
diff --git a/src/lib/libssl/d1_lib.c b/src/lib/libssl/d1_lib.c index 96b220e87c..48e8b6ffbb 100644 --- a/src/lib/libssl/d1_lib.c +++ b/src/lib/libssl/d1_lib.c | |||
| @@ -129,26 +129,33 @@ int dtls1_new(SSL *s) | |||
| 129 | return(1); | 129 | return(1); |
| 130 | } | 130 | } |
| 131 | 131 | ||
| 132 | void dtls1_free(SSL *s) | 132 | static void dtls1_clear_queues(SSL *s) |
| 133 | { | 133 | { |
| 134 | pitem *item = NULL; | 134 | pitem *item = NULL; |
| 135 | hm_fragment *frag = NULL; | 135 | hm_fragment *frag = NULL; |
| 136 | 136 | DTLS1_RECORD_DATA *rdata; | |
| 137 | ssl3_free(s); | ||
| 138 | 137 | ||
| 139 | while( (item = pqueue_pop(s->d1->unprocessed_rcds.q)) != NULL) | 138 | while( (item = pqueue_pop(s->d1->unprocessed_rcds.q)) != NULL) |
| 140 | { | 139 | { |
| 140 | rdata = (DTLS1_RECORD_DATA *) item->data; | ||
| 141 | if (rdata->rbuf.buf) | ||
| 142 | { | ||
| 143 | OPENSSL_free(rdata->rbuf.buf); | ||
| 144 | } | ||
| 141 | OPENSSL_free(item->data); | 145 | OPENSSL_free(item->data); |
| 142 | pitem_free(item); | 146 | pitem_free(item); |
| 143 | } | 147 | } |
| 144 | pqueue_free(s->d1->unprocessed_rcds.q); | ||
| 145 | 148 | ||
| 146 | while( (item = pqueue_pop(s->d1->processed_rcds.q)) != NULL) | 149 | while( (item = pqueue_pop(s->d1->processed_rcds.q)) != NULL) |
| 147 | { | 150 | { |
| 151 | rdata = (DTLS1_RECORD_DATA *) item->data; | ||
| 152 | if (rdata->rbuf.buf) | ||
| 153 | { | ||
| 154 | OPENSSL_free(rdata->rbuf.buf); | ||
| 155 | } | ||
| 148 | OPENSSL_free(item->data); | 156 | OPENSSL_free(item->data); |
| 149 | pitem_free(item); | 157 | pitem_free(item); |
| 150 | } | 158 | } |
| 151 | pqueue_free(s->d1->processed_rcds.q); | ||
| 152 | 159 | ||
| 153 | while( (item = pqueue_pop(s->d1->buffered_messages)) != NULL) | 160 | while( (item = pqueue_pop(s->d1->buffered_messages)) != NULL) |
| 154 | { | 161 | { |
| @@ -157,7 +164,6 @@ void dtls1_free(SSL *s) | |||
| 157 | OPENSSL_free(frag); | 164 | OPENSSL_free(frag); |
| 158 | pitem_free(item); | 165 | pitem_free(item); |
| 159 | } | 166 | } |
| 160 | pqueue_free(s->d1->buffered_messages); | ||
| 161 | 167 | ||
| 162 | while ( (item = pqueue_pop(s->d1->sent_messages)) != NULL) | 168 | while ( (item = pqueue_pop(s->d1->sent_messages)) != NULL) |
| 163 | { | 169 | { |
| @@ -166,7 +172,6 @@ void dtls1_free(SSL *s) | |||
| 166 | OPENSSL_free(frag); | 172 | OPENSSL_free(frag); |
| 167 | pitem_free(item); | 173 | pitem_free(item); |
| 168 | } | 174 | } |
| 169 | pqueue_free(s->d1->sent_messages); | ||
| 170 | 175 | ||
| 171 | while ( (item = pqueue_pop(s->d1->buffered_app_data.q)) != NULL) | 176 | while ( (item = pqueue_pop(s->d1->buffered_app_data.q)) != NULL) |
| 172 | { | 177 | { |
| @@ -175,6 +180,18 @@ void dtls1_free(SSL *s) | |||
| 175 | OPENSSL_free(frag); | 180 | OPENSSL_free(frag); |
| 176 | pitem_free(item); | 181 | pitem_free(item); |
| 177 | } | 182 | } |
| 183 | } | ||
| 184 | |||
| 185 | void dtls1_free(SSL *s) | ||
| 186 | { | ||
| 187 | ssl3_free(s); | ||
| 188 | |||
| 189 | dtls1_clear_queues(s); | ||
| 190 | |||
| 191 | pqueue_free(s->d1->unprocessed_rcds.q); | ||
| 192 | pqueue_free(s->d1->processed_rcds.q); | ||
| 193 | pqueue_free(s->d1->buffered_messages); | ||
| 194 | pqueue_free(s->d1->sent_messages); | ||
| 178 | pqueue_free(s->d1->buffered_app_data.q); | 195 | pqueue_free(s->d1->buffered_app_data.q); |
| 179 | 196 | ||
| 180 | OPENSSL_free(s->d1); | 197 | OPENSSL_free(s->d1); |
| @@ -182,6 +199,36 @@ void dtls1_free(SSL *s) | |||
| 182 | 199 | ||
| 183 | void dtls1_clear(SSL *s) | 200 | void dtls1_clear(SSL *s) |
| 184 | { | 201 | { |
| 202 | pqueue unprocessed_rcds; | ||
| 203 | pqueue processed_rcds; | ||
| 204 | pqueue buffered_messages; | ||
| 205 | pqueue sent_messages; | ||
| 206 | pqueue buffered_app_data; | ||
| 207 | |||
| 208 | if (s->d1) | ||
| 209 | { | ||
| 210 | unprocessed_rcds = s->d1->unprocessed_rcds.q; | ||
| 211 | processed_rcds = s->d1->processed_rcds.q; | ||
| 212 | buffered_messages = s->d1->buffered_messages; | ||
| 213 | sent_messages = s->d1->sent_messages; | ||
| 214 | buffered_app_data = s->d1->buffered_app_data.q; | ||
| 215 | |||
| 216 | dtls1_clear_queues(s); | ||
| 217 | |||
| 218 | memset(s->d1, 0, sizeof(*(s->d1))); | ||
| 219 | |||
| 220 | if (s->server) | ||
| 221 | { | ||
| 222 | s->d1->cookie_len = sizeof(s->d1->cookie); | ||
| 223 | } | ||
| 224 | |||
| 225 | s->d1->unprocessed_rcds.q = unprocessed_rcds; | ||
| 226 | s->d1->processed_rcds.q = processed_rcds; | ||
| 227 | s->d1->buffered_messages = buffered_messages; | ||
| 228 | s->d1->sent_messages = sent_messages; | ||
| 229 | s->d1->buffered_app_data.q = buffered_app_data; | ||
| 230 | } | ||
| 231 | |||
| 185 | ssl3_clear(s); | 232 | ssl3_clear(s); |
| 186 | if (s->options & SSL_OP_CISCO_ANYCONNECT) | 233 | if (s->options & SSL_OP_CISCO_ANYCONNECT) |
| 187 | s->version=DTLS1_BAD_VER; | 234 | s->version=DTLS1_BAD_VER; |
| @@ -330,6 +377,8 @@ void dtls1_stop_timer(SSL *s) | |||
| 330 | memset(&(s->d1->next_timeout), 0, sizeof(struct timeval)); | 377 | memset(&(s->d1->next_timeout), 0, sizeof(struct timeval)); |
| 331 | s->d1->timeout_duration = 1; | 378 | s->d1->timeout_duration = 1; |
| 332 | BIO_ctrl(SSL_get_rbio(s), BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT, 0, &(s->d1->next_timeout)); | 379 | BIO_ctrl(SSL_get_rbio(s), BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT, 0, &(s->d1->next_timeout)); |
| 380 | /* Clear retransmission buffer */ | ||
| 381 | dtls1_clear_record_buffer(s); | ||
| 333 | } | 382 | } |
| 334 | 383 | ||
| 335 | int dtls1_handle_timeout(SSL *s) | 384 | int dtls1_handle_timeout(SSL *s) |
| @@ -349,7 +398,7 @@ int dtls1_handle_timeout(SSL *s) | |||
| 349 | { | 398 | { |
| 350 | /* fail the connection, enough alerts have been sent */ | 399 | /* fail the connection, enough alerts have been sent */ |
| 351 | SSLerr(SSL_F_DTLS1_HANDLE_TIMEOUT,SSL_R_READ_TIMEOUT_EXPIRED); | 400 | SSLerr(SSL_F_DTLS1_HANDLE_TIMEOUT,SSL_R_READ_TIMEOUT_EXPIRED); |
| 352 | return 0; | 401 | return -1; |
| 353 | } | 402 | } |
| 354 | 403 | ||
| 355 | state->timeout.read_timeouts++; | 404 | state->timeout.read_timeouts++; |
