summaryrefslogtreecommitdiffstats
path: root/crypto/asn1
diff options
context:
space:
mode:
authorndossche <niels.dossche@ugent.be>2023-02-09 11:39:58 +0100
committerPauli <pauli@openssl.org>2023-02-28 14:34:57 +1100
commit5df5032ab02d7a17e07435de777d730bae190253 (patch)
tree5059b0c0972a8146d9df5e14af5871dd0a714b8e /crypto/asn1
parent7066c57dce88994778daa10ba2c81490fc5cf0c7 (diff)
Fix incomplete error check on ASN1_item_i2d()
According to the documentation and my analysis tool ASN1_item_i2d() can return a negative value on error, but this is not checked. Fix it by changing the error check condition. CLA: trivial Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/20251)
Diffstat (limited to 'crypto/asn1')
-rw-r--r--crypto/asn1/asn_pack.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/crypto/asn1/asn_pack.c b/crypto/asn1/asn_pack.c
index 0d1f3406db..d22925510d 100644
--- a/crypto/asn1/asn_pack.c
+++ b/crypto/asn1/asn_pack.c
@@ -28,7 +28,7 @@ ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_STRING **oct)
ASN1_STRING_set0(octmp, NULL, 0);
- if ((octmp->length = ASN1_item_i2d(obj, &octmp->data, it)) == 0) {
+ if ((octmp->length = ASN1_item_i2d(obj, &octmp->data, it)) <= 0) {
ERR_raise(ERR_LIB_ASN1, ASN1_R_ENCODE_ERROR);
goto err;
}