summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjsing <>2022-10-17 18:03:15 +0000
committerjsing <>2022-10-17 18:03:15 +0000
commit68426a72f66e5fdfe8e6dcf8c4403a3b85fdf7b2 (patch)
tree44357b22e0956c559cd990097b2ffdc5d8507ae2
parentfcd92a15935245e973ad525798718590262c6a83 (diff)
downloadopenbsd-68426a72f66e5fdfe8e6dcf8c4403a3b85fdf7b2.tar.gz
openbsd-68426a72f66e5fdfe8e6dcf8c4403a3b85fdf7b2.tar.bz2
openbsd-68426a72f66e5fdfe8e6dcf8c4403a3b85fdf7b2.zip
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@
-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..e0f26b9cdb 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.26 2022/10/17 18:03:15 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 */
@@ -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);