diff options
author | deraadt <> | 2014-06-11 15:08:43 +0000 |
---|---|---|
committer | deraadt <> | 2014-06-11 15:08:43 +0000 |
commit | b9b725514027a560daae1c5518c700360b5764bc (patch) | |
tree | 83720c7796a5f39d4327d7cb7fafd984f53ac72d | |
parent | edeec798f517bbf85e9b72eba5ead0073a68fb73 (diff) | |
download | openbsd-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.c | 38 | ||||
-rw-r--r-- | src/lib/libcrypto/crypto/Makefile | 4 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/bio/b_print.c | 38 |
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 | ||
6 | static int | ||
7 | _BIO_write(void *cookie, const char *buf, int nbytes) | ||
8 | { | ||
9 | return BIO_write(cookie, buf, nbytes); | ||
10 | } | ||
11 | |||
12 | int | 6 | int |
13 | BIO_printf(BIO *bio, const char *format, ...) | 7 | BIO_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 | ||
19 | static int | ||
20 | _BIO_write(void *cookie, const char *buf, int nbytes) | ||
21 | { | ||
22 | return BIO_write(cookie, buf, nbytes); | ||
23 | } | ||
24 | |||
24 | int | 25 | int |
25 | BIO_vprintf(BIO *bio, const char *format, va_list args) | 26 | BIO_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 | |||
44 | int | ||
45 | BIO_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); | ||
57 | fail: | ||
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 | ||
3 | LIB= crypto | 3 | LIB= 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) |
12 | CFLAGS+= -DDSO_DLFCN -DHAVE_DLFCN_H | 12 | CFLAGS+= -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 | ||
6 | static int | ||
7 | _BIO_write(void *cookie, const char *buf, int nbytes) | ||
8 | { | ||
9 | return BIO_write(cookie, buf, nbytes); | ||
10 | } | ||
11 | |||
12 | int | 6 | int |
13 | BIO_printf(BIO *bio, const char *format, ...) | 7 | BIO_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 | ||
19 | static int | ||
20 | _BIO_write(void *cookie, const char *buf, int nbytes) | ||
21 | { | ||
22 | return BIO_write(cookie, buf, nbytes); | ||
23 | } | ||
24 | |||
24 | int | 25 | int |
25 | BIO_vprintf(BIO *bio, const char *format, va_list args) | 26 | BIO_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 | |||
44 | int | ||
45 | BIO_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); | ||
57 | fail: | ||
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: |