summaryrefslogtreecommitdiff
path: root/lib/libcrypto
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2021-12-09 16:56:16 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2021-12-09 16:56:16 +0000
commitff2c70b82fe5d1d263e82a153053bf5eb79afd6d (patch)
tree9d3d5ec736cd71dfd4b60a6ed1a239edcd246b92 /lib/libcrypto
parentbfa962c26ab7927f7c446bac8da1cd3349fc53a8 (diff)
Remove handling of a NULL BUF_MEM from asn1_collect()
asn1_collect() (and hence collect_data()) is never called without a BUF_MEM - the only caller that passed NULL was removed in OpenSSL commit e1cc0671ac5. ok inoguchi@ tb@
Diffstat (limited to 'lib/libcrypto')
-rw-r--r--lib/libcrypto/asn1/tasn_dec.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/lib/libcrypto/asn1/tasn_dec.c b/lib/libcrypto/asn1/tasn_dec.c
index 331b1479362..b1fb5886c40 100644
--- a/lib/libcrypto/asn1/tasn_dec.c
+++ b/lib/libcrypto/asn1/tasn_dec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tasn_dec.c,v 1.41 2021/12/03 17:27:34 jsing Exp $ */
+/* $OpenBSD: tasn_dec.c,v 1.42 2021/12/09 16:56:15 jsing Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2000.
*/
@@ -1022,12 +1022,7 @@ asn1_collect(BUF_MEM *buf, const unsigned char **in, long len, char inf,
p = *in;
inf &= 1;
- /* If no buffer and not indefinite length constructed just pass over
- * the encoded data */
- if (!buf && !inf) {
- *in += len;
- return 1;
- }
+
while (len > 0) {
q = p;
/* Check for EOC */
@@ -1073,14 +1068,14 @@ static int
collect_data(BUF_MEM *buf, const unsigned char **p, long plen)
{
int len;
- if (buf) {
- len = buf->length;
- if (!BUF_MEM_grow_clean(buf, len + plen)) {
- ASN1error(ERR_R_MALLOC_FAILURE);
- return 0;
- }
- memcpy(buf->data + len, *p, plen);
+
+ len = buf->length;
+ if (!BUF_MEM_grow_clean(buf, len + plen)) {
+ ASN1error(ERR_R_MALLOC_FAILURE);
+ return 0;
}
+ memcpy(buf->data + len, *p, plen);
+
*p += plen;
return 1;
}