summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2022-08-10 11:15:08 +0000
committertb <>2022-08-10 11:15:08 +0000
commit59e7d7a474ef69602d2c336e05f4593856883a3b (patch)
tree08909fc6f12e70a0a853f695304765f6377ab7c3 /src
parent70837e3e4d47bc74e2f1c690564b3fcd50608ac4 (diff)
downloadopenbsd-59e7d7a474ef69602d2c336e05f4593856883a3b.tar.gz
openbsd-59e7d7a474ef69602d2c336e05f4593856883a3b.tar.bz2
openbsd-59e7d7a474ef69602d2c336e05f4593856883a3b.zip
Only print versions we know about
The version field of an X.509 Certificate is an enum Version ::= INTEGER { v1(0), v2(1), v3(2) } Printing the version as l + 1 only really makes sense with 0 <= l <= 2. Otherwise print a naked l while also indicating that it is an unknown version. ok jsing
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/asn1/t_x509.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/lib/libcrypto/asn1/t_x509.c b/src/lib/libcrypto/asn1/t_x509.c
index 563edac074..abcce54366 100644
--- a/src/lib/libcrypto/asn1/t_x509.c
+++ b/src/lib/libcrypto/asn1/t_x509.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: t_x509.c,v 1.37 2021/12/25 13:17:48 jsing Exp $ */ 1/* $OpenBSD: t_x509.c,v 1.38 2022/08/10 11:15:08 tb 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 *
@@ -137,9 +137,15 @@ X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag)
137 } 137 }
138 if (!(cflag & X509_FLAG_NO_VERSION)) { 138 if (!(cflag & X509_FLAG_NO_VERSION)) {
139 l = X509_get_version(x); 139 l = X509_get_version(x);
140 if (BIO_printf(bp, "%8sVersion: %lu (0x%lx)\n", 140 if (l >= 0 && l <= 2) {
141 "", l + 1, l) <= 0) 141 if (BIO_printf(bp, "%8sVersion: %ld (0x%lx)\n",
142 goto err; 142 "", l + 1, l) <= 0)
143 goto err;
144 } else {
145 if (BIO_printf(bp, "%8sVersion: unknown (%ld)\n",
146 "", l) <= 0)
147 goto err;
148 }
143 } 149 }
144 if (!(cflag & X509_FLAG_NO_SERIAL)) { 150 if (!(cflag & X509_FLAG_NO_SERIAL)) {
145 if (BIO_write(bp, " Serial Number:", 22) <= 0) 151 if (BIO_write(bp, " Serial Number:", 22) <= 0)