Add and use OPENSSL_zalloc
There are many places (nearly 50) where we malloc and then memset. Add an OPENSSL_zalloc routine to encapsulate that. (Missed one conversion; thanks Richard) Also fixes GH328 Reviewed-by: Richard Levitte <levitte@openssl.org>
This commit is contained in:
@@ -440,10 +440,8 @@ int test_builtin(BIO *out)
|
||||
goto builtin_err;
|
||||
}
|
||||
buf_len = 2 * bn_len;
|
||||
if ((raw_buf = OPENSSL_malloc(buf_len)) == NULL)
|
||||
if ((raw_buf = OPENSSL_zalloc(buf_len)) == NULL)
|
||||
goto builtin_err;
|
||||
/* Pad the bignums with leading zeroes. */
|
||||
memset(raw_buf, 0, buf_len);
|
||||
BN_bn2bin(ecdsa_sig->r, raw_buf + bn_len - r_len);
|
||||
BN_bn2bin(ecdsa_sig->s, raw_buf + buf_len - s_len);
|
||||
|
||||
|
||||
@@ -2116,14 +2116,11 @@ int doit(SSL *s_ssl, SSL *c_ssl, long count)
|
||||
|
||||
bufsiz = count > 40 * 1024 ? 40 * 1024 : count;
|
||||
|
||||
if ((cbuf = OPENSSL_malloc(bufsiz)) == NULL)
|
||||
if ((cbuf = OPENSSL_zalloc(bufsiz)) == NULL)
|
||||
goto err;
|
||||
if ((sbuf = OPENSSL_malloc(bufsiz)) == NULL)
|
||||
if ((sbuf = OPENSSL_zalloc(bufsiz)) == NULL)
|
||||
goto err;
|
||||
|
||||
memset(cbuf, 0, bufsiz);
|
||||
memset(sbuf, 0, bufsiz);
|
||||
|
||||
c_to_s = BIO_new(BIO_s_mem());
|
||||
s_to_c = BIO_new(BIO_s_mem());
|
||||
if ((s_to_c == NULL) || (c_to_s == NULL)) {
|
||||
|
||||
Reference in New Issue
Block a user