From 9242b0b903dd7cf75ec56486b4c88314c99168ca Mon Sep 17 00:00:00 2001 From: tb <> Date: Wed, 10 Jan 2024 14:22:53 +0000 Subject: Fix print_fp() The callback-based printing needs to die. But first BIO_set() will die. We have a FILE *. We have fprintf(). No need to use a static BIO to dump error codes to said stream. This basically undoes an unrelated change of "Move crpytlib.h prior bio.h" from 19 years ago (OpenSSL 25a66ee3). Except we don't cast and check len. ok jsing (who had a nearly identical diff) --- src/lib/libcrypto/err/err_prn.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/lib/libcrypto') diff --git a/src/lib/libcrypto/err/err_prn.c b/src/lib/libcrypto/err/err_prn.c index d60cfdcb92..16d8862a82 100644 --- a/src/lib/libcrypto/err/err_prn.c +++ b/src/lib/libcrypto/err/err_prn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: err_prn.c,v 1.20 2023/07/07 13:54:45 beck Exp $ */ +/* $OpenBSD: err_prn.c,v 1.21 2024/01/10 14:22:53 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -56,6 +56,7 @@ * [including the GNU Public Licence.] */ +#include #include #include @@ -93,12 +94,9 @@ LCRYPTO_ALIAS(ERR_print_errors_cb); static int print_fp(const char *str, size_t len, void *fp) { - BIO bio; - - BIO_set(&bio, BIO_s_file()); - BIO_set_fp(&bio, fp, BIO_NOCLOSE); - - return BIO_printf(&bio, "%s", str); + if (len > INT_MAX) + return -1; + return fprintf(fp, "%.*s", (int)len, str); } void -- cgit v1.2.3-55-g6feb