Skip to content

Commit ab516f7

Browse files
committedJun 12, 2016
Purge certificates only when expanding plaintext buffer
1 parent f41146f commit ab516f7

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed
 

‎ssl/tls1.c

+3-8
Original file line numberDiff line numberDiff line change
@@ -288,10 +288,6 @@ EXP_FUNC int STDCALL ssl_write(SSL *ssl, const uint8_t *out_data, int out_len)
288288
int n = out_len, nw, i, tot = 0;
289289
/* maximum size of a TLS packet is around 16kB, so fragment */
290290

291-
if (ssl->can_free_certificates) {
292-
certificate_free(ssl);
293-
}
294-
295291
do
296292
{
297293
nw = n;
@@ -1226,10 +1222,6 @@ int basic_read(SSL *ssl, uint8_t **in_data)
12261222
int read_len, is_client = IS_SET_SSL_FLAG(SSL_IS_CLIENT);
12271223
uint8_t *buf = ssl->bm_data;
12281224

1229-
if (ssl->can_free_certificates) {
1230-
certificate_free(ssl);
1231-
}
1232-
12331225
read_len = SOCKET_READ(ssl->client_fd, &buf[ssl->bm_read_index],
12341226
ssl->need_bytes-ssl->got_bytes);
12351227

@@ -1436,6 +1428,9 @@ int increase_bm_data_size(SSL *ssl, size_t size)
14361428
if (ssl->max_plain_length == RT_MAX_PLAIN_LENGTH) {
14371429
return SSL_OK;
14381430
}
1431+
if (ssl->can_free_certificates) {
1432+
certificate_free(ssl);
1433+
}
14391434
size_t required = (size + 1023) & ~(1023); // round up to 1k
14401435
required = (required < RT_MAX_PLAIN_LENGTH) ? required : RT_MAX_PLAIN_LENGTH;
14411436
uint8_t* new_bm_all_data = (uint8_t*) realloc(ssl->bm_all_data, required + RT_EXTRA);

0 commit comments

Comments
 (0)