BIO_set_retry_reason
BIO_set_shutdown
BIO_set_tcp_ndelay
-BIO_snprintf
BIO_sock_cleanup
BIO_sock_error
BIO_sock_init
BIO_test_flags
BIO_up_ref
BIO_vfree
-BIO_vprintf
-BIO_vsnprintf
BIO_write
BN_CTX_end
BN_CTX_free
_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
-/* $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
fail:
return (ret);
}
-LCRYPTO_ALIAS(BIO_vprintf);
#else /* !HAVE_FUNOPEN */
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);
-/* $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.
*
#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);
-/* $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.
*
#ifndef HEADER_BIO_LOCAL_H
#define HEADER_BIO_LOCAL_H
+#include <stdarg.h>
+
__BEGIN_HIDDEN_DECLS
struct bio_method_st {
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 */
-/* $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>
#include <openssl/bio.h>
#include <openssl/bn.h>
+#include "bio_local.h"
#include "bn_local.h"
#include "bytestring.h"
-/* $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>
*
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 */
-.\" $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>
.\" 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
.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 .