From: tb Date: Sat, 2 Mar 2024 09:18:28 +0000 (+0000) Subject: Remove BIO_{sn,v,vsn}printf(3) X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=8bb5c4c3224143edd7f111344f3d0928006433fa;p=openbsd Remove BIO_{sn,v,vsn}printf(3) Unsued printing functionality. If something should need this we can readily add it back. ok jsing --- diff --git a/lib/libcrypto/Symbols.list b/lib/libcrypto/Symbols.list index a801880ecc5..7877295ccb5 100644 --- a/lib/libcrypto/Symbols.list +++ b/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/lib/libcrypto/Symbols.namespace b/lib/libcrypto/Symbols.namespace index c35225e7981..04ea27935c9 100644 --- a/lib/libcrypto/Symbols.namespace +++ b/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/lib/libcrypto/bio/b_print.c b/lib/libcrypto/bio/b_print.c index a750ac413f7..f6943ea3f38 100644 --- a/lib/libcrypto/bio/b_print.c +++ b/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 -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/lib/libcrypto/bio/bio.h b/lib/libcrypto/bio/bio.h index b955524c456..10b0924f73e 100644 --- a/lib/libcrypto/bio/bio.h +++ b/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/lib/libcrypto/bio/bio_local.h b/lib/libcrypto/bio/bio_local.h index 4eecf7e04a2..f59b5756c99 100644 --- a/lib/libcrypto/bio/bio_local.h +++ b/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 + __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/lib/libcrypto/bn/bn_print.c b/lib/libcrypto/bn/bn_print.c index e7678f7a990..cd8b663602e 100644 --- a/lib/libcrypto/bn/bn_print.c +++ b/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 @@ -25,6 +25,7 @@ #include #include +#include "bio_local.h" #include "bn_local.h" #include "bytestring.h" diff --git a/lib/libcrypto/hidden/openssl/bio.h b/lib/libcrypto/hidden/openssl/bio.h index f7e7cd3d8e7..61664713065 100644 --- a/lib/libcrypto/hidden/openssl/bio.h +++ b/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 * @@ -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/lib/libcrypto/man/BIO_printf.3 b/lib/libcrypto/man/BIO_printf.3 index 838b771be7b..32dec0a8283 100644 --- a/lib/libcrypto/man/BIO_printf.3 +++ b/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 @@ -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 .