summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorschwarze <>2021-07-10 17:45:16 +0000
committerschwarze <>2021-07-10 17:45:16 +0000
commitc54835c3a81aadeb800379d608c618fcc193a794 (patch)
treeff716403ef1e0677728570a873deec57e3889204 /src/lib
parent295a48e4f7e26e62353f13d97f649d07bf435662 (diff)
downloadopenbsd-c54835c3a81aadeb800379d608c618fcc193a794.tar.gz
openbsd-c54835c3a81aadeb800379d608c618fcc193a794.tar.bz2
openbsd-c54835c3a81aadeb800379d608c618fcc193a794.zip
Fix a read buffer overrun in X509_CERT_AUX_print(3),
which by implication also affects X509_print(3). The ASN1_STRING_get0_data(3) manual explitely cautions the reader that the data is not necessarily NUL-terminated, and the function X509_alias_set1(3) does not sanitize the data passed into it in any way either, so we must assume the alias->data field is merely a byte array and not necessarily a string in the sense of the C language. I found this bug while writing manual pages for these functions. OK tb@ As an aside, note that the function still produces incomplete and misleading results when the data contains a NUL byte in the middle and that error handling is consistently absent throughout, even though the function provides an "int" return value obviously intended to be 1 for success and 0 for failure, and even though this function is called by another function that also wants to return 1 for success and 0 for failure and even does so in many of its code paths, though not in others. But let's stay focussed. Many things would be nice to have in the wide wild world, but a buffer overflow must not be allowed to remain in our backyard.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/asn1/t_x509a.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/lib/libcrypto/asn1/t_x509a.c b/src/lib/libcrypto/asn1/t_x509a.c
index fd68211b84..b0346fa681 100644
--- a/src/lib/libcrypto/asn1/t_x509a.c
+++ b/src/lib/libcrypto/asn1/t_x509a.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: t_x509a.c,v 1.8 2014/07/11 08:44:47 jsing Exp $ */ 1/* $OpenBSD: t_x509a.c,v 1.9 2021/07/10 17:45:16 schwarze 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 1999. 3 * project 1999.
4 */ 4 */
@@ -105,8 +105,8 @@ X509_CERT_AUX_print(BIO *out, X509_CERT_AUX *aux, int indent)
105 } else 105 } else
106 BIO_printf(out, "%*sNo Rejected Uses.\n", indent, ""); 106 BIO_printf(out, "%*sNo Rejected Uses.\n", indent, "");
107 if (aux->alias) 107 if (aux->alias)
108 BIO_printf(out, "%*sAlias: %s\n", indent, "", 108 BIO_printf(out, "%*sAlias: %.*s\n", indent, "",
109 aux->alias->data); 109 aux->alias->length, aux->alias->data);
110 if (aux->keyid) { 110 if (aux->keyid) {
111 BIO_printf(out, "%*sKey Id: ", indent, ""); 111 BIO_printf(out, "%*sKey Id: ", indent, "");
112 for (i = 0; i < aux->keyid->length; i++) 112 for (i = 0; i < aux->keyid->length; i++)