summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortb <>2025-01-27 08:05:02 +0000
committertb <>2025-01-27 08:05:02 +0000
commit64baf058c75b35d02155679035668c4b7d001892 (patch)
treea22e29790cd4eb2a4dc7f9f8a9ba1e5656a2d7c9
parentfcdc9e4a3316f2f8313cdb8cd932083814d800e0 (diff)
downloadopenbsd-64baf058c75b35d02155679035668c4b7d001892.tar.gz
openbsd-64baf058c75b35d02155679035668c4b7d001892.tar.bz2
openbsd-64baf058c75b35d02155679035668c4b7d001892.zip
X509_NAME_print: NUL-terminate and switch to BIO_printf()
This handles the empty string, which ruby-openssl checks. Pointed out by anton
-rw-r--r--src/lib/libcrypto/asn1/t_x509.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/lib/libcrypto/asn1/t_x509.c b/src/lib/libcrypto/asn1/t_x509.c
index 669aec0093..d71e2d2e9a 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.48 2025/01/26 20:18:26 tb Exp $ */ 1/* $OpenBSD: t_x509.c,v 1.49 2025/01/27 08:05:02 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 *
@@ -549,13 +549,16 @@ X509_NAME_print(BIO *bio, const X509_NAME *name, int obase)
549 started = 1; 549 started = 1;
550 } 550 }
551 551
552 if (!CBB_add_u8(&cbb, '\0'))
553 goto err;
554
552 if (!CBB_finish(&cbb, &buf, &buf_len)) 555 if (!CBB_finish(&cbb, &buf, &buf_len))
553 goto err; 556 goto err;
554 557
555 if (buf_len > INT_MAX) 558 if (buf_len > INT_MAX)
556 goto err; 559 goto err;
557 560
558 if (BIO_write(bio, buf, buf_len) <= 0) 561 if (BIO_printf(bio, "%s", buf) < 0)
559 goto err; 562 goto err;
560 563
561 ret = 1; 564 ret = 1;