summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorderaadt <>2014-06-11 15:08:43 +0000
committerderaadt <>2014-06-11 15:08:43 +0000
commitb9b725514027a560daae1c5518c700360b5764bc (patch)
tree83720c7796a5f39d4327d7cb7fafd984f53ac72d
parentedeec798f517bbf85e9b72eba5ead0073a68fb73 (diff)
downloadopenbsd-b9b725514027a560daae1c5518c700360b5764bc.tar.gz
openbsd-b9b725514027a560daae1c5518c700360b5764bc.tar.bz2
openbsd-b9b725514027a560daae1c5518c700360b5764bc.zip
Provide support for non-funopen systems.
ok beck
-rw-r--r--src/lib/libcrypto/bio/b_print.c38
-rw-r--r--src/lib/libcrypto/crypto/Makefile4
-rw-r--r--src/lib/libssl/src/crypto/bio/b_print.c38
3 files changed, 62 insertions, 18 deletions
diff --git a/src/lib/libcrypto/bio/b_print.c b/src/lib/libcrypto/bio/b_print.c
index 3a8fdcc821..a790bb0b7d 100644
--- a/src/lib/libcrypto/bio/b_print.c
+++ b/src/lib/libcrypto/bio/b_print.c
@@ -1,14 +1,8 @@
1/* $OpenBSD: b_print.c,v 1.22 2014/04/21 11:18:34 deraadt Exp $ */ 1/* $OpenBSD: b_print.c,v 1.23 2014/06/11 15:08:43 deraadt Exp $ */
2/* Theo de Raadt places this file in the public domain. */ 2/* Theo de Raadt places this file in the public domain. */
3 3
4#include <openssl/bio.h> 4#include <openssl/bio.h>
5 5
6static int
7_BIO_write(void *cookie, const char *buf, int nbytes)
8{
9 return BIO_write(cookie, buf, nbytes);
10}
11
12int 6int
13BIO_printf(BIO *bio, const char *format, ...) 7BIO_printf(BIO *bio, const char *format, ...)
14{ 8{
@@ -21,11 +15,18 @@ BIO_printf(BIO *bio, const char *format, ...)
21 return (ret); 15 return (ret);
22} 16}
23 17
18#ifdef HAVE_FUNOPEN
19static int
20_BIO_write(void *cookie, const char *buf, int nbytes)
21{
22 return BIO_write(cookie, buf, nbytes);
23}
24
24int 25int
25BIO_vprintf(BIO *bio, const char *format, va_list args) 26BIO_vprintf(BIO *bio, const char *format, va_list args)
26{ 27{
27 FILE *fp;
28 int ret; 28 int ret;
29 FILE *fp;
29 30
30 fp = funopen(bio, NULL, &_BIO_write, NULL, NULL); 31 fp = funopen(bio, NULL, &_BIO_write, NULL, NULL);
31 if (fp == NULL) { 32 if (fp == NULL) {
@@ -38,6 +39,27 @@ fail:
38 return (ret); 39 return (ret);
39} 40}
40 41
42#else /* !HAVE_FUNOPEN */
43
44int
45BIO_vprintf(BIO *bio, const char *format, va_list args)
46{
47 int ret;
48 char *buf = NULL;
49
50 ret = vasprintf(&buf, format, args);
51 if (buf == NULL) {
52 ret = -1
53 goto fail;
54 }
55 BIO_write(bio, buf, ret);
56 free(buf);
57fail:
58 return (ret);
59}
60
61#endif /* HAVE_FUNOPEN */
62
41/* 63/*
42 * BIO_snprintf and BIO_vsnprintf return -1 for overflow, 64 * BIO_snprintf and BIO_vsnprintf return -1 for overflow,
43 * due to the history of this API. Justification: 65 * due to the history of this API. Justification:
diff --git a/src/lib/libcrypto/crypto/Makefile b/src/lib/libcrypto/crypto/Makefile
index e71912dd57..c27985e113 100644
--- a/src/lib/libcrypto/crypto/Makefile
+++ b/src/lib/libcrypto/crypto/Makefile
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile,v 1.39 2014/06/10 16:15:19 deraadt Exp $ 1# $OpenBSD: Makefile,v 1.40 2014/06/11 15:08:41 deraadt Exp $
2 2
3LIB= crypto 3LIB= crypto
4 4
@@ -9,7 +9,7 @@ CFLAGS+= -Wall -Werror
9 9
10.include <bsd.own.mk> # for 'NOPIC' definition 10.include <bsd.own.mk> # for 'NOPIC' definition
11.if !defined(NOPIC) 11.if !defined(NOPIC)
12CFLAGS+= -DDSO_DLFCN -DHAVE_DLFCN_H 12CFLAGS+= -DDSO_DLFCN -DHAVE_DLFCN_H -DHAVE_FUNOPEN
13.endif 13.endif
14 14
15.if ${MACHINE_ARCH} == "sparc" 15.if ${MACHINE_ARCH} == "sparc"
diff --git a/src/lib/libssl/src/crypto/bio/b_print.c b/src/lib/libssl/src/crypto/bio/b_print.c
index 3a8fdcc821..a790bb0b7d 100644
--- a/src/lib/libssl/src/crypto/bio/b_print.c
+++ b/src/lib/libssl/src/crypto/bio/b_print.c
@@ -1,14 +1,8 @@
1/* $OpenBSD: b_print.c,v 1.22 2014/04/21 11:18:34 deraadt Exp $ */ 1/* $OpenBSD: b_print.c,v 1.23 2014/06/11 15:08:43 deraadt Exp $ */
2/* Theo de Raadt places this file in the public domain. */ 2/* Theo de Raadt places this file in the public domain. */
3 3
4#include <openssl/bio.h> 4#include <openssl/bio.h>
5 5
6static int
7_BIO_write(void *cookie, const char *buf, int nbytes)
8{
9 return BIO_write(cookie, buf, nbytes);
10}
11
12int 6int
13BIO_printf(BIO *bio, const char *format, ...) 7BIO_printf(BIO *bio, const char *format, ...)
14{ 8{
@@ -21,11 +15,18 @@ BIO_printf(BIO *bio, const char *format, ...)
21 return (ret); 15 return (ret);
22} 16}
23 17
18#ifdef HAVE_FUNOPEN
19static int
20_BIO_write(void *cookie, const char *buf, int nbytes)
21{
22 return BIO_write(cookie, buf, nbytes);
23}
24
24int 25int
25BIO_vprintf(BIO *bio, const char *format, va_list args) 26BIO_vprintf(BIO *bio, const char *format, va_list args)
26{ 27{
27 FILE *fp;
28 int ret; 28 int ret;
29 FILE *fp;
29 30
30 fp = funopen(bio, NULL, &_BIO_write, NULL, NULL); 31 fp = funopen(bio, NULL, &_BIO_write, NULL, NULL);
31 if (fp == NULL) { 32 if (fp == NULL) {
@@ -38,6 +39,27 @@ fail:
38 return (ret); 39 return (ret);
39} 40}
40 41
42#else /* !HAVE_FUNOPEN */
43
44int
45BIO_vprintf(BIO *bio, const char *format, va_list args)
46{
47 int ret;
48 char *buf = NULL;
49
50 ret = vasprintf(&buf, format, args);
51 if (buf == NULL) {
52 ret = -1
53 goto fail;
54 }
55 BIO_write(bio, buf, ret);
56 free(buf);
57fail:
58 return (ret);
59}
60
61#endif /* HAVE_FUNOPEN */
62
41/* 63/*
42 * BIO_snprintf and BIO_vsnprintf return -1 for overflow, 64 * BIO_snprintf and BIO_vsnprintf return -1 for overflow,
43 * due to the history of this API. Justification: 65 * due to the history of this API. Justification: