diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/asn1/tasn_dec.c | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/src/lib/libcrypto/asn1/tasn_dec.c b/src/lib/libcrypto/asn1/tasn_dec.c index aa97bc8f4e..7338f6800a 100644 --- a/src/lib/libcrypto/asn1/tasn_dec.c +++ b/src/lib/libcrypto/asn1/tasn_dec.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: tasn_dec.c,v 1.43 2021/12/09 16:58:44 jsing Exp $ */ | 1 | /* $OpenBSD: tasn_dec.c,v 1.44 2021/12/09 17:01:41 jsing Exp $ */ |
| 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 3 | * project 2000. | 3 | * project 2000. |
| 4 | */ | 4 | */ |
| @@ -77,8 +77,6 @@ static int asn1_find_end(const unsigned char **in, long len, char inf); | |||
| 77 | static int asn1_collect(BUF_MEM *buf, const unsigned char **in, long len, | 77 | static int asn1_collect(BUF_MEM *buf, const unsigned char **in, long len, |
| 78 | char inf, int tag, int aclass, int depth); | 78 | char inf, int tag, int aclass, int depth); |
| 79 | 79 | ||
| 80 | static int collect_data(BUF_MEM *buf, const unsigned char **p, long plen); | ||
| 81 | |||
| 82 | static int asn1_check_tlen(long *olen, int *otag, unsigned char *oclass, | 80 | static int asn1_check_tlen(long *olen, int *otag, unsigned char *oclass, |
| 83 | char *inf, char *cst, const unsigned char **in, long len, int exptag, | 81 | char *inf, char *cst, const unsigned char **in, long len, int exptag, |
| 84 | int expclass, char opt, ASN1_TLC *ctx); | 82 | int expclass, char opt, ASN1_TLC *ctx); |
| @@ -1053,8 +1051,17 @@ asn1_collect(BUF_MEM *buf, const unsigned char **in, long len, char inf, | |||
| 1053 | if (!asn1_collect(buf, &p, plen, ininf, tag, aclass, | 1051 | if (!asn1_collect(buf, &p, plen, ininf, tag, aclass, |
| 1054 | depth + 1)) | 1052 | depth + 1)) |
| 1055 | return 0; | 1053 | return 0; |
| 1056 | } else if (plen && !collect_data(buf, &p, plen)) | 1054 | } else if (plen > 0) { |
| 1057 | return 0; | 1055 | size_t len = buf->length; |
| 1056 | |||
| 1057 | if (!BUF_MEM_grow_clean(buf, len + plen)) { | ||
| 1058 | ASN1error(ERR_R_MALLOC_FAILURE); | ||
| 1059 | return 0; | ||
| 1060 | } | ||
| 1061 | memcpy(buf->data + len, p, plen); | ||
| 1062 | |||
| 1063 | p += plen; | ||
| 1064 | } | ||
| 1058 | len -= p - q; | 1065 | len -= p - q; |
| 1059 | } | 1066 | } |
| 1060 | if (inf) { | 1067 | if (inf) { |
| @@ -1065,22 +1072,6 @@ asn1_collect(BUF_MEM *buf, const unsigned char **in, long len, char inf, | |||
| 1065 | return 1; | 1072 | return 1; |
| 1066 | } | 1073 | } |
| 1067 | 1074 | ||
| 1068 | static int | ||
| 1069 | collect_data(BUF_MEM *buf, const unsigned char **p, long plen) | ||
| 1070 | { | ||
| 1071 | int len; | ||
| 1072 | |||
| 1073 | len = buf->length; | ||
| 1074 | if (!BUF_MEM_grow_clean(buf, len + plen)) { | ||
| 1075 | ASN1error(ERR_R_MALLOC_FAILURE); | ||
| 1076 | return 0; | ||
| 1077 | } | ||
| 1078 | memcpy(buf->data + len, *p, plen); | ||
| 1079 | |||
| 1080 | *p += plen; | ||
| 1081 | return 1; | ||
| 1082 | } | ||
| 1083 | |||
| 1084 | /* Check for ASN1 EOC and swallow it if found */ | 1075 | /* Check for ASN1 EOC and swallow it if found */ |
| 1085 | 1076 | ||
| 1086 | static int | 1077 | static int |
