summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/malloc-wrapper.c
diff options
context:
space:
mode:
authorderaadt <>2017-05-02 03:59:45 +0000
committerderaadt <>2017-05-02 03:59:45 +0000
commit2b561cb0e87f2ee535e8c64907883cd275ad3fec (patch)
treebb9d050c5c2984047e6475e087694d6764f24157 /src/lib/libcrypto/malloc-wrapper.c
parent024e2580a5280d4df3724dab76ce52e14fe2060c (diff)
downloadopenbsd-2b561cb0e87f2ee535e8c64907883cd275ad3fec.tar.gz
openbsd-2b561cb0e87f2ee535e8c64907883cd275ad3fec.tar.bz2
openbsd-2b561cb0e87f2ee535e8c64907883cd275ad3fec.zip
use freezero() instead of memset/explicit_bzero + free. Substantially
reduces conditional logic (-218, +82). MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH cache alignment calculation bn/bn_exp.c wasn'tt quite right. Two other tricky bits with ASN1_STRING_FLAG_NDEF and BN_FLG_STATIC_DATA where the condition cannot be collapsed completely. Passes regress. ok beck
Diffstat (limited to 'src/lib/libcrypto/malloc-wrapper.c')
-rw-r--r--src/lib/libcrypto/malloc-wrapper.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/lib/libcrypto/malloc-wrapper.c b/src/lib/libcrypto/malloc-wrapper.c
index 6ba0aad7e4..12867387bf 100644
--- a/src/lib/libcrypto/malloc-wrapper.c
+++ b/src/lib/libcrypto/malloc-wrapper.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: malloc-wrapper.c,v 1.5 2017/04/28 22:46:40 beck Exp $ */ 1/* $OpenBSD: malloc-wrapper.c,v 1.6 2017/05/02 03:59:44 deraadt Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Bob Beck 3 * Copyright (c) 2014 Bob Beck
4 * 4 *
@@ -165,8 +165,7 @@ CRYPTO_realloc_clean(void *ptr, int old_len, int num, const char *file,
165 ret = malloc(num); 165 ret = malloc(num);
166 if (ret && ptr && old_len > 0) { 166 if (ret && ptr && old_len > 0) {
167 memcpy(ret, ptr, old_len); 167 memcpy(ret, ptr, old_len);
168 explicit_bzero(ptr, old_len); 168 freezero(ptr, old_len);
169 free(ptr);
170 } 169 }
171 return ret; 170 return ret;
172} 171}