| Index: openssl/ssl/d1_lib.c
|
| ===================================================================
|
| --- openssl/ssl/d1_lib.c (revision 105093)
|
| +++ openssl/ssl/d1_lib.c (working copy)
|
| @@ -91,11 +91,6 @@
|
| return(60*60*2);
|
| }
|
|
|
| -IMPLEMENT_dtls1_meth_func(dtlsv1_base_method,
|
| - ssl_undefined_function,
|
| - ssl_undefined_function,
|
| - ssl_bad_method)
|
| -
|
| int dtls1_new(SSL *s)
|
| {
|
| DTLS1_STATE *d1;
|
| @@ -105,17 +100,6 @@
|
| memset(d1,0, sizeof *d1);
|
|
|
| /* d1->handshake_epoch=0; */
|
| -#if defined(OPENSSL_SYS_VMS) || defined(VMS_TEST)
|
| - d1->bitmap.length=64;
|
| -#else
|
| - d1->bitmap.length=sizeof(d1->bitmap.map) * 8;
|
| -#endif
|
| - pq_64bit_init(&(d1->bitmap.map));
|
| - pq_64bit_init(&(d1->bitmap.max_seq_num));
|
| -
|
| - d1->next_bitmap.length = d1->bitmap.length;
|
| - pq_64bit_init(&(d1->next_bitmap.map));
|
| - pq_64bit_init(&(d1->next_bitmap.max_seq_num));
|
|
|
| d1->unprocessed_rcds.q=pqueue_new();
|
| d1->processed_rcds.q=pqueue_new();
|
| @@ -145,26 +129,33 @@
|
| return(1);
|
| }
|
|
|
| -void dtls1_free(SSL *s)
|
| +static void dtls1_clear_queues(SSL *s)
|
| {
|
| pitem *item = NULL;
|
| hm_fragment *frag = NULL;
|
| + DTLS1_RECORD_DATA *rdata;
|
|
|
| - ssl3_free(s);
|
| -
|
| while( (item = pqueue_pop(s->d1->unprocessed_rcds.q)) != NULL)
|
| {
|
| + rdata = (DTLS1_RECORD_DATA *) item->data;
|
| + if (rdata->rbuf.buf)
|
| + {
|
| + OPENSSL_free(rdata->rbuf.buf);
|
| + }
|
| OPENSSL_free(item->data);
|
| pitem_free(item);
|
| }
|
| - pqueue_free(s->d1->unprocessed_rcds.q);
|
|
|
| while( (item = pqueue_pop(s->d1->processed_rcds.q)) != NULL)
|
| {
|
| + rdata = (DTLS1_RECORD_DATA *) item->data;
|
| + if (rdata->rbuf.buf)
|
| + {
|
| + OPENSSL_free(rdata->rbuf.buf);
|
| + }
|
| OPENSSL_free(item->data);
|
| pitem_free(item);
|
| }
|
| - pqueue_free(s->d1->processed_rcds.q);
|
|
|
| while( (item = pqueue_pop(s->d1->buffered_messages)) != NULL)
|
| {
|
| @@ -173,7 +164,6 @@
|
| OPENSSL_free(frag);
|
| pitem_free(item);
|
| }
|
| - pqueue_free(s->d1->buffered_messages);
|
|
|
| while ( (item = pqueue_pop(s->d1->sent_messages)) != NULL)
|
| {
|
| @@ -182,28 +172,70 @@
|
| OPENSSL_free(frag);
|
| pitem_free(item);
|
| }
|
| - pqueue_free(s->d1->sent_messages);
|
|
|
| while ( (item = pqueue_pop(s->d1->buffered_app_data.q)) != NULL)
|
| - {
|
| + {
|
| frag = (hm_fragment *)item->data;
|
| OPENSSL_free(frag->fragment);
|
| OPENSSL_free(frag);
|
| pitem_free(item);
|
| + }
|
| }
|
| +
|
| +void dtls1_free(SSL *s)
|
| + {
|
| + ssl3_free(s);
|
| +
|
| + dtls1_clear_queues(s);
|
| +
|
| + pqueue_free(s->d1->unprocessed_rcds.q);
|
| + pqueue_free(s->d1->processed_rcds.q);
|
| + pqueue_free(s->d1->buffered_messages);
|
| + pqueue_free(s->d1->sent_messages);
|
| pqueue_free(s->d1->buffered_app_data.q);
|
| -
|
| - pq_64bit_free(&(s->d1->bitmap.map));
|
| - pq_64bit_free(&(s->d1->bitmap.max_seq_num));
|
|
|
| - pq_64bit_free(&(s->d1->next_bitmap.map));
|
| - pq_64bit_free(&(s->d1->next_bitmap.max_seq_num));
|
| -
|
| OPENSSL_free(s->d1);
|
| }
|
|
|
| void dtls1_clear(SSL *s)
|
| {
|
| + pqueue unprocessed_rcds;
|
| + pqueue processed_rcds;
|
| + pqueue buffered_messages;
|
| + pqueue sent_messages;
|
| + pqueue buffered_app_data;
|
| + unsigned int mtu;
|
| +
|
| + if (s->d1)
|
| + {
|
| + unprocessed_rcds = s->d1->unprocessed_rcds.q;
|
| + processed_rcds = s->d1->processed_rcds.q;
|
| + buffered_messages = s->d1->buffered_messages;
|
| + sent_messages = s->d1->sent_messages;
|
| + buffered_app_data = s->d1->buffered_app_data.q;
|
| + mtu = s->d1->mtu;
|
| +
|
| + dtls1_clear_queues(s);
|
| +
|
| + memset(s->d1, 0, sizeof(*(s->d1)));
|
| +
|
| + if (s->server)
|
| + {
|
| + s->d1->cookie_len = sizeof(s->d1->cookie);
|
| + }
|
| +
|
| + if (SSL_get_options(s) & SSL_OP_NO_QUERY_MTU)
|
| + {
|
| + s->d1->mtu = mtu;
|
| + }
|
| +
|
| + s->d1->unprocessed_rcds.q = unprocessed_rcds;
|
| + s->d1->processed_rcds.q = processed_rcds;
|
| + s->d1->buffered_messages = buffered_messages;
|
| + s->d1->sent_messages = sent_messages;
|
| + s->d1->buffered_app_data.q = buffered_app_data;
|
| + }
|
| +
|
| ssl3_clear(s);
|
| if (s->options & SSL_OP_CISCO_ANYCONNECT)
|
| s->version=DTLS1_BAD_VER;
|
| @@ -244,13 +276,13 @@
|
| * to explicitly list their SSL_* codes. Currently RC4 is the only one
|
| * available, but if new ones emerge, they will have to be added...
|
| */
|
| -SSL_CIPHER *dtls1_get_cipher(unsigned int u)
|
| +const SSL_CIPHER *dtls1_get_cipher(unsigned int u)
|
| {
|
| - SSL_CIPHER *ciph = ssl3_get_cipher(u);
|
| + const SSL_CIPHER *ciph = ssl3_get_cipher(u);
|
|
|
| if (ciph != NULL)
|
| {
|
| - if ((ciph->algorithms&SSL_ENC_MASK) == SSL_RC4)
|
| + if (ciph->algorithm_enc == SSL_RC4)
|
| return NULL;
|
| }
|
|
|
| @@ -352,6 +384,8 @@
|
| memset(&(s->d1->next_timeout), 0, sizeof(struct timeval));
|
| s->d1->timeout_duration = 1;
|
| BIO_ctrl(SSL_get_rbio(s), BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT, 0, &(s->d1->next_timeout));
|
| + /* Clear retransmission buffer */
|
| + dtls1_clear_record_buffer(s);
|
| }
|
|
|
| int dtls1_handle_timeout(SSL *s)
|
| @@ -371,7 +405,7 @@
|
| {
|
| /* fail the connection, enough alerts have been sent */
|
| SSLerr(SSL_F_DTLS1_HANDLE_TIMEOUT,SSL_R_READ_TIMEOUT_EXPIRED);
|
| - return 0;
|
| + return -1;
|
| }
|
|
|
| state->timeout.read_timeouts++;
|
|
|