diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/asn1/tasn_enc.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/lib/libcrypto/asn1/tasn_enc.c b/src/lib/libcrypto/asn1/tasn_enc.c index ee2320f856..d42c5ea369 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.24 2022/01/07 11:13:54 tb Exp $ */ | 1 | /* $OpenBSD: tasn_enc.c,v 1.25 2022/08/20 17:55:08 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 | */ |
@@ -529,6 +529,10 @@ asn1_i2d_ex_primitive(ASN1_VALUE **pval, unsigned char **out, | |||
529 | len = 0; | 529 | len = 0; |
530 | } | 530 | } |
531 | 531 | ||
532 | /* Treat any other negative value as an error. */ | ||
533 | if (len < 0) | ||
534 | return -1; | ||
535 | |||
532 | /* If not implicitly tagged get tag from underlying type */ | 536 | /* If not implicitly tagged get tag from underlying type */ |
533 | if (tag == -1) | 537 | if (tag == -1) |
534 | tag = utype; | 538 | tag = utype; |
@@ -537,7 +541,8 @@ asn1_i2d_ex_primitive(ASN1_VALUE **pval, unsigned char **out, | |||
537 | if (out) { | 541 | if (out) { |
538 | if (usetag) | 542 | if (usetag) |
539 | ASN1_put_object(out, ndef, len, tag, aclass); | 543 | ASN1_put_object(out, ndef, len, tag, aclass); |
540 | asn1_ex_i2c(pval, *out, &utype, it); | 544 | if (asn1_ex_i2c(pval, *out, &utype, it) != len) |
545 | return -1; | ||
541 | if (ndef) | 546 | if (ndef) |
542 | ASN1_put_eoc(out); | 547 | ASN1_put_eoc(out); |
543 | else | 548 | else |