summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authortb <>2024-01-10 14:22:53 +0000
committertb <>2024-01-10 14:22:53 +0000
commitc3992a11119db57dd0ffed20dfdac0b7ecca39b8 (patch)
tree42d8d1e0fe8b5b494f973b2463aea93a7a7c2ad0 /src/lib
parent07e4a65c6531f89f40ce731f11090bc168df2576 (diff)
downloadopenbsd-c3992a11119db57dd0ffed20dfdac0b7ecca39b8.tar.gz
openbsd-c3992a11119db57dd0ffed20dfdac0b7ecca39b8.tar.bz2
openbsd-c3992a11119db57dd0ffed20dfdac0b7ecca39b8.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/lib')
-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