summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjsing <>2022-02-12 03:07:24 +0000
committerjsing <>2022-02-12 03:07:24 +0000
commit4f6b3f124aaba62ebcf7e04e6536475e0aa3d1d2 (patch)
tree24faa356502796536aea428de4b8a93d3628db09 /src
parent7676cf85d21fefda1d234d70fb1f1f519919aff8 (diff)
downloadopenbsd-4f6b3f124aaba62ebcf7e04e6536475e0aa3d1d2.tar.gz
openbsd-4f6b3f124aaba62ebcf7e04e6536475e0aa3d1d2.tar.bz2
openbsd-4f6b3f124aaba62ebcf7e04e6536475e0aa3d1d2.zip
Avoid potential single byte overread in asn1_parse2().
A fix for this was previously commited in r1.32, however while this added a bounds check the logic means we still fall through and perform the overread. Fix the logic such that we only log the error if the bounds check fails. While here, flip the test around such that we check for validity then print (which is more readable and matches earlier code). ok inoguchi@ tb@
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/asn1/asn1_par.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/lib/libcrypto/asn1/asn1_par.c b/src/lib/libcrypto/asn1/asn1_par.c
index 2d1c7b2b48..6c14f271b6 100644
--- a/src/lib/libcrypto/asn1/asn1_par.c
+++ b/src/lib/libcrypto/asn1/asn1_par.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: asn1_par.c,v 1.33 2022/01/20 10:49:56 inoguchi Exp $ */ 1/* $OpenBSD: asn1_par.c,v 1.34 2022/02/12 03:07:24 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 *
@@ -233,12 +233,13 @@ asn1_parse2(BIO *bp, const unsigned char **pp, long length, int offset,
233 goto end; 233 goto end;
234 } 234 }
235 } else if (tag == V_ASN1_BOOLEAN) { 235 } else if (tag == V_ASN1_BOOLEAN) {
236 if (len != 1 || p >= tot) { 236 if (len == 1 && p < tot) {
237 BIO_printf(bp, ":%u", p[0]);
238 } else {
237 if (BIO_write(bp, "Bad boolean\n", 239 if (BIO_write(bp, "Bad boolean\n",
238 12) <= 0) 240 12) <= 0)
239 goto end; 241 goto end;
240 } 242 }
241 BIO_printf(bp, ":%u", p[0]);
242 } else if (tag == V_ASN1_BMPSTRING) { 243 } else if (tag == V_ASN1_BMPSTRING) {
243 /* do the BMP thang */ 244 /* do the BMP thang */
244 } else if (tag == V_ASN1_OCTET_STRING) { 245 } else if (tag == V_ASN1_OCTET_STRING) {