diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2014-06-11 15:08:44 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2014-06-11 15:08:44 +0000 |
commit | 88f454d8f6e93255573600a08a8359826d49be79 (patch) | |
tree | 380b8be26a65e8cad65a44132d36b51bbf9242bc | |
parent | 2c32084c460d0b5a4b591cb446cbd4cb119304d7 (diff) |
Provide support for non-funopen systems.
ok beck
-rw-r--r-- | lib/libcrypto/crypto/Makefile | 4 | ||||
-rw-r--r-- | lib/libssl/src/crypto/bio/b_print.c | 38 |
2 files changed, 32 insertions, 10 deletions
diff --git a/lib/libcrypto/crypto/Makefile b/lib/libcrypto/crypto/Makefile index e71912dd575..c27985e1139 100644 --- a/lib/libcrypto/crypto/Makefile +++ b/lib/libcrypto/crypto/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.39 2014/06/10 16:15:19 deraadt Exp $ +# $OpenBSD: Makefile,v 1.40 2014/06/11 15:08:41 deraadt Exp $ LIB= crypto @@ -9,7 +9,7 @@ CFLAGS+= -Wall -Werror .include <bsd.own.mk> # for 'NOPIC' definition .if !defined(NOPIC) -CFLAGS+= -DDSO_DLFCN -DHAVE_DLFCN_H +CFLAGS+= -DDSO_DLFCN -DHAVE_DLFCN_H -DHAVE_FUNOPEN .endif .if ${MACHINE_ARCH} == "sparc" diff --git a/lib/libssl/src/crypto/bio/b_print.c b/lib/libssl/src/crypto/bio/b_print.c index 3a8fdcc8213..a790bb0b7da 100644 --- a/lib/libssl/src/crypto/bio/b_print.c +++ b/lib/libssl/src/crypto/bio/b_print.c @@ -1,14 +1,8 @@ -/* $OpenBSD: b_print.c,v 1.22 2014/04/21 11:18:34 deraadt Exp $ */ +/* $OpenBSD: b_print.c,v 1.23 2014/06/11 15:08:43 deraadt Exp $ */ /* Theo de Raadt places this file in the public domain. */ #include <openssl/bio.h> -static int -_BIO_write(void *cookie, const char *buf, int nbytes) -{ - return BIO_write(cookie, buf, nbytes); -} - int BIO_printf(BIO *bio, const char *format, ...) { @@ -21,11 +15,18 @@ BIO_printf(BIO *bio, const char *format, ...) return (ret); } +#ifdef HAVE_FUNOPEN +static int +_BIO_write(void *cookie, const char *buf, int nbytes) +{ + return BIO_write(cookie, buf, nbytes); +} + int BIO_vprintf(BIO *bio, const char *format, va_list args) { - FILE *fp; int ret; + FILE *fp; fp = funopen(bio, NULL, &_BIO_write, NULL, NULL); if (fp == NULL) { @@ -38,6 +39,27 @@ fail: return (ret); } +#else /* !HAVE_FUNOPEN */ + +int +BIO_vprintf(BIO *bio, const char *format, va_list args) +{ + int ret; + char *buf = NULL; + + ret = vasprintf(&buf, format, args); + if (buf == NULL) { + ret = -1 + goto fail; + } + BIO_write(bio, buf, ret); + free(buf); +fail: + return (ret); +} + +#endif /* HAVE_FUNOPEN */ + /* * BIO_snprintf and BIO_vsnprintf return -1 for overflow, * due to the history of this API. Justification: |