summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjsing <>2022-08-28 17:49:25 +0000
committerjsing <>2022-08-28 17:49:25 +0000
commitfc40a94c1070698fc2309e20e5f331b5152f85b5 (patch)
tree069494453f9add0f2e422ad624f7019e1b4900ce
parentd41edc9b0d24a1228f0d3bbfaf3d70c6be7efbe7 (diff)
downloadopenbsd-fc40a94c1070698fc2309e20e5f331b5152f85b5.tar.gz
openbsd-fc40a94c1070698fc2309e20e5f331b5152f85b5.tar.bz2
openbsd-fc40a94c1070698fc2309e20e5f331b5152f85b5.zip
Encode an ASN.1 INTEGER with NULL data to value of zero.
When an ASN1_INTEGER is created it has NULL data until a value is set - previously, an ASN1_INTEGER in this state encoded to an ASN.1 INTEGER with a value of 0, rather than being treated as an error. While code should really set values, the historical behaviour has not required this. Found the hard way by sthen@ with acme-client. ok tb@
-rw-r--r--src/lib/libcrypto/asn1/a_int.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/lib/libcrypto/asn1/a_int.c b/src/lib/libcrypto/asn1/a_int.c
index 6a24c5183c..1f4778922d 100644
--- a/src/lib/libcrypto/asn1/a_int.c
+++ b/src/lib/libcrypto/asn1/a_int.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: a_int.c,v 1.45 2022/08/20 18:17:33 jsing Exp $ */ 1/* $OpenBSD: a_int.c,v 1.46 2022/08/28 17:49:25 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -553,7 +553,9 @@ i2c_ASN1_INTEGER_cbb(ASN1_INTEGER *aint, CBB *cbb)
553 CBS cbs; 553 CBS cbs;
554 int ret = 0; 554 int ret = 0;
555 555
556 if (aint->data == NULL || aint->length < 0) 556 if (aint->length < 0)
557 goto err;
558 if (aint->data == NULL && aint->length != 0)
557 goto err; 559 goto err;
558 560
559 if ((aint->type & ~V_ASN1_NEG) != V_ASN1_ENUMERATED && 561 if ((aint->type & ~V_ASN1_NEG) != V_ASN1_ENUMERATED &&