summaryrefslogtreecommitdiff
path: root/lib/libcrypto/asn1
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2022-10-17 18:03:16 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2022-10-17 18:03:16 +0000
commit1f8e2220c1d9569f46508c33b5c165fff9d16be7 (patch)
tree9dd1b8687e80b71876325d9b5e274b7922bae105 /lib/libcrypto/asn1
parent4be0c729d03e148940b22796b96f14a5df1345e0 (diff)
Unbreak ASN.1 indefinite length encoding.
In r1.25 of tasn_enc.c a check was added to ensure that asn1_ex_i2c() returned the same value on both calls, however in the ndef case the len variable gets changed between calls. Keep a copy of the original value to test against. Issue reported by niklas, who encountered a test failure in rust-openssl. ok miod@ tb@
Diffstat (limited to 'lib/libcrypto/asn1')
-rw-r--r--lib/libcrypto/asn1/tasn_enc.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/libcrypto/asn1/tasn_enc.c b/lib/libcrypto/asn1/tasn_enc.c
index d42c5ea3694..e0f26b9cdba 100644
--- a/lib/libcrypto/asn1/tasn_enc.c
+++ b/lib/libcrypto/asn1/tasn_enc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tasn_enc.c,v 1.25 2022/08/20 17:55:08 jsing Exp $ */
+/* $OpenBSD: tasn_enc.c,v 1.26 2022/10/17 18:03:15 jsing Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2000.
*/
@@ -494,7 +494,7 @@ static int
asn1_i2d_ex_primitive(ASN1_VALUE **pval, unsigned char **out,
const ASN1_ITEM *it, int tag, int aclass)
{
- int len;
+ int olen, len;
int utype;
int usetag;
int ndef = 0;
@@ -505,7 +505,7 @@ asn1_i2d_ex_primitive(ASN1_VALUE **pval, unsigned char **out,
* out the underlying type.
*/
- len = asn1_ex_i2c(pval, NULL, &utype, it);
+ olen = len = asn1_ex_i2c(pval, NULL, &utype, it);
/* If SEQUENCE, SET or OTHER then header is
* included in pseudo content octets so don't
@@ -541,7 +541,7 @@ asn1_i2d_ex_primitive(ASN1_VALUE **pval, unsigned char **out,
if (out) {
if (usetag)
ASN1_put_object(out, ndef, len, tag, aclass);
- if (asn1_ex_i2c(pval, *out, &utype, it) != len)
+ if (asn1_ex_i2c(pval, *out, &utype, it) != olen)
return -1;
if (ndef)
ASN1_put_eoc(out);