diff options
author | raniervf <ranier_gyn@hotmail.com> | 2019-11-16 08:28:00 +1000 |
---|---|---|
committer | Pauli <paul.dale@oracle.com> | 2019-11-16 08:29:26 +1000 |
commit | 4bac25e1115b8c613f9fff12b835aca47e2bdef7 (patch) | |
tree | 5f69584794343fc7eb8635a43a80f3ea7edbcd35 /apps/s_server.c | |
parent | d7cea0b8f50ee9cc698211f4fbf8ad5fca5812ad (diff) |
Author: raniervf <ranier_gyn@hotmail.com>
Date: Thu Nov 7 18:59:11 2019 -0300
Avoid calling strlen repeatedly in loops.
Reviewed-by: Paul Yang <kaishen.yy@antfin.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/10380)
Diffstat (limited to 'apps/s_server.c')
-rw-r--r-- | apps/s_server.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/apps/s_server.c b/apps/s_server.c index 5fa7c2fb42..c81e572267 100644 --- a/apps/s_server.c +++ b/apps/s_server.c @@ -2594,8 +2594,8 @@ static int sv_body(int s, int stype, int prot, unsigned char *context) continue; } if (buf[0] == 'P') { - static const char *str = "Lets print some clear text\n"; - BIO_write(SSL_get_wbio(con), str, strlen(str)); + static const char str[] = "Lets print some clear text\n"; + BIO_write(SSL_get_wbio(con), str, sizeof(str) -1); } if (buf[0] == 'S') { print_stats(bio_s_out, SSL_get_SSL_CTX(con)); @@ -3544,6 +3544,8 @@ static int generate_session_id(SSL *ssl, unsigned char *id, unsigned int *id_len) { unsigned int count = 0; + unsigned int session_id_prefix_len = strlen(session_id_prefix); + do { if (RAND_bytes(id, *id_len) <= 0) return 0; @@ -3555,8 +3557,8 @@ static int generate_session_id(SSL *ssl, unsigned char *id, * conflicts. */ memcpy(id, session_id_prefix, - (strlen(session_id_prefix) < *id_len) ? - strlen(session_id_prefix) : *id_len); + (session_id_prefix_len < *id_len) ? + session_id_prefix_len : *id_len); } while (SSL_has_matching_session_id(ssl, id, *id_len) && (++count < MAX_SESSION_ID_ATTEMPTS)); |