*
*/
+#include "../ssl_locl.h"
+
typedef struct record_layer_st {
/* The parent SSL structure */
SSL *s;
* non-blocking reads)
*/
int read_ahead;
+ /* read IO goes into here */
+ SSL3_BUFFER rbuf;
} RECORD_LAYER;
#define RECORD_LAYER_set_ssl(rl, s) ((rl)->s = (s))
#define RECORD_LAYER_set_read_ahead(rl, ra) ((rl)->read_ahead = (ra))
#define RECORD_LAYER_get_read_ahead(rl) ((rl)->read_ahead)
-#define RECORD_LAYER_get_rbuf(rl) (&(rl)->s->s3->rbuf)
+#define RECORD_LAYER_get_rbuf(rl) (&(rl)->rbuf)
return;
ssl3_cleanup_key_block(s);
- if (SSL3_BUFFER_is_initialised(RECORD_LAYER_get_rbuf(&s->rlayer)))
- ssl3_release_read_buffer(s);
if (s->s3->wbuf.buf != NULL)
ssl3_release_write_buffer(s);
if (s->s3->rrec.comp != NULL)
void ssl3_clear(SSL *s)
{
- unsigned char *rp, *wp;
- size_t rlen, wlen;
+ unsigned char *wp;
+ size_t wlen;
int init_extra;
ssl3_cleanup_key_block(s);
# endif /* !OPENSSL_NO_EC */
#endif /* !OPENSSL_NO_TLSEXT */
- rp = SSL3_BUFFER_get_buf(RECORD_LAYER_get_rbuf(&s->rlayer));
wp = s->s3->wbuf.buf;
- rlen = SSL3_BUFFER_get_len(RECORD_LAYER_get_rbuf(&s->rlayer));
wlen = s->s3->wbuf.len;
init_extra = s->s3->init_extra;
BIO_free(s->s3->handshake_buffer);
}
#endif
memset(s->s3, 0, sizeof *s->s3);
- SSL3_BUFFER_set_buf(RECORD_LAYER_get_rbuf(&s->rlayer), rp);
s->s3->wbuf.buf = wp;
- SSL3_BUFFER_set_len(RECORD_LAYER_get_rbuf(&s->rlayer), rlen);
s->s3->wbuf.len = wlen;
s->s3->init_extra = init_extra;
int SSL_clear(SSL *s)
{
+ unsigned char *rp;
+ size_t rlen;
+ int read_ahead;
if (s->method == NULL) {
SSLerr(SSL_F_SSL_CLEAR, SSL_R_NO_METHOD_SPECIFIED);
return (0);
} else
s->method->ssl_clear(s);
+
+ read_ahead = RECORD_LAYER_get_read_ahead(&s->rlayer);
+ rp = SSL3_BUFFER_get_buf(RECORD_LAYER_get_rbuf(&s->rlayer));
+ rlen = SSL3_BUFFER_get_len(RECORD_LAYER_get_rbuf(&s->rlayer));
+ memset(&s->rlayer, 0, sizeof s->rlayer);
+ SSL3_BUFFER_set_buf(RECORD_LAYER_get_rbuf(&s->rlayer), rp);
+ SSL3_BUFFER_set_len(RECORD_LAYER_get_rbuf(&s->rlayer), rlen);
+
+ /* Do I need to do this? As far as I can tell read_ahead did not
+ * previously get reset by SSL_clear...so I'll keep it that way..but is
+ * that right?
+ */
+ RECORD_LAYER_set_read_ahead(&s->rlayer, read_ahead);
+
return (1);
}
if (s->method != NULL)
s->method->ssl_free(s);
+ if (SSL3_BUFFER_is_initialised(RECORD_LAYER_get_rbuf(&s->rlayer)))
+ ssl3_release_read_buffer(s);
+
if (s->ctx)
SSL_CTX_free(s->ctx);
# include <openssl/ssl.h>
# include <openssl/symhacks.h>
-#include "record/rec_layer.h"
#include "record/ssl3_buffer.h"
+#include "record/rec_layer.h"
# ifdef OPENSSL_BUILD_SHLIBSSL
# undef OPENSSL_EXTERN
int empty_fragment_done;
/* The value of 'extra' when the buffers were initialized */
int init_extra;
- SSL3_BUFFER rbuf; /* read IO goes into here */
SSL3_BUFFER wbuf; /* write IO goes into here */
SSL3_RECORD rrec; /* each decoded record goes in here */
SSL3_RECORD wrec; /* goes out from here */