summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2024-01-10 14:22:53 +0000
committertb <>2024-01-10 14:22:53 +0000
commit9242b0b903dd7cf75ec56486b4c88314c99168ca (patch)
tree42d8d1e0fe8b5b494f973b2463aea93a7a7c2ad0 /src
parent594b886b999265c72df148ccc4ca133cff208074 (diff)
downloadopenbsd-9242b0b903dd7cf75ec56486b4c88314c99168ca.tar.gz
openbsd-9242b0b903dd7cf75ec56486b4c88314c99168ca.tar.bz2
openbsd-9242b0b903dd7cf75ec56486b4c88314c99168ca.zip
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)
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/err/err_prn.c12
1 files changed, 5 insertions, 7 deletions
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 @@
1/* $OpenBSD: err_prn.c,v 1.20 2023/07/07 13:54:45 beck Exp $ */ 1/* $OpenBSD: err_prn.c,v 1.21 2024/01/10 14:22:53 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 *
@@ -56,6 +56,7 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59#include <limits.h>
59#include <stdio.h> 60#include <stdio.h>
60#include <string.h> 61#include <string.h>
61 62
@@ -93,12 +94,9 @@ LCRYPTO_ALIAS(ERR_print_errors_cb);
93static int 94static int
94print_fp(const char *str, size_t len, void *fp) 95print_fp(const char *str, size_t len, void *fp)
95{ 96{
96 BIO bio; 97 if (len > INT_MAX)
97 98 return -1;
98 BIO_set(&bio, BIO_s_file()); 99 return fprintf(fp, "%.*s", (int)len, str);
99 BIO_set_fp(&bio, fp, BIO_NOCLOSE);
100
101 return BIO_printf(&bio, "%s", str);
102} 100}
103 101
104void 102void