Introduce macro RECORD_LAYER_setup_comp_buffer
authorMatt Caswell <matt@openssl.org>
Mon, 2 Feb 2015 14:52:32 +0000 (14:52 +0000)
committerMatt Caswell <matt@openssl.org>
Thu, 26 Mar 2015 15:01:59 +0000 (15:01 +0000)
Reviewed-by: Richard Levitte <levitte@openssl.org>
ssl/record/rec_layer.h
ssl/record/ssl3_record.c
ssl/record/ssl3_record.h
ssl/s3_enc.c
ssl/t1_enc.c

index 4fb374de5613a478bd20ee67bd86bb1dfb01734f..110bed24a21fc57425b5821381e644621e65fe1b 100644 (file)
@@ -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);
index a1f3c56b58a610b1c6d3510500b7982cbadcff2d..33feb01c576bc6574ad40d068261948909636625 100644 (file)
@@ -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;
index 574bf7f31c4e0a8a76f12e2a83efd64daf51890c..be8ca2af8b90a292fd676e26a3ddd9e7b293432a 100644 (file)
@@ -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);
index d3269245d3f9ac41099cda3e4202303c5646d254..974668ba45d61980358133d7c706cc6516784657 100644 (file)
@@ -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
index 80626db3735a61ff3954b33bc508ecd626398e64..aea39f45820562f73a3b00c7621bd07de350d444 100644 (file)
@@ -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