From: Matt Caswell Date: Mon, 2 Feb 2015 14:52:32 +0000 (+0000) Subject: Introduce macro RECORD_LAYER_setup_comp_buffer X-Git-Tag: OpenSSL_1_1_0-pre1~1415 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=bd2e3a9512523ff888982cd91e830fc49f1a9595;p=oweals%2Fopenssl.git Introduce macro RECORD_LAYER_setup_comp_buffer Reviewed-by: Richard Levitte --- diff --git a/ssl/record/rec_layer.h b/ssl/record/rec_layer.h index 4fb374de56..110bed24a2 100644 --- a/ssl/record/rec_layer.h +++ b/ssl/record/rec_layer.h @@ -164,6 +164,7 @@ typedef struct record_layer_st { #define RECORD_LAYER_get_wbuf(rl) (&(rl)->wbuf) #define RECORD_LAYER_get_rrec(rl) (&(rl)->rrec) #define RECORD_LAYER_get_wrec(rl) (&(rl)->wrec) +#define RECORD_LAYER_setup_comp_buffer(rl) (SSL3_RECORD_setup(&(rl)->rrec)) void RECORD_LAYER_init(RECORD_LAYER *rl, SSL *s); void RECORD_LAYER_clear(RECORD_LAYER *rl); diff --git a/ssl/record/ssl3_record.c b/ssl/record/ssl3_record.c index a1f3c56b58..33feb01c57 100644 --- a/ssl/record/ssl3_record.c +++ b/ssl/record/ssl3_record.c @@ -143,10 +143,11 @@ void SSL3_RECORD_release(SSL3_RECORD *r) r->comp = NULL; } -int SSL3_RECORD_setup(SSL3_RECORD *r, size_t len) +int SSL3_RECORD_setup(SSL3_RECORD *r) { if (r->comp == NULL) - r->comp = (unsigned char *) OPENSSL_malloc(len); + r->comp = (unsigned char *) + OPENSSL_malloc(SSL3_RT_MAX_ENCRYPTED_LENGTH); if (r->comp == NULL) return 0; return 1; diff --git a/ssl/record/ssl3_record.h b/ssl/record/ssl3_record.h index 574bf7f31c..be8ca2af8b 100644 --- a/ssl/record/ssl3_record.h +++ b/ssl/record/ssl3_record.h @@ -158,7 +158,7 @@ typedef struct ssl3_record_st { void SSL3_RECORD_clear(SSL3_RECORD *r); void SSL3_RECORD_release(SSL3_RECORD *r); -int SSL3_RECORD_setup(SSL3_RECORD *r, size_t len); +int SSL3_RECORD_setup(SSL3_RECORD *r); void SSL3_RECORD_set_seq_num(SSL3_RECORD *r, const unsigned char *seq_num); int ssl3_get_record(SSL *s); __owur int ssl3_do_compress(SSL *ssl); diff --git a/ssl/s3_enc.c b/ssl/s3_enc.c index d3269245d3..974668ba45 100644 --- a/ssl/s3_enc.c +++ b/ssl/s3_enc.c @@ -270,8 +270,7 @@ int ssl3_change_cipher_state(SSL *s, int which) SSL_R_COMPRESSION_LIBRARY_ERROR); goto err2; } - if(!SSL3_RECORD_setup(RECORD_LAYER_get_rrec(&s->rlayer), - SSL3_RT_MAX_PLAIN_LENGTH)) + if(!RECORD_LAYER_setup_comp_buffer(&s->rlayer)) goto err; } #endif diff --git a/ssl/t1_enc.c b/ssl/t1_enc.c index 80626db373..aea39f4582 100644 --- a/ssl/t1_enc.c +++ b/ssl/t1_enc.c @@ -396,8 +396,7 @@ int tls1_change_cipher_state(SSL *s, int which) SSL_R_COMPRESSION_LIBRARY_ERROR); goto err2; } - if (SSL3_RECORD_setup(RECORD_LAYER_get_rrec(&s->rlayer), - SSL3_RT_MAX_ENCRYPTED_LENGTH)) + if (!RECORD_LAYER_setup_comp_buffer(&s->rlayer)) goto err; } #endif