-/* $OpenBSD: tasn_dec.c,v 1.43 2021/12/09 16:58:44 jsing Exp $ */
+/* $OpenBSD: tasn_dec.c,v 1.44 2021/12/09 17:01:41 jsing Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2000.
*/
static int asn1_collect(BUF_MEM *buf, const unsigned char **in, long len,
char inf, int tag, int aclass, int depth);
-static int collect_data(BUF_MEM *buf, const unsigned char **p, long plen);
-
static int asn1_check_tlen(long *olen, int *otag, unsigned char *oclass,
char *inf, char *cst, const unsigned char **in, long len, int exptag,
int expclass, char opt, ASN1_TLC *ctx);
if (!asn1_collect(buf, &p, plen, ininf, tag, aclass,
depth + 1))
return 0;
- } else if (plen && !collect_data(buf, &p, plen))
- return 0;
+ } else if (plen > 0) {
+ size_t 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;
+ }
len -= p - q;
}
if (inf) {
return 1;
}
-static int
-collect_data(BUF_MEM *buf, const unsigned char **p, long plen)
-{
- int len;
-
- 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;
-}
-
/* Check for ASN1 EOC and swallow it if found */
static int