summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortb <>2022-10-20 09:47:01 +0000
committertb <>2022-10-20 09:47:01 +0000
commitbe7071a39d853595f00196e2efdfab18244b5dc1 (patch)
tree3914a94d9f9af199d2b64702f93d87320b3e70fb
parenta501e42ba79e88a58d28b4491728b8cf86cf46d6 (diff)
downloadopenbsd-be7071a39d853595f00196e2efdfab18244b5dc1.tar.gz
openbsd-be7071a39d853595f00196e2efdfab18244b5dc1.tar.bz2
openbsd-be7071a39d853595f00196e2efdfab18244b5dc1.zip
Unbreak ASN.1 indefinite length encoding.libressl-v3.6.2libressl-v3.6.1
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@; from jsing This is errata/7.2/002_asn1.patch.sig
-rw-r--r--src/lib/libcrypto/asn1/tasn_enc.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/lib/libcrypto/asn1/tasn_enc.c b/src/lib/libcrypto/asn1/tasn_enc.c
index d42c5ea369..8e17d666da 100644
--- a/src/lib/libcrypto/asn1/tasn_enc.c
+++ b/src/lib/libcrypto/asn1/tasn_enc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tasn_enc.c,v 1.25 2022/08/20 17:55:08 jsing Exp $ */ 1/* $OpenBSD: tasn_enc.c,v 1.25.2.1 2022/10/20 09:47:01 tb 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 */
@@ -494,7 +494,7 @@ static int
494asn1_i2d_ex_primitive(ASN1_VALUE **pval, unsigned char **out, 494asn1_i2d_ex_primitive(ASN1_VALUE **pval, unsigned char **out,
495 const ASN1_ITEM *it, int tag, int aclass) 495 const ASN1_ITEM *it, int tag, int aclass)
496{ 496{
497 int len; 497 int olen, len;
498 int utype; 498 int utype;
499 int usetag; 499 int usetag;
500 int ndef = 0; 500 int ndef = 0;
@@ -505,7 +505,7 @@ asn1_i2d_ex_primitive(ASN1_VALUE **pval, unsigned char **out,
505 * out the underlying type. 505 * out the underlying type.
506 */ 506 */
507 507
508 len = asn1_ex_i2c(pval, NULL, &utype, it); 508 olen = len = asn1_ex_i2c(pval, NULL, &utype, it);
509 509
510 /* If SEQUENCE, SET or OTHER then header is 510 /* If SEQUENCE, SET or OTHER then header is
511 * included in pseudo content octets so don't 511 * included in pseudo content octets so don't
@@ -541,7 +541,7 @@ asn1_i2d_ex_primitive(ASN1_VALUE **pval, unsigned char **out,
541 if (out) { 541 if (out) {
542 if (usetag) 542 if (usetag)
543 ASN1_put_object(out, ndef, len, tag, aclass); 543 ASN1_put_object(out, ndef, len, tag, aclass);
544 if (asn1_ex_i2c(pval, *out, &utype, it) != len) 544 if (asn1_ex_i2c(pval, *out, &utype, it) != olen)
545 return -1; 545 return -1;
546 if (ndef) 546 if (ndef)
547 ASN1_put_eoc(out); 547 ASN1_put_eoc(out);