diff options
author | 2020-09-03 17:19:27 +0000 | |
---|---|---|
committer | 2020-09-03 17:19:27 +0000 | |
commit | 2fd449498a8551610dca69595bc18e05073a188a (patch) | |
tree | cc8cd292f4b767b92a9056a1695e908412842a33 /lib/libcrypto/asn1/a_bitstr.c | |
parent | Make sure ober_read_elements sets errno on every case where NULL is (diff) | |
download | wireguard-openbsd-2fd449498a8551610dca69595bc18e05073a188a.tar.xz wireguard-openbsd-2fd449498a8551610dca69595bc18e05073a188a.zip |
Remove unnecessary zeroing after recallocarray(3)
Zap a memset that was redundant since OpenSSL 0.97b was merged by
markus in 2003. Nowadays it's otto's recallocarray(3) that does the
zeroing.
ok beck inoguchi otto
PS: ASN1_BIT_STRING_set_bit(3) was committed on Dec 21 1998 by Ralf S.
Engelschnall and used this bizarre allocation idiom:
if (a->data == NULL)
c=(unsigned char *)Malloc(w+1);
else
c=(unsigned char *)Realloc(a->data,w+1);
People complained about Malloc, Realloc and Free being used elsewhere, so
on Jun 1 2000, Richarde Levitte swept the OpenSSL tree and it became this.
if (a->data == NULL)
c=(unsigned char *)OPENSSL_malloc(w+1);
else
c=(unsigned char *)OPENSSL_realloc(a->data,w+1);
Then it was found that existing data should be cleaned, and on Nov 13 2002
Ben Laurie changed the last line to
c=(unsigned char *)OPENSSL_realloc_clean(a->data,
a->length,
w+1);
Diffstat (limited to 'lib/libcrypto/asn1/a_bitstr.c')
-rw-r--r-- | lib/libcrypto/asn1/a_bitstr.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/lib/libcrypto/asn1/a_bitstr.c b/lib/libcrypto/asn1/a_bitstr.c index 7fd40d8a8c6..f217f13d27a 100644 --- a/lib/libcrypto/asn1/a_bitstr.c +++ b/lib/libcrypto/asn1/a_bitstr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_bitstr.c,v 1.29 2018/10/20 16:07:09 tb Exp $ */ +/* $OpenBSD: a_bitstr.c,v 1.30 2020/09/03 17:19:27 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -215,8 +215,6 @@ ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value) ASN1error(ERR_R_MALLOC_FAILURE); return 0; } - if (w + 1 - a->length > 0) - memset(c + a->length, 0, w + 1 - a->length); a->data = c; a->length = w + 1; } |