From 8df6eeefceb4403224b672a6e0b97b6ddf378410 Mon Sep 17 00:00:00 2001 From: beck Date: Thu, 17 Apr 2014 16:30:59 +0000 Subject: [PATCH] remove OPENSSL_realloc_clean usage here - replace with intrinsics to make it obvious what should happen. ok tedu@ --- lib/libcrypto/buffer/buffer.c | 11 +++++++---- lib/libssl/src/crypto/buffer/buffer.c | 11 +++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/libcrypto/buffer/buffer.c b/lib/libcrypto/buffer/buffer.c index 4bd55c04ae5..a50c30a3485 100644 --- a/lib/libcrypto/buffer/buffer.c +++ b/lib/libcrypto/buffer/buffer.c @@ -153,10 +153,13 @@ BUF_MEM_grow_clean(BUF_MEM *str, size_t len) return 0; } n = (len + 3) / 3 * 4; - if (str->data == NULL) - ret = malloc(n); - else - ret = OPENSSL_realloc_clean(str->data, str->max, n); + ret = malloc(n); + /* we're not shrinking - that case returns above */ + if ((ret != NULL) && (str->data != NULL)) { + memcpy(ret, str->data, str->max); + explicit_bzero(str->data, str->max); + free(str->data); + } if (ret == NULL) { BUFerr(BUF_F_BUF_MEM_GROW_CLEAN, ERR_R_MALLOC_FAILURE); len = 0; diff --git a/lib/libssl/src/crypto/buffer/buffer.c b/lib/libssl/src/crypto/buffer/buffer.c index 4bd55c04ae5..a50c30a3485 100644 --- a/lib/libssl/src/crypto/buffer/buffer.c +++ b/lib/libssl/src/crypto/buffer/buffer.c @@ -153,10 +153,13 @@ BUF_MEM_grow_clean(BUF_MEM *str, size_t len) return 0; } n = (len + 3) / 3 * 4; - if (str->data == NULL) - ret = malloc(n); - else - ret = OPENSSL_realloc_clean(str->data, str->max, n); + ret = malloc(n); + /* we're not shrinking - that case returns above */ + if ((ret != NULL) && (str->data != NULL)) { + memcpy(ret, str->data, str->max); + explicit_bzero(str->data, str->max); + free(str->data); + } if (ret == NULL) { BUFerr(BUF_F_BUF_MEM_GROW_CLEAN, ERR_R_MALLOC_FAILURE); len = 0; -- 2.20.1