From 0ad809a3e5e65ac5128296f24014a9b037cbed24 Mon Sep 17 00:00:00 2001
From: tb <>
Date: Sat, 2 Mar 2024 09:18:28 +0000
Subject: Remove BIO_{sn,v,vsn}printf(3)

Unsued printing functionality. If something should need this we can readily
add it back.

ok jsing
---
 src/lib/libcrypto/Symbols.list         |  3 --
 src/lib/libcrypto/Symbols.namespace    |  3 --
 src/lib/libcrypto/bio/b_print.c        | 59 +++-------------------------------
 src/lib/libcrypto/bio/bio.h            | 18 +----------
 src/lib/libcrypto/bio/bio_local.h      |  6 +++-
 src/lib/libcrypto/bn/bn_print.c        |  3 +-
 src/lib/libcrypto/hidden/openssl/bio.h |  5 +--
 src/lib/libcrypto/man/BIO_printf.3     | 59 +++-------------------------------
 8 files changed, 18 insertions(+), 138 deletions(-)

(limited to 'src/lib')

diff --git a/src/lib/libcrypto/Symbols.list b/src/lib/libcrypto/Symbols.list
index a801880ecc..7877295ccb 100644
--- a/src/lib/libcrypto/Symbols.list
+++ b/src/lib/libcrypto/Symbols.list
@@ -332,7 +332,6 @@ BIO_set_next
 BIO_set_retry_reason
 BIO_set_shutdown
 BIO_set_tcp_ndelay
-BIO_snprintf
 BIO_sock_cleanup
 BIO_sock_error
 BIO_sock_init
@@ -343,8 +342,6 @@ BIO_socket_nbio
 BIO_test_flags
 BIO_up_ref
 BIO_vfree
-BIO_vprintf
-BIO_vsnprintf
 BIO_write
 BN_CTX_end
 BN_CTX_free
diff --git a/src/lib/libcrypto/Symbols.namespace b/src/lib/libcrypto/Symbols.namespace
index c35225e798..04ea27935c 100644
--- a/src/lib/libcrypto/Symbols.namespace
+++ b/src/lib/libcrypto/Symbols.namespace
@@ -1215,9 +1215,6 @@ _libre_BIO_new_connect
 _libre_BIO_new_accept
 _libre_BIO_copy_next_retry
 _libre_BIO_printf
-_libre_BIO_vprintf
-_libre_BIO_snprintf
-_libre_BIO_vsnprintf
 _libre_ERR_load_BIO_strings
 _libre_ASN1_item_ex_new
 _libre_ASN1_item_ex_free
diff --git a/src/lib/libcrypto/bio/b_print.c b/src/lib/libcrypto/bio/b_print.c
index a750ac413f..f6943ea3f3 100644
--- a/src/lib/libcrypto/bio/b_print.c
+++ b/src/lib/libcrypto/bio/b_print.c
@@ -1,21 +1,10 @@
-/* $OpenBSD: b_print.c,v 1.27 2023/07/05 21:23:37 beck Exp $ */
+/* $OpenBSD: b_print.c,v 1.28 2024/03/02 09:18:28 tb Exp $ */
 
 /* Theo de Raadt places this file in the public domain. */
 
 #include <openssl/bio.h>
 
-int
-BIO_printf(BIO *bio, const char *format, ...)
-{
-	va_list args;
-	int ret;
-
-	va_start(args, format);
-	ret = BIO_vprintf(bio, format, args);
-	va_end(args);
-	return (ret);
-}
-LCRYPTO_ALIAS(BIO_printf);
+#include "bio_local.h"
 
 #ifdef HAVE_FUNOPEN
 static int
@@ -40,7 +29,6 @@ BIO_vprintf(BIO *bio, const char *format, va_list args)
 fail:
 	return (ret);
 }
-LCRYPTO_ALIAS(BIO_vprintf);
 
 #else /* !HAVE_FUNOPEN */
 
@@ -57,55 +45,18 @@ BIO_vprintf(BIO *bio, const char *format, va_list args)
 	free(buf);
 	return (ret);
 }
-LCRYPTO_ALIAS(BIO_vprintf);
 
 #endif /* HAVE_FUNOPEN */
 
-/*
- * BIO_snprintf and BIO_vsnprintf return -1 for overflow,
- * due to the history of this API.  Justification:
- *
- * Traditional snprintf surfaced in 4.4BSD, and returned
- * "number of bytes wanted". Solaris and Windows opted to
- * return -1.  A draft standard was written which returned -1.
- * Due to the large volume of code already using the first
- * semantics, the draft was repaired before standardization to
- * specify "number of bytes wanted" plus "-1 for character conversion
- * style errors".  Solaris adapted to this rule, but Windows stuck
- * with -1.
- *
- * Original OpenSSL comment which is full of lies:
- *
- * "In case of truncation, return -1 like traditional snprintf.
- * (Current drafts for ISO/IEC 9899 say snprintf should return
- * the number of characters that would have been written,
- * had the buffer been large enough.)"
- */
 int
-BIO_snprintf(char *buf, size_t n, const char *format, ...)
+BIO_printf(BIO *bio, const char *format, ...)
 {
 	va_list args;
 	int ret;
 
 	va_start(args, format);
-	ret = vsnprintf(buf, n, format, args);
+	ret = BIO_vprintf(bio, format, args);
 	va_end(args);
-
-	if (ret >= n || ret == -1)
-		return (-1);
-	return (ret);
-}
-LCRYPTO_ALIAS(BIO_snprintf);
-
-int
-BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args)
-{
-	int ret;
-
-	ret = vsnprintf(buf, n, format, args);
-
-	if (ret >= n || ret == -1)
-		return (-1);
 	return (ret);
 }
-LCRYPTO_ALIAS(BIO_vsnprintf);
+LCRYPTO_ALIAS(BIO_printf);
diff --git a/src/lib/libcrypto/bio/bio.h b/src/lib/libcrypto/bio/bio.h
index b955524c45..10b0924f73 100644
--- a/src/lib/libcrypto/bio/bio.h
+++ b/src/lib/libcrypto/bio/bio.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bio.h,v 1.60 2023/08/25 12:37:33 schwarze Exp $ */
+/* $OpenBSD: bio.h,v 1.61 2024/03/02 09:18:28 tb Exp $ */
 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
@@ -648,25 +648,9 @@ void BIO_copy_next_retry(BIO *b);
 #ifndef __MINGW_PRINTF_FORMAT
 int BIO_printf(BIO *bio, const char *format, ...)
 	__attribute__((__format__(__printf__, 2, 3), __nonnull__(2)));
-int BIO_vprintf(BIO *bio, const char *format, va_list args)
-	__attribute__((__format__(__printf__, 2, 0), __nonnull__(2)));
-int BIO_snprintf(char *buf, size_t n, const char *format, ...)
-	__attribute__((__deprecated__, __format__(__printf__, 3, 4),
-	    __nonnull__(3)));
-int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args)
-	__attribute__((__deprecated__, __format__(__printf__, 3, 0),
-	    __nonnull__(3)));
 #else
 int BIO_printf(BIO *bio, const char *format, ...)
 	__attribute__((__format__(__MINGW_PRINTF_FORMAT, 2, 3), __nonnull__(2)));
-int BIO_vprintf(BIO *bio, const char *format, va_list args)
-	__attribute__((__format__(__MINGW_PRINTF_FORMAT, 2, 0), __nonnull__(2)));
-int BIO_snprintf(char *buf, size_t n, const char *format, ...)
-	__attribute__((__deprecated__, __format__(__MINGW_PRINTF_FORMAT, 3, 4),
-	    __nonnull__(3)));
-int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args)
-	__attribute__((__deprecated__, __format__(__MINGW_PRINTF_FORMAT, 3, 0),
-	    __nonnull__(3)));
 #endif
 
 void ERR_load_BIO_strings(void);
diff --git a/src/lib/libcrypto/bio/bio_local.h b/src/lib/libcrypto/bio/bio_local.h
index 4eecf7e04a..f59b5756c9 100644
--- a/src/lib/libcrypto/bio/bio_local.h
+++ b/src/lib/libcrypto/bio/bio_local.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bio_local.h,v 1.5 2022/12/02 19:44:04 tb Exp $ */
+/* $OpenBSD: bio_local.h,v 1.6 2024/03/02 09:18:28 tb Exp $ */
 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
@@ -59,6 +59,8 @@
 #ifndef HEADER_BIO_LOCAL_H
 #define HEADER_BIO_LOCAL_H
 
+#include <stdarg.h>
+
 __BEGIN_HIDDEN_DECLS
 
 struct bio_method_st {
@@ -118,6 +120,8 @@ typedef struct bio_f_buffer_ctx_struct {
 	int obuf_off;	/* write/read offset */
 } BIO_F_BUFFER_CTX;
 
+int BIO_vprintf(BIO *bio, const char *format, va_list args);
+
 __END_HIDDEN_DECLS
 
 #endif /* !HEADER_BIO_LOCAL_H */
diff --git a/src/lib/libcrypto/bn/bn_print.c b/src/lib/libcrypto/bn/bn_print.c
index e7678f7a99..cd8b663602 100644
--- a/src/lib/libcrypto/bn/bn_print.c
+++ b/src/lib/libcrypto/bn/bn_print.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: bn_print.c,v 1.46 2023/07/22 17:14:08 tb Exp $ */
+/*	$OpenBSD: bn_print.c,v 1.47 2024/03/02 09:18:28 tb Exp $ */
 
 /*
  * Copyright (c) 2023 Theo Buehler <tb@openbsd.org>
@@ -25,6 +25,7 @@
 #include <openssl/bio.h>
 #include <openssl/bn.h>
 
+#include "bio_local.h"
 #include "bn_local.h"
 #include "bytestring.h"
 
diff --git a/src/lib/libcrypto/hidden/openssl/bio.h b/src/lib/libcrypto/hidden/openssl/bio.h
index f7e7cd3d8e..6166471306 100644
--- a/src/lib/libcrypto/hidden/openssl/bio.h
+++ b/src/lib/libcrypto/hidden/openssl/bio.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bio.h,v 1.4 2023/07/28 10:13:50 tb Exp $ */
+/* $OpenBSD: bio.h,v 1.5 2024/03/02 09:18:28 tb Exp $ */
 /*
  * Copyright (c) 2023 Bob Beck <beck@openbsd.org>
  *
@@ -138,9 +138,6 @@ LCRYPTO_USED(BIO_new_connect);
 LCRYPTO_USED(BIO_new_accept);
 LCRYPTO_USED(BIO_copy_next_retry);
 LCRYPTO_USED(BIO_printf);
-LCRYPTO_USED(BIO_vprintf);
-LCRYPTO_USED(BIO_snprintf);
-LCRYPTO_USED(BIO_vsnprintf);
 LCRYPTO_USED(ERR_load_BIO_strings);
 
 #endif /* _LIBCRYPTO_BIO_H */
diff --git a/src/lib/libcrypto/man/BIO_printf.3 b/src/lib/libcrypto/man/BIO_printf.3
index 838b771be7..32dec0a828 100644
--- a/src/lib/libcrypto/man/BIO_printf.3
+++ b/src/lib/libcrypto/man/BIO_printf.3
@@ -1,4 +1,4 @@
-.\"	$OpenBSD: BIO_printf.3,v 1.3 2018/03/22 17:11:04 schwarze Exp $
+.\"	$OpenBSD: BIO_printf.3,v 1.4 2024/03/02 09:18:28 tb Exp $
 .\"	OpenSSL 2ca2e917 Mon Mar 20 16:25:22 2017 -0400
 .\"
 .\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -15,14 +15,11 @@
 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 .\"
-.Dd $Mdocdate: March 22 2018 $
+.Dd $Mdocdate: March 2 2024 $
 .Dt BIO_PRINTF 3
 .Os
 .Sh NAME
-.Nm BIO_printf ,
-.Nm BIO_vprintf ,
-.Nm BIO_snprintf ,
-.Nm BIO_vsnprintf
+.Nm BIO_printf
 .Nd formatted output to a BIO
 .Sh SYNOPSIS
 .In openssl/bio.h
@@ -32,66 +29,18 @@
 .Fa "const char *format"
 .Fa ...
 .Fc
-.Ft int
-.Fo BIO_vprintf
-.Fa "BIO *bio"
-.Fa "const char *format"
-.Fa "va_list args"
-.Fc
-.Ft int
-.Fo BIO_snprintf
-.Fa "char *buf"
-.Fa "size_t n"
-.Fa "const char *format"
-.Fa ...
-.Fc
-.Ft int
-.Fo BIO_vsnprintf
-.Fa "char *buf"
-.Fa "size_t n"
-.Fa "const char *format"
-.Fa "va_list args"
-.Fc
 .Sh DESCRIPTION
-.Fn BIO_vprintf
+.Fn BIO_printf
 is a wrapper around
 .Xr vfprintf 3 ,
 sending the output to the specified
 .Fa bio .
-.Pp
-.Fn BIO_printf
-is a wrapper around
-.Fn BIO_vprintf .
-.Pp
-.Fn BIO_snprintf
-and
-.Fn BIO_vsnprintf
-are wrappers around
-.Xr vsnprintf 3 .
 .Sh RETURN VALUES
 These functions return the number of bytes written,
 or -1 if an error occurs.
-.Pp
-In contrast to
-.Xr snprintf 3
-and
-.Xr vsnprintf 3 ,
-.Fn BIO_snprintf
-and
-.Fn BIO_vsnprintf
-also return -1 if
-.Fa n
-is too small to hold the complete output.
 .Sh SEE ALSO
 .Xr BIO_new 3
 .Sh HISTORY
 .Fn BIO_printf
 first appeared in SSLeay 0.6.5 and has been available since
 .Ox 2.4 .
-.Pp
-.Fn BIO_vprintf ,
-.Fn BIO_snprintf ,
-and
-.Fn BIO_vsnprintf
-first appeared in OpenSSL 0.9.6 and have been available since
-.Ox 2.9 .
-- 
cgit v1.2.3-55-g6feb