summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bio
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/bio')
-rw-r--r--src/lib/libcrypto/bio/Makefile222
-rw-r--r--src/lib/libcrypto/bio/b_sock.c29
-rw-r--r--src/lib/libcrypto/bio/bf_nbio.c2
-rw-r--r--src/lib/libcrypto/bio/bio_lcl.h36
-rw-r--r--src/lib/libcrypto/bio/bio_lib.c4
-rw-r--r--src/lib/libcrypto/bio/bss_acpt.c5
-rw-r--r--src/lib/libcrypto/bio/bss_dgram.c20
-rw-r--r--src/lib/libcrypto/bio/bss_file.c12
-rw-r--r--src/lib/libcrypto/bio/bss_log.c32
-rw-r--r--src/lib/libcrypto/bio/bss_rtcp.c294
10 files changed, 573 insertions, 83 deletions
diff --git a/src/lib/libcrypto/bio/Makefile b/src/lib/libcrypto/bio/Makefile
new file mode 100644
index 0000000000..c395d80496
--- /dev/null
+++ b/src/lib/libcrypto/bio/Makefile
@@ -0,0 +1,222 @@
1#
2# OpenSSL/crypto/bio/Makefile
3#
4
5DIR= bio
6TOP= ../..
7CC= cc
8INCLUDES= -I.. -I$(TOP) -I../../include
9CFLAG=-g
10MAKEFILE= Makefile
11AR= ar r
12
13CFLAGS= $(INCLUDES) $(CFLAG)
14
15GENERAL=Makefile
16TEST=
17APPS=
18
19LIB=$(TOP)/libcrypto.a
20LIBSRC= bio_lib.c bio_cb.c bio_err.c \
21 bss_mem.c bss_null.c bss_fd.c \
22 bss_file.c bss_sock.c bss_conn.c \
23 bf_null.c bf_buff.c b_print.c b_dump.c \
24 b_sock.c bss_acpt.c bf_nbio.c bss_log.c bss_bio.c \
25 bss_dgram.c
26# bf_lbuf.c
27LIBOBJ= bio_lib.o bio_cb.o bio_err.o \
28 bss_mem.o bss_null.o bss_fd.o \
29 bss_file.o bss_sock.o bss_conn.o \
30 bf_null.o bf_buff.o b_print.o b_dump.o \
31 b_sock.o bss_acpt.o bf_nbio.o bss_log.o bss_bio.o \
32 bss_dgram.o
33# bf_lbuf.o
34
35SRC= $(LIBSRC)
36
37EXHEADER= bio.h
38HEADER= bio_lcl.h $(EXHEADER)
39
40ALL= $(GENERAL) $(SRC) $(HEADER)
41
42top:
43 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
44
45all: lib
46
47lib: $(LIBOBJ)
48 $(AR) $(LIB) $(LIBOBJ)
49 $(RANLIB) $(LIB) || echo Never mind.
50 @touch lib
51
52files:
53 $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
54
55links:
56 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
57 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
58 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
59
60install:
61 @[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
62 @headerlist="$(EXHEADER)"; for i in $$headerlist; \
63 do \
64 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
65 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
66 done;
67
68tags:
69 ctags $(SRC)
70
71tests:
72
73lint:
74 lint -DLINT $(INCLUDES) $(SRC)>fluff
75
76depend:
77 @[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile...
78 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
79
80dclean:
81 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
82 mv -f Makefile.new $(MAKEFILE)
83
84clean:
85 rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
86
87# DO NOT DELETE THIS LINE -- make depend depends on it.
88
89b_dump.o: ../../e_os.h ../../include/openssl/bio.h
90b_dump.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
91b_dump.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
92b_dump.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
93b_dump.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
94b_dump.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
95b_dump.o: ../../include/openssl/symhacks.h ../cryptlib.h b_dump.c bio_lcl.h
96b_print.o: ../../e_os.h ../../include/openssl/bio.h ../../include/openssl/bn.h
97b_print.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
98b_print.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
99b_print.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
100b_print.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
101b_print.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
102b_print.o: ../../include/openssl/symhacks.h ../cryptlib.h b_print.c
103b_sock.o: ../../e_os.h ../../include/openssl/bio.h
104b_sock.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
105b_sock.o: ../../include/openssl/dso.h ../../include/openssl/e_os2.h
106b_sock.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
107b_sock.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
108b_sock.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
109b_sock.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
110b_sock.o: ../cryptlib.h b_sock.c
111bf_buff.o: ../../e_os.h ../../include/openssl/bio.h
112bf_buff.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
113bf_buff.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
114bf_buff.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
115bf_buff.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
116bf_buff.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
117bf_buff.o: ../../include/openssl/symhacks.h ../cryptlib.h bf_buff.c
118bf_nbio.o: ../../e_os.h ../../include/openssl/bio.h
119bf_nbio.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
120bf_nbio.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
121bf_nbio.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
122bf_nbio.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
123bf_nbio.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
124bf_nbio.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
125bf_nbio.o: ../cryptlib.h bf_nbio.c
126bf_null.o: ../../e_os.h ../../include/openssl/bio.h
127bf_null.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
128bf_null.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
129bf_null.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
130bf_null.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
131bf_null.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
132bf_null.o: ../../include/openssl/symhacks.h ../cryptlib.h bf_null.c
133bio_cb.o: ../../e_os.h ../../include/openssl/bio.h
134bio_cb.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
135bio_cb.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
136bio_cb.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
137bio_cb.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
138bio_cb.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
139bio_cb.o: ../../include/openssl/symhacks.h ../cryptlib.h bio_cb.c
140bio_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
141bio_err.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
142bio_err.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
143bio_err.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
144bio_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
145bio_err.o: ../../include/openssl/symhacks.h bio_err.c
146bio_lib.o: ../../e_os.h ../../include/openssl/bio.h
147bio_lib.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
148bio_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
149bio_lib.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
150bio_lib.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
151bio_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
152bio_lib.o: ../../include/openssl/symhacks.h ../cryptlib.h bio_lib.c
153bss_acpt.o: ../../e_os.h ../../include/openssl/bio.h
154bss_acpt.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
155bss_acpt.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
156bss_acpt.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
157bss_acpt.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
158bss_acpt.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
159bss_acpt.o: ../../include/openssl/symhacks.h ../cryptlib.h bss_acpt.c
160bss_bio.o: ../../e_os.h ../../include/openssl/bio.h
161bss_bio.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
162bss_bio.o: ../../include/openssl/err.h ../../include/openssl/lhash.h
163bss_bio.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
164bss_bio.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
165bss_bio.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
166bss_bio.o: bss_bio.c
167bss_conn.o: ../../e_os.h ../../include/openssl/bio.h
168bss_conn.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
169bss_conn.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
170bss_conn.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
171bss_conn.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
172bss_conn.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
173bss_conn.o: ../../include/openssl/symhacks.h ../cryptlib.h bss_conn.c
174bss_dgram.o: ../../e_os.h ../../include/openssl/bio.h
175bss_dgram.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
176bss_dgram.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
177bss_dgram.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
178bss_dgram.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
179bss_dgram.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
180bss_dgram.o: ../../include/openssl/symhacks.h ../cryptlib.h bss_dgram.c
181bss_fd.o: ../../e_os.h ../../include/openssl/bio.h
182bss_fd.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
183bss_fd.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
184bss_fd.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
185bss_fd.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
186bss_fd.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
187bss_fd.o: ../../include/openssl/symhacks.h ../cryptlib.h bio_lcl.h bss_fd.c
188bss_file.o: ../../e_os.h ../../include/openssl/bio.h
189bss_file.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
190bss_file.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
191bss_file.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
192bss_file.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
193bss_file.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
194bss_file.o: ../../include/openssl/symhacks.h ../cryptlib.h bio_lcl.h bss_file.c
195bss_log.o: ../../e_os.h ../../include/openssl/bio.h
196bss_log.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
197bss_log.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
198bss_log.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
199bss_log.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
200bss_log.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
201bss_log.o: ../../include/openssl/symhacks.h ../cryptlib.h bss_log.c
202bss_mem.o: ../../e_os.h ../../include/openssl/bio.h
203bss_mem.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
204bss_mem.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
205bss_mem.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
206bss_mem.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
207bss_mem.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
208bss_mem.o: ../../include/openssl/symhacks.h ../cryptlib.h bss_mem.c
209bss_null.o: ../../e_os.h ../../include/openssl/bio.h
210bss_null.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
211bss_null.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
212bss_null.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
213bss_null.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
214bss_null.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
215bss_null.o: ../../include/openssl/symhacks.h ../cryptlib.h bss_null.c
216bss_sock.o: ../../e_os.h ../../include/openssl/bio.h
217bss_sock.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
218bss_sock.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
219bss_sock.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
220bss_sock.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
221bss_sock.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
222bss_sock.o: ../../include/openssl/symhacks.h ../cryptlib.h bss_sock.c
diff --git a/src/lib/libcrypto/bio/b_sock.c b/src/lib/libcrypto/bio/b_sock.c
index d47310d650..12b0a53a81 100644
--- a/src/lib/libcrypto/bio/b_sock.c
+++ b/src/lib/libcrypto/bio/b_sock.c
@@ -551,30 +551,7 @@ int BIO_socket_ioctl(int fd, long type, void *arg)
551#ifdef __DJGPP__ 551#ifdef __DJGPP__
552 i=ioctlsocket(fd,type,(char *)arg); 552 i=ioctlsocket(fd,type,(char *)arg);
553#else 553#else
554# if defined(OPENSSL_SYS_VMS) 554 i=ioctlsocket(fd,type,arg);
555 /* 2011-02-18 SMS.
556 * VMS ioctl() can't tolerate a 64-bit "void *arg", but we
557 * observe that all the consumers pass in an "unsigned long *",
558 * so we arrange a local copy with a short pointer, and use
559 * that, instead.
560 */
561# if __INITIAL_POINTER_SIZE == 64
562# define ARG arg_32p
563# pragma pointer_size save
564# pragma pointer_size 32
565 unsigned long arg_32;
566 unsigned long *arg_32p;
567# pragma pointer_size restore
568 arg_32p = &arg_32;
569 arg_32 = *((unsigned long *) arg);
570# else /* __INITIAL_POINTER_SIZE == 64 */
571# define ARG arg
572# endif /* __INITIAL_POINTER_SIZE == 64 [else] */
573# else /* defined(OPENSSL_SYS_VMS) */
574# define ARG arg
575# endif /* defined(OPENSSL_SYS_VMS) [else] */
576
577 i=ioctlsocket(fd,type,ARG);
578#endif /* __DJGPP__ */ 555#endif /* __DJGPP__ */
579 if (i < 0) 556 if (i < 0)
580 SYSerr(SYS_F_IOCTLSOCKET,get_last_socket_error()); 557 SYSerr(SYS_F_IOCTLSOCKET,get_last_socket_error());
@@ -683,7 +660,6 @@ int BIO_get_accept_socket(char *host, int bind_mode)
683 * note that commonly IPv6 wildchard socket can service 660 * note that commonly IPv6 wildchard socket can service
684 * IPv4 connections just as well... */ 661 * IPv4 connections just as well... */
685 memset(&hint,0,sizeof(hint)); 662 memset(&hint,0,sizeof(hint));
686 hint.ai_flags = AI_PASSIVE;
687 if (h) 663 if (h)
688 { 664 {
689 if (strchr(h,':')) 665 if (strchr(h,':'))
@@ -696,10 +672,7 @@ int BIO_get_accept_socket(char *host, int bind_mode)
696#endif 672#endif
697 } 673 }
698 else if (h[0]=='*' && h[1]=='\0') 674 else if (h[0]=='*' && h[1]=='\0')
699 {
700 hint.ai_family = AF_INET;
701 h=NULL; 675 h=NULL;
702 }
703 } 676 }
704 677
705 if ((*p_getaddrinfo.f)(h,p,&hint,&res)) break; 678 if ((*p_getaddrinfo.f)(h,p,&hint,&res)) break;
diff --git a/src/lib/libcrypto/bio/bf_nbio.c b/src/lib/libcrypto/bio/bf_nbio.c
index 028616c064..c72a23c2e1 100644
--- a/src/lib/libcrypto/bio/bf_nbio.c
+++ b/src/lib/libcrypto/bio/bf_nbio.c
@@ -125,6 +125,7 @@ static int nbiof_free(BIO *a)
125 125
126static int nbiof_read(BIO *b, char *out, int outl) 126static int nbiof_read(BIO *b, char *out, int outl)
127 { 127 {
128 NBIO_TEST *nt;
128 int ret=0; 129 int ret=0;
129#if 1 130#if 1
130 int num; 131 int num;
@@ -133,6 +134,7 @@ static int nbiof_read(BIO *b, char *out, int outl)
133 134
134 if (out == NULL) return(0); 135 if (out == NULL) return(0);
135 if (b->next_bio == NULL) return(0); 136 if (b->next_bio == NULL) return(0);
137 nt=(NBIO_TEST *)b->ptr;
136 138
137 BIO_clear_retry_flags(b); 139 BIO_clear_retry_flags(b);
138#if 1 140#if 1
diff --git a/src/lib/libcrypto/bio/bio_lcl.h b/src/lib/libcrypto/bio/bio_lcl.h
new file mode 100644
index 0000000000..e7f7ec8d8b
--- /dev/null
+++ b/src/lib/libcrypto/bio/bio_lcl.h
@@ -0,0 +1,36 @@
1#include <openssl/bio.h>
2
3#if BIO_FLAGS_UPLINK==0
4/* Shortcut UPLINK calls on most platforms... */
5#define UP_stdin stdin
6#define UP_stdout stdout
7#define UP_stderr stderr
8#define UP_fprintf fprintf
9#define UP_fgets fgets
10#define UP_fread fread
11#define UP_fwrite fwrite
12#undef UP_fsetmod
13#define UP_feof feof
14#define UP_fclose fclose
15
16#define UP_fopen fopen
17#define UP_fseek fseek
18#define UP_ftell ftell
19#define UP_fflush fflush
20#define UP_ferror ferror
21#ifdef _WIN32
22#define UP_fileno _fileno
23#define UP_open _open
24#define UP_read _read
25#define UP_write _write
26#define UP_lseek _lseek
27#define UP_close _close
28#else
29#define UP_fileno fileno
30#define UP_open open
31#define UP_read read
32#define UP_write write
33#define UP_lseek lseek
34#define UP_close close
35#endif
36#endif
diff --git a/src/lib/libcrypto/bio/bio_lib.c b/src/lib/libcrypto/bio/bio_lib.c
index e12bc3a2ca..77f4de9c32 100644
--- a/src/lib/libcrypto/bio/bio_lib.c
+++ b/src/lib/libcrypto/bio/bio_lib.c
@@ -110,7 +110,7 @@ int BIO_set(BIO *bio, BIO_METHOD *method)
110 110
111int BIO_free(BIO *a) 111int BIO_free(BIO *a)
112 { 112 {
113 int i; 113 int ret=0,i;
114 114
115 if (a == NULL) return(0); 115 if (a == NULL) return(0);
116 116
@@ -133,7 +133,7 @@ int BIO_free(BIO *a)
133 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, a, &a->ex_data); 133 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, a, &a->ex_data);
134 134
135 if ((a->method == NULL) || (a->method->destroy == NULL)) return(1); 135 if ((a->method == NULL) || (a->method->destroy == NULL)) return(1);
136 a->method->destroy(a); 136 ret=a->method->destroy(a);
137 OPENSSL_free(a); 137 OPENSSL_free(a);
138 return(1); 138 return(1);
139 } 139 }
diff --git a/src/lib/libcrypto/bio/bss_acpt.c b/src/lib/libcrypto/bio/bss_acpt.c
index 5d49e1a72b..826f761143 100644
--- a/src/lib/libcrypto/bio/bss_acpt.c
+++ b/src/lib/libcrypto/bio/bss_acpt.c
@@ -340,6 +340,7 @@ static int acpt_write(BIO *b, const char *in, int inl)
340 340
341static long acpt_ctrl(BIO *b, int cmd, long num, void *ptr) 341static long acpt_ctrl(BIO *b, int cmd, long num, void *ptr)
342 { 342 {
343 BIO *dbio;
343 int *ip; 344 int *ip;
344 long ret=1; 345 long ret=1;
345 BIO_ACCEPT *data; 346 BIO_ACCEPT *data;
@@ -436,8 +437,8 @@ static long acpt_ctrl(BIO *b, int cmd, long num, void *ptr)
436 ret=(long)data->bind_mode; 437 ret=(long)data->bind_mode;
437 break; 438 break;
438 case BIO_CTRL_DUP: 439 case BIO_CTRL_DUP:
439/* dbio=(BIO *)ptr; 440 dbio=(BIO *)ptr;
440 if (data->param_port) EAY EAY 441/* if (data->param_port) EAY EAY
441 BIO_set_port(dbio,data->param_port); 442 BIO_set_port(dbio,data->param_port);
442 if (data->param_hostname) 443 if (data->param_hostname)
443 BIO_set_hostname(dbio,data->param_hostname); 444 BIO_set_hostname(dbio,data->param_hostname);
diff --git a/src/lib/libcrypto/bio/bss_dgram.c b/src/lib/libcrypto/bio/bss_dgram.c
index 71ebe987b6..eb7e365467 100644
--- a/src/lib/libcrypto/bio/bss_dgram.c
+++ b/src/lib/libcrypto/bio/bss_dgram.c
@@ -57,6 +57,7 @@
57 * 57 *
58 */ 58 */
59 59
60#ifndef OPENSSL_NO_DGRAM
60 61
61#include <stdio.h> 62#include <stdio.h>
62#include <errno.h> 63#include <errno.h>
@@ -64,7 +65,6 @@
64#include "cryptlib.h" 65#include "cryptlib.h"
65 66
66#include <openssl/bio.h> 67#include <openssl/bio.h>
67#ifndef OPENSSL_NO_DGRAM
68 68
69#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) 69#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS)
70#include <sys/timeb.h> 70#include <sys/timeb.h>
@@ -308,6 +308,7 @@ static int dgram_read(BIO *b, char *out, int outl)
308 OPENSSL_assert(sa.len.s<=sizeof(sa.peer)); 308 OPENSSL_assert(sa.len.s<=sizeof(sa.peer));
309 sa.len.i = (int)sa.len.s; 309 sa.len.i = (int)sa.len.s;
310 } 310 }
311 dgram_reset_rcv_timeout(b);
311 312
312 if ( ! data->connected && ret >= 0) 313 if ( ! data->connected && ret >= 0)
313 BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, &sa.peer); 314 BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, &sa.peer);
@@ -321,8 +322,6 @@ static int dgram_read(BIO *b, char *out, int outl)
321 data->_errno = get_last_socket_error(); 322 data->_errno = get_last_socket_error();
322 } 323 }
323 } 324 }
324
325 dgram_reset_rcv_timeout(b);
326 } 325 }
327 return(ret); 326 return(ret);
328 } 327 }
@@ -341,7 +340,7 @@ static int dgram_write(BIO *b, const char *in, int inl)
341 340
342 if (data->peer.sa.sa_family == AF_INET) 341 if (data->peer.sa.sa_family == AF_INET)
343 peerlen = sizeof(data->peer.sa_in); 342 peerlen = sizeof(data->peer.sa_in);
344#if OPENSSL_USE_IPV6 343#if OPENSSL_USE_IVP6
345 else if (data->peer.sa.sa_family == AF_INET6) 344 else if (data->peer.sa.sa_family == AF_INET6)
346 peerlen = sizeof(data->peer.sa_in6); 345 peerlen = sizeof(data->peer.sa_in6);
347#endif 346#endif
@@ -746,13 +745,9 @@ static int BIO_dgram_should_retry(int i)
746 { 745 {
747 err=get_last_socket_error(); 746 err=get_last_socket_error();
748 747
749#if defined(OPENSSL_SYS_WINDOWS) 748#if defined(OPENSSL_SYS_WINDOWS) && 0 /* more microsoft stupidity? perhaps not? Ben 4/1/99 */
750 /* If the socket return value (i) is -1 749 if ((i == -1) && (err == 0))
751 * and err is unexpectedly 0 at this point, 750 return(1);
752 * the error code was overwritten by
753 * another system call before this error
754 * handling is called.
755 */
756#endif 751#endif
757 752
758 return(BIO_dgram_non_fatal_error(err)); 753 return(BIO_dgram_non_fatal_error(err));
@@ -815,6 +810,7 @@ int BIO_dgram_non_fatal_error(int err)
815 } 810 }
816 return(0); 811 return(0);
817 } 812 }
813#endif
818 814
819static void get_current_time(struct timeval *t) 815static void get_current_time(struct timeval *t)
820 { 816 {
@@ -832,5 +828,3 @@ static void get_current_time(struct timeval *t)
832 gettimeofday(t, NULL); 828 gettimeofday(t, NULL);
833#endif 829#endif
834 } 830 }
835
836#endif
diff --git a/src/lib/libcrypto/bio/bss_file.c b/src/lib/libcrypto/bio/bss_file.c
index b954fe7ebc..8bfa0bcd97 100644
--- a/src/lib/libcrypto/bio/bss_file.c
+++ b/src/lib/libcrypto/bio/bss_file.c
@@ -123,7 +123,6 @@ BIO *BIO_new_file(const char *filename, const char *mode)
123 123
124#if defined(_WIN32) && defined(CP_UTF8) 124#if defined(_WIN32) && defined(CP_UTF8)
125 int sz, len_0 = (int)strlen(filename)+1; 125 int sz, len_0 = (int)strlen(filename)+1;
126 DWORD flags;
127 126
128 /* 127 /*
129 * Basically there are three cases to cover: a) filename is 128 * Basically there are three cases to cover: a) filename is
@@ -137,22 +136,17 @@ BIO *BIO_new_file(const char *filename, const char *mode)
137 * ERROR_NO_UNICODE_TRANSLATION, in which case we fall 136 * ERROR_NO_UNICODE_TRANSLATION, in which case we fall
138 * back to fopen... 137 * back to fopen...
139 */ 138 */
140 if ((sz=MultiByteToWideChar(CP_UTF8,(flags=MB_ERR_INVALID_CHARS), 139 if ((sz=MultiByteToWideChar(CP_UTF8,MB_ERR_INVALID_CHARS,
141 filename,len_0,NULL,0))>0 ||
142 (GetLastError()==ERROR_INVALID_FLAGS &&
143 (sz=MultiByteToWideChar(CP_UTF8,(flags=0),
144 filename,len_0,NULL,0))>0) 140 filename,len_0,NULL,0))>0)
145 )
146 { 141 {
147 WCHAR wmode[8]; 142 WCHAR wmode[8];
148 WCHAR *wfilename = _alloca(sz*sizeof(WCHAR)); 143 WCHAR *wfilename = _alloca(sz*sizeof(WCHAR));
149 144
150 if (MultiByteToWideChar(CP_UTF8,flags, 145 if (MultiByteToWideChar(CP_UTF8,MB_ERR_INVALID_CHARS,
151 filename,len_0,wfilename,sz) && 146 filename,len_0,wfilename,sz) &&
152 MultiByteToWideChar(CP_UTF8,0,mode,strlen(mode)+1, 147 MultiByteToWideChar(CP_UTF8,0,mode,strlen(mode)+1,
153 wmode,sizeof(wmode)/sizeof(wmode[0])) && 148 wmode,sizeof(wmode)/sizeof(wmode[0])) &&
154 (file=_wfopen(wfilename,wmode))==NULL && 149 (file=_wfopen(wfilename,wmode))==NULL && errno==ENOENT
155 (errno==ENOENT || errno==EBADF)
156 ) /* UTF-8 decode succeeded, but no file, filename 150 ) /* UTF-8 decode succeeded, but no file, filename
157 * could still have been locale-ized... */ 151 * could still have been locale-ized... */
158 file = fopen(filename,mode); 152 file = fopen(filename,mode);
diff --git a/src/lib/libcrypto/bio/bss_log.c b/src/lib/libcrypto/bio/bss_log.c
index b7dce5c1a2..7ead044b37 100644
--- a/src/lib/libcrypto/bio/bss_log.c
+++ b/src/lib/libcrypto/bio/bss_log.c
@@ -75,15 +75,6 @@
75# include <descrip.h> 75# include <descrip.h>
76# include <lib$routines.h> 76# include <lib$routines.h>
77# include <starlet.h> 77# include <starlet.h>
78/* Some compiler options may mask the declaration of "_malloc32". */
79# if __INITIAL_POINTER_SIZE && defined _ANSI_C_SOURCE
80# if __INITIAL_POINTER_SIZE == 64
81# pragma pointer_size save
82# pragma pointer_size 32
83 void * _malloc32 (__size_t);
84# pragma pointer_size restore
85# endif /* __INITIAL_POINTER_SIZE == 64 */
86# endif /* __INITIAL_POINTER_SIZE && defined _ANSI_C_SOURCE */
87#elif defined(__ultrix) 78#elif defined(__ultrix)
88# include <sys/syslog.h> 79# include <sys/syslog.h>
89#elif defined(OPENSSL_SYS_NETWARE) 80#elif defined(OPENSSL_SYS_NETWARE)
@@ -309,24 +300,7 @@ static void xopenlog(BIO* bp, char* name, int level)
309static void xsyslog(BIO *bp, int priority, const char *string) 300static void xsyslog(BIO *bp, int priority, const char *string)
310{ 301{
311 struct dsc$descriptor_s opc_dsc; 302 struct dsc$descriptor_s opc_dsc;
312
313/* Arrange 32-bit pointer to opcdef buffer and malloc(), if needed. */
314#if __INITIAL_POINTER_SIZE == 64
315# pragma pointer_size save
316# pragma pointer_size 32
317# define OPCDEF_TYPE __char_ptr32
318# define OPCDEF_MALLOC _malloc32
319#else /* __INITIAL_POINTER_SIZE == 64 */
320# define OPCDEF_TYPE char *
321# define OPCDEF_MALLOC OPENSSL_malloc
322#endif /* __INITIAL_POINTER_SIZE == 64 [else] */
323
324 struct opcdef *opcdef_p; 303 struct opcdef *opcdef_p;
325
326#if __INITIAL_POINTER_SIZE == 64
327# pragma pointer_size restore
328#endif /* __INITIAL_POINTER_SIZE == 64 */
329
330 char buf[10240]; 304 char buf[10240];
331 unsigned int len; 305 unsigned int len;
332 struct dsc$descriptor_s buf_dsc; 306 struct dsc$descriptor_s buf_dsc;
@@ -352,8 +326,8 @@ static void xsyslog(BIO *bp, int priority, const char *string)
352 326
353 lib$sys_fao(&fao_cmd, &len, &buf_dsc, priority_tag, string); 327 lib$sys_fao(&fao_cmd, &len, &buf_dsc, priority_tag, string);
354 328
355 /* We know there's an 8-byte header. That's documented. */ 329 /* we know there's an 8 byte header. That's documented */
356 opcdef_p = OPCDEF_MALLOC( 8+ len); 330 opcdef_p = (struct opcdef *) OPENSSL_malloc(8 + len);
357 opcdef_p->opc$b_ms_type = OPC$_RQ_RQST; 331 opcdef_p->opc$b_ms_type = OPC$_RQ_RQST;
358 memcpy(opcdef_p->opc$z_ms_target_classes, &VMS_OPC_target, 3); 332 memcpy(opcdef_p->opc$z_ms_target_classes, &VMS_OPC_target, 3);
359 opcdef_p->opc$l_ms_rqstid = 0; 333 opcdef_p->opc$l_ms_rqstid = 0;
@@ -361,7 +335,7 @@ static void xsyslog(BIO *bp, int priority, const char *string)
361 335
362 opc_dsc.dsc$b_dtype = DSC$K_DTYPE_T; 336 opc_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
363 opc_dsc.dsc$b_class = DSC$K_CLASS_S; 337 opc_dsc.dsc$b_class = DSC$K_CLASS_S;
364 opc_dsc.dsc$a_pointer = (OPCDEF_TYPE) opcdef_p; 338 opc_dsc.dsc$a_pointer = (char *)opcdef_p;
365 opc_dsc.dsc$w_length = len + 8; 339 opc_dsc.dsc$w_length = len + 8;
366 340
367 sys$sndopr(opc_dsc, 0); 341 sys$sndopr(opc_dsc, 0);
diff --git a/src/lib/libcrypto/bio/bss_rtcp.c b/src/lib/libcrypto/bio/bss_rtcp.c
new file mode 100644
index 0000000000..7dae485564
--- /dev/null
+++ b/src/lib/libcrypto/bio/bss_rtcp.c
@@ -0,0 +1,294 @@
1/* crypto/bio/bss_rtcp.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59/* Written by David L. Jones <jonesd@kcgl1.eng.ohio-state.edu>
60 * Date: 22-JUL-1996
61 * Revised: 25-SEP-1997 Update for 0.8.1, BIO_CTRL_SET -> BIO_C_SET_FD
62 */
63/* VMS */
64#include <stdio.h>
65#include <stdlib.h>
66#include <string.h>
67#include <errno.h>
68#include "cryptlib.h"
69#include <openssl/bio.h>
70
71#include <iodef.h> /* VMS IO$_ definitions */
72#include <starlet.h>
73
74typedef unsigned short io_channel;
75/*************************************************************************/
76struct io_status { short status, count; long flags; };
77
78struct rpc_msg { /* Should have member alignment inhibited */
79 char channel; /* 'A'-app data. 'R'-remote client 'G'-global */
80 char function; /* 'G'-get, 'P'-put, 'C'-confirm, 'X'-close */
81 unsigned short int length; /* Amount of data returned or max to return */
82 char data[4092]; /* variable data */
83};
84#define RPC_HDR_SIZE (sizeof(struct rpc_msg) - 4092)
85
86struct rpc_ctx {
87 int filled, pos;
88 struct rpc_msg msg;
89};
90
91static int rtcp_write(BIO *h,const char *buf,int num);
92static int rtcp_read(BIO *h,char *buf,int size);
93static int rtcp_puts(BIO *h,const char *str);
94static int rtcp_gets(BIO *h,char *str,int size);
95static long rtcp_ctrl(BIO *h,int cmd,long arg1,void *arg2);
96static int rtcp_new(BIO *h);
97static int rtcp_free(BIO *data);
98
99static BIO_METHOD rtcp_method=
100 {
101 BIO_TYPE_FD,
102 "RTCP",
103 rtcp_write,
104 rtcp_read,
105 rtcp_puts,
106 rtcp_gets,
107 rtcp_ctrl,
108 rtcp_new,
109 rtcp_free,
110 NULL,
111 };
112
113BIO_METHOD *BIO_s_rtcp(void)
114 {
115 return(&rtcp_method);
116 }
117/*****************************************************************************/
118/* Decnet I/O routines.
119 */
120
121#ifdef __DECC
122#pragma message save
123#pragma message disable DOLLARID
124#endif
125
126static int get ( io_channel chan, char *buffer, int maxlen, int *length )
127{
128 int status;
129 struct io_status iosb;
130 status = sys$qiow ( 0, chan, IO$_READVBLK, &iosb, 0, 0,
131 buffer, maxlen, 0, 0, 0, 0 );
132 if ( (status&1) == 1 ) status = iosb.status;
133 if ( (status&1) == 1 ) *length = iosb.count;
134 return status;
135}
136
137static int put ( io_channel chan, char *buffer, int length )
138{
139 int status;
140 struct io_status iosb;
141 status = sys$qiow ( 0, chan, IO$_WRITEVBLK, &iosb, 0, 0,
142 buffer, length, 0, 0, 0, 0 );
143 if ( (status&1) == 1 ) status = iosb.status;
144 return status;
145}
146
147#ifdef __DECC
148#pragma message restore
149#endif
150
151/***************************************************************************/
152
153static int rtcp_new(BIO *bi)
154{
155 struct rpc_ctx *ctx;
156 bi->init=1;
157 bi->num=0;
158 bi->flags = 0;
159 bi->ptr=OPENSSL_malloc(sizeof(struct rpc_ctx));
160 ctx = (struct rpc_ctx *) bi->ptr;
161 ctx->filled = 0;
162 ctx->pos = 0;
163 return(1);
164}
165
166static int rtcp_free(BIO *a)
167{
168 if (a == NULL) return(0);
169 if ( a->ptr ) OPENSSL_free ( a->ptr );
170 a->ptr = NULL;
171 return(1);
172}
173
174static int rtcp_read(BIO *b, char *out, int outl)
175{
176 int status, length;
177 struct rpc_ctx *ctx;
178 /*
179 * read data, return existing.
180 */
181 ctx = (struct rpc_ctx *) b->ptr;
182 if ( ctx->pos < ctx->filled ) {
183 length = ctx->filled - ctx->pos;
184 if ( length > outl ) length = outl;
185 memmove ( out, &ctx->msg.data[ctx->pos], length );
186 ctx->pos += length;
187 return length;
188 }
189 /*
190 * Requst more data from R channel.
191 */
192 ctx->msg.channel = 'R';
193 ctx->msg.function = 'G';
194 ctx->msg.length = sizeof(ctx->msg.data);
195 status = put ( b->num, (char *) &ctx->msg, RPC_HDR_SIZE );
196 if ( (status&1) == 0 ) {
197 return -1;
198 }
199 /*
200 * Read.
201 */
202 ctx->pos = ctx->filled = 0;
203 status = get ( b->num, (char *) &ctx->msg, sizeof(ctx->msg), &length );
204 if ( (status&1) == 0 ) length = -1;
205 if ( ctx->msg.channel != 'R' || ctx->msg.function != 'C' ) {
206 length = -1;
207 }
208 ctx->filled = length - RPC_HDR_SIZE;
209
210 if ( ctx->pos < ctx->filled ) {
211 length = ctx->filled - ctx->pos;
212 if ( length > outl ) length = outl;
213 memmove ( out, ctx->msg.data, length );
214 ctx->pos += length;
215 return length;
216 }
217
218 return length;
219}
220
221static int rtcp_write(BIO *b, const char *in, int inl)
222{
223 int status, i, segment, length;
224 struct rpc_ctx *ctx;
225 /*
226 * Output data, send in chunks no larger that sizeof(ctx->msg.data).
227 */
228 ctx = (struct rpc_ctx *) b->ptr;
229 for ( i = 0; i < inl; i += segment ) {
230 segment = inl - i;
231 if ( segment > sizeof(ctx->msg.data) ) segment = sizeof(ctx->msg.data);
232 ctx->msg.channel = 'R';
233 ctx->msg.function = 'P';
234 ctx->msg.length = segment;
235 memmove ( ctx->msg.data, &in[i], segment );
236 status = put ( b->num, (char *) &ctx->msg, segment + RPC_HDR_SIZE );
237 if ((status&1) == 0 ) { i = -1; break; }
238
239 status = get ( b->num, (char *) &ctx->msg, sizeof(ctx->msg), &length );
240 if ( ((status&1) == 0) || (length < RPC_HDR_SIZE) ) { i = -1; break; }
241 if ( (ctx->msg.channel != 'R') || (ctx->msg.function != 'C') ) {
242 printf("unexpected response when confirming put %c %c\n",
243 ctx->msg.channel, ctx->msg.function );
244
245 }
246 }
247 return(i);
248}
249
250static long rtcp_ctrl(BIO *b, int cmd, long num, void *ptr)
251 {
252 long ret=1;
253
254 switch (cmd)
255 {
256 case BIO_CTRL_RESET:
257 case BIO_CTRL_EOF:
258 ret = 1;
259 break;
260 case BIO_C_SET_FD:
261 b->num = num;
262 ret = 1;
263 break;
264 case BIO_CTRL_SET_CLOSE:
265 case BIO_CTRL_FLUSH:
266 case BIO_CTRL_DUP:
267 ret=1;
268 break;
269 case BIO_CTRL_GET_CLOSE:
270 case BIO_CTRL_INFO:
271 case BIO_CTRL_GET:
272 case BIO_CTRL_PENDING:
273 case BIO_CTRL_WPENDING:
274 default:
275 ret=0;
276 break;
277 }
278 return(ret);
279 }
280
281static int rtcp_gets(BIO *bp, char *buf, int size)
282 {
283 return(0);
284 }
285
286static int rtcp_puts(BIO *bp, const char *str)
287{
288 int length;
289 if (str == NULL) return(0);
290 length = strlen ( str );
291 if ( length == 0 ) return (0);
292 return rtcp_write ( bp,str, length );
293}
294