From: Benjamin Kaduk Date: Tue, 24 Jan 2017 16:50:21 +0000 (-0600) Subject: Do not overallocate for tmp.ciphers_raw X-Git-Tag: OpenSSL_1_1_1-pre1~2624 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=f1429b85c5821e55224e5878da9d0fa420a41f71;p=oweals%2Fopenssl.git Do not overallocate for tmp.ciphers_raw Well, not as much, at least. Commit 07afdf3c3ac97af4f2b4eec22a97f7230f8227e0 changed things so that for SSLv2 format ClientHellos we store the cipher list in the TLS format, i.e., with two bytes per cipher, to be consistent with historical behavior. However, the space allocated for the array still performed the computation with three bytes per cipher, a needless over-allocation (though a relatively small one, all things considered). Reviewed-by: Rich Salz Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/2281) --- diff --git a/ssl/statem/statem_srvr.c b/ssl/statem/statem_srvr.c index 8d6fd1fb2c..84f6dfb4c2 100644 --- a/ssl/statem/statem_srvr.c +++ b/ssl/statem/statem_srvr.c @@ -3470,7 +3470,8 @@ STACK_OF(SSL_CIPHER) *ssl_bytes_to_cipher_list(SSL *s, * slightly over allocate because we won't store those. But that isn't a * problem. */ - raw = s->s3->tmp.ciphers_raw = OPENSSL_malloc(numciphers * n); + raw = OPENSSL_malloc(numciphers * TLS_CIPHER_LEN); + s->s3->tmp.ciphers_raw = raw; if (raw == NULL) { *al = SSL_AD_INTERNAL_ERROR; goto err;