diff options
| author | beck <> | 1999-09-29 04:37:45 +0000 |
|---|---|---|
| committer | beck <> | 1999-09-29 04:37:45 +0000 |
| commit | de8f24ea083384bb66b32ec105dc4743c5663cdf (patch) | |
| tree | 1412176ae62a3cab2cf2b0b92150fcbceaac6092 /src/lib/libcrypto/bio | |
| parent | cb929d29896bcb87c2a97417fbd03e50078fc178 (diff) | |
| download | openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.tar.gz openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.tar.bz2 openbsd-de8f24ea083384bb66b32ec105dc4743c5663cdf.zip | |
OpenSSL 0.9.4 merge
Diffstat (limited to 'src/lib/libcrypto/bio')
| -rw-r--r-- | src/lib/libcrypto/bio/Makefile.ssl | 170 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/b_dump.c | 13 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/b_print.c | 19 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/b_sock.c | 319 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bf_buff.c | 49 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bf_nbio.c | 50 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bf_null.c | 48 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bio.err | 46 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bio.h | 343 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bio_cb.c | 13 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bio_err.c | 131 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bio_lib.c | 147 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bss_acpt.c | 132 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bss_bio.c | 588 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bss_conn.c | 146 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bss_file.c | 60 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bss_log.c | 232 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bss_mem.c | 59 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bss_null.c | 46 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bss_rtcp.c | 56 | ||||
| -rw-r--r-- | src/lib/libcrypto/bio/bss_sock.c | 118 |
21 files changed, 1709 insertions, 1076 deletions
diff --git a/src/lib/libcrypto/bio/Makefile.ssl b/src/lib/libcrypto/bio/Makefile.ssl index 42e11e1c94..f54c7ee1f0 100644 --- a/src/lib/libcrypto/bio/Makefile.ssl +++ b/src/lib/libcrypto/bio/Makefile.ssl | |||
| @@ -7,36 +7,36 @@ TOP= ../.. | |||
| 7 | CC= cc | 7 | CC= cc |
| 8 | INCLUDES= -I.. -I../../include | 8 | INCLUDES= -I.. -I../../include |
| 9 | CFLAG=-g | 9 | CFLAG=-g |
| 10 | INSTALL_PREFIX= | ||
| 11 | OPENSSLDIR= /usr/local/ssl | ||
| 10 | INSTALLTOP=/usr/local/ssl | 12 | INSTALLTOP=/usr/local/ssl |
| 11 | MAKE= make -f Makefile.ssl | 13 | MAKE= make -f Makefile.ssl |
| 12 | MAKEDEPEND= makedepend -f Makefile.ssl | 14 | MAKEDEPEND= $(TOP)/util/domd $(TOP) |
| 13 | MAKEFILE= Makefile.ssl | 15 | MAKEFILE= Makefile.ssl |
| 14 | AR= ar r | 16 | AR= ar r |
| 15 | 17 | ||
| 16 | CFLAGS= $(INCLUDES) $(CFLAG) | 18 | CFLAGS= $(INCLUDES) $(CFLAG) |
| 17 | 19 | ||
| 18 | ERR=bio | ||
| 19 | ERRC=bio_err | ||
| 20 | GENERAL=Makefile | 20 | GENERAL=Makefile |
| 21 | TEST= | 21 | TEST= |
| 22 | APPS= | 22 | APPS= |
| 23 | 23 | ||
| 24 | LIB=$(TOP)/libcrypto.a | 24 | LIB=$(TOP)/libcrypto.a |
| 25 | LIBSRC= bio_lib.c bio_cb.c $(ERRC).c \ | 25 | LIBSRC= bio_lib.c bio_cb.c bio_err.c \ |
| 26 | bss_mem.c bss_null.c bss_fd.c \ | 26 | bss_mem.c bss_null.c bss_fd.c \ |
| 27 | bss_file.c bss_sock.c bss_conn.c \ | 27 | bss_file.c bss_sock.c bss_conn.c \ |
| 28 | bf_null.c bf_buff.c b_print.c b_dump.c \ | 28 | bf_null.c bf_buff.c b_print.c b_dump.c \ |
| 29 | b_sock.c bss_acpt.c bf_nbio.c | 29 | b_sock.c bss_acpt.c bf_nbio.c bss_log.c bss_bio.c |
| 30 | LIBOBJ= bio_lib.o bio_cb.o $(ERRC).o \ | 30 | LIBOBJ= bio_lib.o bio_cb.o bio_err.o \ |
| 31 | bss_mem.o bss_null.o bss_fd.o \ | 31 | bss_mem.o bss_null.o bss_fd.o \ |
| 32 | bss_file.o bss_sock.o bss_conn.o \ | 32 | bss_file.o bss_sock.o bss_conn.o \ |
| 33 | bf_null.o bf_buff.o b_print.o b_dump.o \ | 33 | bf_null.o bf_buff.o b_print.o b_dump.o \ |
| 34 | b_sock.o bss_acpt.o bf_nbio.o | 34 | b_sock.o bss_acpt.o bf_nbio.o bss_log.o bss_bio.o |
| 35 | 35 | ||
| 36 | SRC= $(LIBSRC) | 36 | SRC= $(LIBSRC) |
| 37 | 37 | ||
| 38 | EXHEADER= bio.h bss_file.c | 38 | EXHEADER= bio.h |
| 39 | HEADER= $(EXHEADER) | 39 | HEADER= bss_file.c $(EXHEADER) |
| 40 | 40 | ||
| 41 | ALL= $(GENERAL) $(SRC) $(HEADER) | 41 | ALL= $(GENERAL) $(SRC) $(HEADER) |
| 42 | 42 | ||
| @@ -47,24 +47,23 @@ all: lib | |||
| 47 | 47 | ||
| 48 | lib: $(LIBOBJ) | 48 | lib: $(LIBOBJ) |
| 49 | $(AR) $(LIB) $(LIBOBJ) | 49 | $(AR) $(LIB) $(LIBOBJ) |
| 50 | sh $(TOP)/util/ranlib.sh $(LIB) | 50 | $(RANLIB) $(LIB) |
| 51 | @touch lib | 51 | @touch lib |
| 52 | 52 | ||
| 53 | files: | 53 | files: |
| 54 | perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO | 54 | $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO |
| 55 | 55 | ||
| 56 | links: | 56 | links: |
| 57 | /bin/rm -f Makefile | 57 | @$(TOP)/util/point.sh Makefile.ssl Makefile |
| 58 | $(TOP)/util/point.sh Makefile.ssl Makefile; | 58 | @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) |
| 59 | $(TOP)/util/mklink.sh ../../include $(EXHEADER) | 59 | @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) |
| 60 | $(TOP)/util/mklink.sh ../../test $(TEST) | 60 | @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) |
| 61 | $(TOP)/util/mklink.sh ../../apps $(APPS) | ||
| 62 | 61 | ||
| 63 | install: | 62 | install: |
| 64 | @for i in $(EXHEADER) bss_file.c ; \ | 63 | @for i in $(EXHEADER); \ |
| 65 | do \ | 64 | do \ |
| 66 | (cp $$i $(INSTALLTOP)/include/$$i; \ | 65 | (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \ |
| 67 | chmod 644 $(INSTALLTOP)/include/$$i ); \ | 66 | chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \ |
| 68 | done; | 67 | done; |
| 69 | 68 | ||
| 70 | tags: | 69 | tags: |
| @@ -76,17 +75,136 @@ lint: | |||
| 76 | lint -DLINT $(INCLUDES) $(SRC)>fluff | 75 | lint -DLINT $(INCLUDES) $(SRC)>fluff |
| 77 | 76 | ||
| 78 | depend: | 77 | depend: |
| 79 | $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) | 78 | $(MAKEDEPEND) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) |
| 80 | 79 | ||
| 81 | dclean: | 80 | dclean: |
| 82 | perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new | 81 | $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new |
| 83 | mv -f Makefile.new $(MAKEFILE) | 82 | mv -f Makefile.new $(MAKEFILE) |
| 84 | 83 | ||
| 85 | clean: | 84 | clean: |
| 86 | /bin/rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff | 85 | rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff |
| 87 | |||
| 88 | errors: | ||
| 89 | perl $(TOP)/util/err-ins.pl $(ERR).err $(ERR).h | ||
| 90 | perl ../err/err_genc.pl -s $(ERR).h $(ERRC).c | ||
| 91 | 86 | ||
| 92 | # DO NOT DELETE THIS LINE -- make depend depends on it. | 87 | # DO NOT DELETE THIS LINE -- make depend depends on it. |
| 88 | |||
| 89 | b_dump.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h | ||
| 90 | b_dump.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h | ||
| 91 | b_dump.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 92 | b_dump.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 93 | b_dump.o: ../../include/openssl/stack.h ../cryptlib.h | ||
| 94 | b_print.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h | ||
| 95 | b_print.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h | ||
| 96 | b_print.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 97 | b_print.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 98 | b_print.o: ../../include/openssl/stack.h ../cryptlib.h | ||
| 99 | b_sock.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h | ||
| 100 | b_sock.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h | ||
| 101 | b_sock.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 102 | b_sock.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 103 | b_sock.o: ../../include/openssl/stack.h ../cryptlib.h | ||
| 104 | bf_buff.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
| 105 | bf_buff.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | ||
| 106 | bf_buff.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h | ||
| 107 | bf_buff.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | ||
| 108 | bf_buff.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 109 | bf_buff.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h | ||
| 110 | bf_buff.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
| 111 | bf_buff.o: ../../include/openssl/idea.h ../../include/openssl/md2.h | ||
| 112 | bf_buff.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | ||
| 113 | bf_buff.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
| 114 | bf_buff.o: ../../include/openssl/opensslv.h ../../include/openssl/rc2.h | ||
| 115 | bf_buff.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h | ||
| 116 | bf_buff.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h | ||
| 117 | bf_buff.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
| 118 | bf_buff.o: ../../include/openssl/stack.h ../cryptlib.h | ||
| 119 | bf_nbio.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
| 120 | bf_nbio.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | ||
| 121 | bf_nbio.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h | ||
| 122 | bf_nbio.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | ||
| 123 | bf_nbio.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 124 | bf_nbio.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h | ||
| 125 | bf_nbio.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
| 126 | bf_nbio.o: ../../include/openssl/idea.h ../../include/openssl/md2.h | ||
| 127 | bf_nbio.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | ||
| 128 | bf_nbio.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
| 129 | bf_nbio.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h | ||
| 130 | bf_nbio.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h | ||
| 131 | bf_nbio.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h | ||
| 132 | bf_nbio.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h | ||
| 133 | bf_nbio.o: ../../include/openssl/sha.h ../../include/openssl/stack.h | ||
| 134 | bf_nbio.o: ../cryptlib.h | ||
| 135 | bf_null.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h | ||
| 136 | bf_null.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h | ||
| 137 | bf_null.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h | ||
| 138 | bf_null.o: ../../include/openssl/crypto.h ../../include/openssl/des.h | ||
| 139 | bf_null.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h | ||
| 140 | bf_null.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h | ||
| 141 | bf_null.o: ../../include/openssl/err.h ../../include/openssl/evp.h | ||
| 142 | bf_null.o: ../../include/openssl/idea.h ../../include/openssl/md2.h | ||
| 143 | bf_null.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h | ||
| 144 | bf_null.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h | ||
| 145 | bf_null.o: ../../include/openssl/opensslv.h ../../include/openssl/rc2.h | ||
| 146 | bf_null.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h | ||
| 147 | bf_null.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h | ||
| 148 | bf_null.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h | ||
| 149 | bf_null.o: ../../include/openssl/stack.h ../cryptlib.h | ||
| 150 | bio_cb.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h | ||
| 151 | bio_cb.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h | ||
| 152 | bio_cb.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 153 | bio_cb.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 154 | bio_cb.o: ../../include/openssl/stack.h ../cryptlib.h | ||
| 155 | bio_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h | ||
| 156 | bio_err.o: ../../include/openssl/err.h ../../include/openssl/opensslv.h | ||
| 157 | bio_err.o: ../../include/openssl/stack.h | ||
| 158 | bio_lib.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h | ||
| 159 | bio_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h | ||
| 160 | bio_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 161 | bio_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 162 | bio_lib.o: ../../include/openssl/stack.h ../cryptlib.h | ||
| 163 | bss_acpt.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h | ||
| 164 | bss_acpt.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h | ||
| 165 | bss_acpt.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 166 | bss_acpt.o: ../../include/openssl/opensslconf.h | ||
| 167 | bss_acpt.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h | ||
| 168 | bss_acpt.o: ../cryptlib.h | ||
| 169 | bss_bio.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h | ||
| 170 | bss_bio.o: ../../include/openssl/err.h ../../include/openssl/opensslv.h | ||
| 171 | bss_bio.o: ../../include/openssl/stack.h | ||
| 172 | bss_conn.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h | ||
| 173 | bss_conn.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h | ||
| 174 | bss_conn.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 175 | bss_conn.o: ../../include/openssl/opensslconf.h | ||
| 176 | bss_conn.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h | ||
| 177 | bss_conn.o: ../cryptlib.h | ||
| 178 | bss_fd.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h | ||
| 179 | bss_fd.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h | ||
| 180 | bss_fd.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 181 | bss_fd.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 182 | bss_fd.o: ../../include/openssl/stack.h ../cryptlib.h bss_sock.c | ||
| 183 | bss_file.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h | ||
| 184 | bss_file.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h | ||
| 185 | bss_file.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 186 | bss_file.o: ../../include/openssl/opensslconf.h | ||
| 187 | bss_file.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h | ||
| 188 | bss_file.o: ../cryptlib.h | ||
| 189 | bss_log.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h | ||
| 190 | bss_log.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h | ||
| 191 | bss_log.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 192 | bss_log.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 193 | bss_log.o: ../../include/openssl/stack.h ../cryptlib.h | ||
| 194 | bss_mem.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h | ||
| 195 | bss_mem.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h | ||
| 196 | bss_mem.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 197 | bss_mem.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h | ||
| 198 | bss_mem.o: ../../include/openssl/stack.h ../cryptlib.h | ||
| 199 | bss_null.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h | ||
| 200 | bss_null.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h | ||
| 201 | bss_null.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 202 | bss_null.o: ../../include/openssl/opensslconf.h | ||
| 203 | bss_null.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h | ||
| 204 | bss_null.o: ../cryptlib.h | ||
| 205 | bss_sock.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h | ||
| 206 | bss_sock.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h | ||
| 207 | bss_sock.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h | ||
| 208 | bss_sock.o: ../../include/openssl/opensslconf.h | ||
| 209 | bss_sock.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h | ||
| 210 | bss_sock.o: ../cryptlib.h | ||
diff --git a/src/lib/libcrypto/bio/b_dump.c b/src/lib/libcrypto/bio/b_dump.c index db84ad3d47..a7cd828978 100644 --- a/src/lib/libcrypto/bio/b_dump.c +++ b/src/lib/libcrypto/bio/b_dump.c | |||
| @@ -62,15 +62,12 @@ | |||
| 62 | 62 | ||
| 63 | #include <stdio.h> | 63 | #include <stdio.h> |
| 64 | #include "cryptlib.h" | 64 | #include "cryptlib.h" |
| 65 | #include "bio.h" | 65 | #include <openssl/bio.h> |
| 66 | 66 | ||
| 67 | #define TRUNCATE | 67 | #define TRUNCATE |
| 68 | #define DUMP_WIDTH 16 | 68 | #define DUMP_WIDTH 16 |
| 69 | 69 | ||
| 70 | int BIO_dump(bio,s,len) | 70 | int BIO_dump(BIO *bio, const char *s, int len) |
| 71 | BIO *bio; | ||
| 72 | char *s; | ||
| 73 | int len; | ||
| 74 | { | 71 | { |
| 75 | int ret=0; | 72 | int ret=0; |
| 76 | char buf[160+1],tmp[20]; | 73 | char buf[160+1],tmp[20]; |
| @@ -105,7 +102,13 @@ int len; | |||
| 105 | if (((i*DUMP_WIDTH)+j)>=len) | 102 | if (((i*DUMP_WIDTH)+j)>=len) |
| 106 | break; | 103 | break; |
| 107 | ch=((unsigned char)*((char *)(s)+i*DUMP_WIDTH+j)) & 0xff; | 104 | ch=((unsigned char)*((char *)(s)+i*DUMP_WIDTH+j)) & 0xff; |
| 105 | #ifndef CHARSET_EBCDIC | ||
| 108 | sprintf(tmp,"%c",((ch>=' ')&&(ch<='~'))?ch:'.'); | 106 | sprintf(tmp,"%c",((ch>=' ')&&(ch<='~'))?ch:'.'); |
| 107 | #else | ||
| 108 | sprintf(tmp,"%c",((ch>=os_toascii[' '])&&(ch<=os_toascii['~'])) | ||
| 109 | ? os_toebcdic[ch] | ||
| 110 | : '.'); | ||
| 111 | #endif | ||
| 109 | strcat(buf,tmp); | 112 | strcat(buf,tmp); |
| 110 | } | 113 | } |
| 111 | strcat(buf,"\n"); | 114 | strcat(buf,"\n"); |
diff --git a/src/lib/libcrypto/bio/b_print.c b/src/lib/libcrypto/bio/b_print.c index cdadeb839a..f448004298 100644 --- a/src/lib/libcrypto/bio/b_print.c +++ b/src/lib/libcrypto/bio/b_print.c | |||
| @@ -61,32 +61,27 @@ | |||
| 61 | */ | 61 | */ |
| 62 | 62 | ||
| 63 | #include <stdio.h> | 63 | #include <stdio.h> |
| 64 | #include <stdarg.h> | ||
| 64 | #include "cryptlib.h" | 65 | #include "cryptlib.h" |
| 65 | #include "bio.h" | 66 | #include <openssl/bio.h> |
| 66 | 67 | ||
| 67 | int BIO_printf ( VAR_PLIST( BIO *, bio ) ) | 68 | int BIO_printf (BIO *bio, ...) |
| 68 | VAR_ALIST | ||
| 69 | { | 69 | { |
| 70 | VAR_BDEFN(args, BIO *, bio); | 70 | va_list args; |
| 71 | char *format; | 71 | char *format; |
| 72 | int ret; | 72 | int ret; |
| 73 | MS_STATIC char hugebuf[1024*2]; /* 10k in one chunk is the limit */ | 73 | MS_STATIC char hugebuf[1024*2]; /* 10k in one chunk is the limit */ |
| 74 | 74 | ||
| 75 | VAR_INIT(args, BIO *, bio); | 75 | va_start(args, bio); |
| 76 | VAR_ARG(args, char *, format); | 76 | format=va_arg(args, char *); |
| 77 | 77 | ||
| 78 | hugebuf[0]='\0'; | 78 | hugebuf[0]='\0'; |
| 79 | 79 | ||
| 80 | /* no-one uses _doprnt anymore and it appears to be broken under SunOS 4.1.4 */ | ||
| 81 | #if 0 && defined(sun) && !defined(VAR_ANSI) /**/ | ||
| 82 | _doprnt(hugebuf,format,args); | ||
| 83 | #else /* !sun */ | ||
| 84 | vsprintf(hugebuf,format,args); | 80 | vsprintf(hugebuf,format,args); |
| 85 | #endif /* sun */ | ||
| 86 | 81 | ||
| 87 | ret=BIO_write(bio,hugebuf,strlen(hugebuf)); | 82 | ret=BIO_write(bio,hugebuf,strlen(hugebuf)); |
| 88 | 83 | ||
| 89 | VAR_END( args ); | 84 | va_end(args); |
| 90 | return(ret); | 85 | return(ret); |
| 91 | } | 86 | } |
| 92 | 87 | ||
diff --git a/src/lib/libcrypto/bio/b_sock.c b/src/lib/libcrypto/bio/b_sock.c index a45909527c..d29b29ff8b 100644 --- a/src/lib/libcrypto/bio/b_sock.c +++ b/src/lib/libcrypto/bio/b_sock.c | |||
| @@ -63,9 +63,7 @@ | |||
| 63 | #include <errno.h> | 63 | #include <errno.h> |
| 64 | #define USE_SOCKETS | 64 | #define USE_SOCKETS |
| 65 | #include "cryptlib.h" | 65 | #include "cryptlib.h" |
| 66 | #include "bio.h" | 66 | #include <openssl/bio.h> |
| 67 | |||
| 68 | /* BIOerr(BIO_F_WSASTARTUP,BIO_R_WSASTARTUP ); */ | ||
| 69 | 67 | ||
| 70 | #ifdef WIN16 | 68 | #ifdef WIN16 |
| 71 | #define SOCKET_PROTOCOL 0 /* more microsoft stupidity */ | 69 | #define SOCKET_PROTOCOL 0 /* more microsoft stupidity */ |
| @@ -96,21 +94,14 @@ static struct ghbn_cache_st | |||
| 96 | unsigned long order; | 94 | unsigned long order; |
| 97 | } ghbn_cache[GHBN_NUM]; | 95 | } ghbn_cache[GHBN_NUM]; |
| 98 | 96 | ||
| 99 | #ifndef NOPROTO | 97 | static int get_ip(const char *str,unsigned char *ip); |
| 100 | static int get_ip(char *str,unsigned char *ip); | ||
| 101 | static void ghbn_free(struct hostent *a); | 98 | static void ghbn_free(struct hostent *a); |
| 102 | static struct hostent *ghbn_dup(struct hostent *a); | 99 | static struct hostent *ghbn_dup(struct hostent *a); |
| 103 | #else | 100 | int BIO_get_host_ip(const char *str, unsigned char *ip) |
| 104 | static int get_ip(); | ||
| 105 | static void ghbn_free(); | ||
| 106 | static struct hostent *ghbn_dup(); | ||
| 107 | #endif | ||
| 108 | |||
| 109 | int BIO_get_host_ip(str,ip) | ||
| 110 | char *str; | ||
| 111 | unsigned char *ip; | ||
| 112 | { | 101 | { |
| 113 | int i; | 102 | int i; |
| 103 | int err = 1; | ||
| 104 | int locked = 0; | ||
| 114 | struct hostent *he; | 105 | struct hostent *he; |
| 115 | 106 | ||
| 116 | i=get_ip(str,ip); | 107 | i=get_ip(str,ip); |
| @@ -118,37 +109,45 @@ unsigned char *ip; | |||
| 118 | if (i < 0) | 109 | if (i < 0) |
| 119 | { | 110 | { |
| 120 | BIOerr(BIO_F_BIO_GET_HOST_IP,BIO_R_INVALID_IP_ADDRESS); | 111 | BIOerr(BIO_F_BIO_GET_HOST_IP,BIO_R_INVALID_IP_ADDRESS); |
| 121 | ERR_add_error_data(2,"host=",str); | 112 | goto err; |
| 122 | return(0); | ||
| 123 | } | 113 | } |
| 124 | else | ||
| 125 | { /* do a gethostbyname */ | ||
| 126 | if (!BIO_sock_init()) return(0); | ||
| 127 | 114 | ||
| 128 | he=BIO_gethostbyname(str); | 115 | /* do a gethostbyname */ |
| 129 | if (he == NULL) | 116 | if (!BIO_sock_init()) |
| 130 | { | 117 | return(0); /* don't generate another error code here */ |
| 131 | BIOerr(BIO_F_BIO_GET_HOST_IP,BIO_R_BAD_HOSTNAME_LOOKUP); | ||
| 132 | ERR_add_error_data(2,"host=",str); | ||
| 133 | return(0); | ||
| 134 | } | ||
| 135 | 118 | ||
| 136 | /* cast to short because of win16 winsock definition */ | 119 | CRYPTO_w_lock(CRYPTO_LOCK_GETHOSTBYNAME); |
| 137 | if ((short)he->h_addrtype != AF_INET) | 120 | locked = 1; |
| 138 | { | 121 | he=BIO_gethostbyname(str); |
| 139 | BIOerr(BIO_F_BIO_GET_HOST_IP,BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET); | 122 | if (he == NULL) |
| 140 | ERR_add_error_data(2,"host=",str); | 123 | { |
| 141 | return(0); | 124 | BIOerr(BIO_F_BIO_GET_HOST_IP,BIO_R_BAD_HOSTNAME_LOOKUP); |
| 142 | } | 125 | goto err; |
| 143 | for (i=0; i<4; i++) | ||
| 144 | ip[i]=he->h_addr_list[0][i]; | ||
| 145 | } | 126 | } |
| 146 | return(1); | 127 | |
| 128 | /* cast to short because of win16 winsock definition */ | ||
| 129 | if ((short)he->h_addrtype != AF_INET) | ||
| 130 | { | ||
| 131 | BIOerr(BIO_F_BIO_GET_HOST_IP,BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET); | ||
| 132 | goto err; | ||
| 133 | } | ||
| 134 | for (i=0; i<4; i++) | ||
| 135 | ip[i]=he->h_addr_list[0][i]; | ||
| 136 | err = 0; | ||
| 137 | |||
| 138 | err: | ||
| 139 | if (locked) | ||
| 140 | CRYPTO_w_unlock(CRYPTO_LOCK_GETHOSTBYNAME); | ||
| 141 | if (err) | ||
| 142 | { | ||
| 143 | ERR_add_error_data(2,"host=",str); | ||
| 144 | return 0; | ||
| 145 | } | ||
| 146 | else | ||
| 147 | return 1; | ||
| 147 | } | 148 | } |
| 148 | 149 | ||
| 149 | int BIO_get_port(str,port_ptr) | 150 | int BIO_get_port(const char *str, unsigned short *port_ptr) |
| 150 | char *str; | ||
| 151 | short *port_ptr; | ||
| 152 | { | 151 | { |
| 153 | int i; | 152 | int i; |
| 154 | struct servent *s; | 153 | struct servent *s; |
| @@ -163,8 +162,12 @@ short *port_ptr; | |||
| 163 | *port_ptr=(unsigned short)i; | 162 | *port_ptr=(unsigned short)i; |
| 164 | else | 163 | else |
| 165 | { | 164 | { |
| 166 | s=getservbyname(str,"tcp"); | 165 | CRYPTO_w_lock(CRYPTO_LOCK_GETSERVBYNAME); |
| 167 | if (s == NULL) | 166 | s=getservbyname(str,"tcp"); |
| 167 | if(s != NULL) | ||
| 168 | *port_ptr=ntohs((unsigned short)s->s_port); | ||
| 169 | CRYPTO_w_unlock(CRYPTO_LOCK_GETSERVBYNAME); | ||
| 170 | if(s == NULL) | ||
| 168 | { | 171 | { |
| 169 | if (strcmp(str,"http") == 0) | 172 | if (strcmp(str,"http") == 0) |
| 170 | *port_ptr=80; | 173 | *port_ptr=80; |
| @@ -190,31 +193,30 @@ short *port_ptr; | |||
| 190 | ERR_add_error_data(3,"service='",str,"'"); | 193 | ERR_add_error_data(3,"service='",str,"'"); |
| 191 | return(0); | 194 | return(0); |
| 192 | } | 195 | } |
| 193 | return(1); | ||
| 194 | } | 196 | } |
| 195 | *port_ptr=htons((unsigned short)s->s_port); | ||
| 196 | } | 197 | } |
| 197 | return(1); | 198 | return(1); |
| 198 | } | 199 | } |
| 199 | 200 | ||
| 200 | int BIO_sock_error(sock) | 201 | int BIO_sock_error(int sock) |
| 201 | int sock; | ||
| 202 | { | 202 | { |
| 203 | int j,i,size; | 203 | int j,i; |
| 204 | int size; | ||
| 204 | 205 | ||
| 205 | size=sizeof(int); | 206 | size=sizeof(int); |
| 206 | 207 | /* Note: under Windows the third parameter is of type (char *) | |
| 207 | i=getsockopt(sock,SOL_SOCKET,SO_ERROR,(char *)&j,&size); | 208 | * whereas under other systems it is (void *) if you don't have |
| 209 | * a cast it will choke the compiler: if you do have a cast then | ||
| 210 | * you can either go for (char *) or (void *). | ||
| 211 | */ | ||
| 212 | i=getsockopt(sock,SOL_SOCKET,SO_ERROR,(void *)&j,(void *)&size); | ||
| 208 | if (i < 0) | 213 | if (i < 0) |
| 209 | return(1); | 214 | return(1); |
| 210 | else | 215 | else |
| 211 | return(j); | 216 | return(j); |
| 212 | } | 217 | } |
| 213 | 218 | ||
| 214 | long BIO_ghbn_ctrl(cmd,iarg,parg) | 219 | long BIO_ghbn_ctrl(int cmd, int iarg, char *parg) |
| 215 | int cmd; | ||
| 216 | int iarg; | ||
| 217 | char *parg; | ||
| 218 | { | 220 | { |
| 219 | int i; | 221 | int i; |
| 220 | char **p; | 222 | char **p; |
| @@ -223,13 +225,13 @@ char *parg; | |||
| 223 | { | 225 | { |
| 224 | case BIO_GHBN_CTRL_HITS: | 226 | case BIO_GHBN_CTRL_HITS: |
| 225 | return(BIO_ghbn_hits); | 227 | return(BIO_ghbn_hits); |
| 226 | break; | 228 | /* break; */ |
| 227 | case BIO_GHBN_CTRL_MISSES: | 229 | case BIO_GHBN_CTRL_MISSES: |
| 228 | return(BIO_ghbn_miss); | 230 | return(BIO_ghbn_miss); |
| 229 | break; | 231 | /* break; */ |
| 230 | case BIO_GHBN_CTRL_CACHE_SIZE: | 232 | case BIO_GHBN_CTRL_CACHE_SIZE: |
| 231 | return(GHBN_NUM); | 233 | return(GHBN_NUM); |
| 232 | break; | 234 | /* break; */ |
| 233 | case BIO_GHBN_CTRL_GET_ENTRY: | 235 | case BIO_GHBN_CTRL_GET_ENTRY: |
| 234 | if ((iarg >= 0) && (iarg <GHBN_NUM) && | 236 | if ((iarg >= 0) && (iarg <GHBN_NUM) && |
| 235 | (ghbn_cache[iarg].order > 0)) | 237 | (ghbn_cache[iarg].order > 0)) |
| @@ -241,7 +243,7 @@ char *parg; | |||
| 241 | return(1); | 243 | return(1); |
| 242 | } | 244 | } |
| 243 | return(0); | 245 | return(0); |
| 244 | break; | 246 | /* break; */ |
| 245 | case BIO_GHBN_CTRL_FLUSH: | 247 | case BIO_GHBN_CTRL_FLUSH: |
| 246 | for (i=0; i<GHBN_NUM; i++) | 248 | for (i=0; i<GHBN_NUM; i++) |
| 247 | ghbn_cache[i].order=0; | 249 | ghbn_cache[i].order=0; |
| @@ -252,77 +254,84 @@ char *parg; | |||
| 252 | return(1); | 254 | return(1); |
| 253 | } | 255 | } |
| 254 | 256 | ||
| 255 | static struct hostent *ghbn_dup(a) | 257 | static struct hostent *ghbn_dup(struct hostent *a) |
| 256 | struct hostent *a; | ||
| 257 | { | 258 | { |
| 258 | struct hostent *ret; | 259 | struct hostent *ret; |
| 259 | int i,j; | 260 | int i,j; |
| 260 | 261 | ||
| 261 | ret=(struct hostent *)malloc(sizeof(struct hostent)); | 262 | MemCheck_off(); |
| 263 | ret=(struct hostent *)Malloc(sizeof(struct hostent)); | ||
| 262 | if (ret == NULL) return(NULL); | 264 | if (ret == NULL) return(NULL); |
| 263 | memset(ret,0,sizeof(struct hostent)); | 265 | memset(ret,0,sizeof(struct hostent)); |
| 264 | 266 | ||
| 265 | for (i=0; a->h_aliases[i] != NULL; i++) | 267 | for (i=0; a->h_aliases[i] != NULL; i++) |
| 266 | ; | 268 | ; |
| 267 | i++; | 269 | i++; |
| 268 | ret->h_aliases=(char **)malloc(sizeof(char *)*i); | 270 | ret->h_aliases = (char **)Malloc(i*sizeof(char *)); |
| 269 | memset(ret->h_aliases,0,sizeof(char *)*i); | 271 | if (ret->h_aliases == NULL) |
| 270 | if (ret == NULL) goto err; | 272 | goto err; |
| 273 | memset(ret->h_aliases, 0, i*sizeof(char *)); | ||
| 271 | 274 | ||
| 272 | for (i=0; a->h_addr_list[i] != NULL; i++) | 275 | for (i=0; a->h_addr_list[i] != NULL; i++) |
| 273 | ; | 276 | ; |
| 274 | i++; | 277 | i++; |
| 275 | ret->h_addr_list=(char **)malloc(sizeof(char *)*i); | 278 | ret->h_addr_list=(char **)Malloc(i*sizeof(char *)); |
| 276 | memset(ret->h_addr_list,0,sizeof(char *)*i); | 279 | if (ret->h_addr_list == NULL) |
| 277 | if (ret->h_addr_list == NULL) goto err; | 280 | goto err; |
| 281 | memset(ret->h_addr_list, 0, i*sizeof(char *)); | ||
| 278 | 282 | ||
| 279 | j=strlen(a->h_name)+1; | 283 | j=strlen(a->h_name)+1; |
| 280 | if ((ret->h_name=malloc(j)) == NULL) goto err; | 284 | if ((ret->h_name=Malloc(j)) == NULL) goto err; |
| 281 | memcpy((char *)ret->h_name,a->h_name,j); | 285 | memcpy((char *)ret->h_name,a->h_name,j+1); |
| 282 | for (i=0; a->h_aliases[i] != NULL; i++) | 286 | for (i=0; a->h_aliases[i] != NULL; i++) |
| 283 | { | 287 | { |
| 284 | j=strlen(a->h_aliases[i])+1; | 288 | j=strlen(a->h_aliases[i])+1; |
| 285 | if ((ret->h_aliases[i]=malloc(j)) == NULL) goto err; | 289 | if ((ret->h_aliases[i]=Malloc(j)) == NULL) goto err; |
| 286 | memcpy(ret->h_aliases[i],a->h_aliases[i],j); | 290 | memcpy(ret->h_aliases[i],a->h_aliases[i],j+1); |
| 287 | } | 291 | } |
| 288 | ret->h_length=a->h_length; | 292 | ret->h_length=a->h_length; |
| 289 | ret->h_addrtype=a->h_addrtype; | 293 | ret->h_addrtype=a->h_addrtype; |
| 290 | for (i=0; a->h_addr_list[i] != NULL; i++) | 294 | for (i=0; a->h_addr_list[i] != NULL; i++) |
| 291 | { | 295 | { |
| 292 | if ((ret->h_addr_list[i]=malloc(a->h_length)) == NULL) | 296 | if ((ret->h_addr_list[i]=Malloc(a->h_length)) == NULL) |
| 293 | goto err; | 297 | goto err; |
| 294 | memcpy(ret->h_addr_list[i],a->h_addr_list[i],a->h_length); | 298 | memcpy(ret->h_addr_list[i],a->h_addr_list[i],a->h_length); |
| 295 | } | 299 | } |
| 296 | return(ret); | 300 | if (0) |
| 301 | { | ||
| 297 | err: | 302 | err: |
| 298 | if (ret != NULL) | 303 | if (ret != NULL) |
| 299 | ghbn_free(ret); | 304 | ghbn_free(ret); |
| 300 | return(NULL); | 305 | ret=NULL; |
| 306 | } | ||
| 307 | MemCheck_on(); | ||
| 308 | return(ret); | ||
| 301 | } | 309 | } |
| 302 | 310 | ||
| 303 | static void ghbn_free(a) | 311 | static void ghbn_free(struct hostent *a) |
| 304 | struct hostent *a; | ||
| 305 | { | 312 | { |
| 306 | int i; | 313 | int i; |
| 307 | 314 | ||
| 315 | if(a == NULL) | ||
| 316 | return; | ||
| 317 | |||
| 308 | if (a->h_aliases != NULL) | 318 | if (a->h_aliases != NULL) |
| 309 | { | 319 | { |
| 310 | for (i=0; a->h_aliases[i] != NULL; i++) | 320 | for (i=0; a->h_aliases[i] != NULL; i++) |
| 311 | free(a->h_aliases[i]); | 321 | Free(a->h_aliases[i]); |
| 312 | free(a->h_aliases); | 322 | Free(a->h_aliases); |
| 313 | } | 323 | } |
| 314 | if (a->h_addr_list != NULL) | 324 | if (a->h_addr_list != NULL) |
| 315 | { | 325 | { |
| 316 | for (i=0; a->h_addr_list[i] != NULL; i++) | 326 | for (i=0; a->h_addr_list[i] != NULL; i++) |
| 317 | free(a->h_addr_list[i]); | 327 | Free(a->h_addr_list[i]); |
| 318 | free(a->h_addr_list); | 328 | Free(a->h_addr_list); |
| 319 | } | 329 | } |
| 320 | if (a->h_name != NULL) free((char *)a->h_name); | 330 | if (a->h_name != NULL) Free((char *)a->h_name); |
| 321 | free(a); | 331 | Free(a); |
| 322 | } | 332 | } |
| 323 | 333 | ||
| 324 | struct hostent *BIO_gethostbyname(name) | 334 | struct hostent *BIO_gethostbyname(const char *name) |
| 325 | char *name; | ||
| 326 | { | 335 | { |
| 327 | struct hostent *ret; | 336 | struct hostent *ret; |
| 328 | int i,lowi=0,j; | 337 | int i,lowi=0,j; |
| @@ -330,7 +339,12 @@ char *name; | |||
| 330 | 339 | ||
| 331 | /* return(gethostbyname(name)); */ | 340 | /* return(gethostbyname(name)); */ |
| 332 | 341 | ||
| 333 | CRYPTO_w_lock(CRYPTO_LOCK_BIO_GETHOSTBYNAME); | 342 | #if 0 /* It doesn't make sense to use locking here: The function interface |
| 343 | * is not thread-safe, because threads can never be sure when | ||
| 344 | * some other thread destroys the data they were given a pointer to. | ||
| 345 | */ | ||
| 346 | CRYPTO_w_lock(CRYPTO_LOCK_GETHOSTBYNAME); | ||
| 347 | #endif | ||
| 334 | j=strlen(name); | 348 | j=strlen(name); |
| 335 | if (j < 128) | 349 | if (j < 128) |
| 336 | { | 350 | { |
| @@ -356,15 +370,29 @@ char *name; | |||
| 356 | BIO_ghbn_miss++; | 370 | BIO_ghbn_miss++; |
| 357 | ret=gethostbyname(name); | 371 | ret=gethostbyname(name); |
| 358 | 372 | ||
| 359 | if (ret == NULL) return(NULL); | 373 | if (ret == NULL) |
| 360 | if (j > 128) return(ret); /* too big to cache */ | 374 | goto end; |
| 375 | if (j > 128) /* too big to cache */ | ||
| 376 | { | ||
| 377 | #if 0 /* If we were trying to make this function thread-safe (which | ||
| 378 | * is bound to fail), we'd have to give up in this case | ||
| 379 | * (or allocate more memory). */ | ||
| 380 | ret = NULL; | ||
| 381 | #endif | ||
| 382 | goto end; | ||
| 383 | } | ||
| 361 | 384 | ||
| 362 | /* else add to cache */ | 385 | /* else add to cache */ |
| 363 | if (ghbn_cache[lowi].ent != NULL) | 386 | if (ghbn_cache[lowi].ent != NULL) |
| 364 | ghbn_free(ghbn_cache[lowi].ent); | 387 | ghbn_free(ghbn_cache[lowi].ent); /* XXX not thread-safe */ |
| 388 | ghbn_cache[lowi].name[0] = '\0'; | ||
| 365 | 389 | ||
| 390 | if((ret=ghbn_cache[lowi].ent=ghbn_dup(ret)) == NULL) | ||
| 391 | { | ||
| 392 | BIOerr(BIO_F_BIO_GETHOSTBYNAME,ERR_R_MALLOC_FAILURE); | ||
| 393 | goto end; | ||
| 394 | } | ||
| 366 | strncpy(ghbn_cache[lowi].name,name,128); | 395 | strncpy(ghbn_cache[lowi].name,name,128); |
| 367 | ghbn_cache[lowi].ent=ghbn_dup(ret); | ||
| 368 | ghbn_cache[lowi].order=BIO_ghbn_miss+BIO_ghbn_hits; | 396 | ghbn_cache[lowi].order=BIO_ghbn_miss+BIO_ghbn_hits; |
| 369 | } | 397 | } |
| 370 | else | 398 | else |
| @@ -373,11 +401,14 @@ char *name; | |||
| 373 | ret= ghbn_cache[i].ent; | 401 | ret= ghbn_cache[i].ent; |
| 374 | ghbn_cache[i].order=BIO_ghbn_miss+BIO_ghbn_hits; | 402 | ghbn_cache[i].order=BIO_ghbn_miss+BIO_ghbn_hits; |
| 375 | } | 403 | } |
| 376 | CRYPTO_w_unlock(CRYPTO_LOCK_BIO_GETHOSTBYNAME); | 404 | end: |
| 405 | #if 0 | ||
| 406 | CRYPTO_w_unlock(CRYPTO_LOCK_GETHOSTBYNAME); | ||
| 407 | #endif | ||
| 377 | return(ret); | 408 | return(ret); |
| 378 | } | 409 | } |
| 379 | 410 | ||
| 380 | int BIO_sock_init() | 411 | int BIO_sock_init(void) |
| 381 | { | 412 | { |
| 382 | #ifdef WINDOWS | 413 | #ifdef WINDOWS |
| 383 | static struct WSAData wsa_state; | 414 | static struct WSAData wsa_state; |
| @@ -403,7 +434,7 @@ int BIO_sock_init() | |||
| 403 | return(1); | 434 | return(1); |
| 404 | } | 435 | } |
| 405 | 436 | ||
| 406 | void BIO_sock_cleanup() | 437 | void BIO_sock_cleanup(void) |
| 407 | { | 438 | { |
| 408 | #ifdef WINDOWS | 439 | #ifdef WINDOWS |
| 409 | if (wsa_init_done) | 440 | if (wsa_init_done) |
| @@ -415,10 +446,9 @@ void BIO_sock_cleanup() | |||
| 415 | #endif | 446 | #endif |
| 416 | } | 447 | } |
| 417 | 448 | ||
| 418 | int BIO_socket_ioctl(fd,type,arg) | 449 | #if !defined(VMS) || __VMS_VER >= 70000000 |
| 419 | int fd; | 450 | |
| 420 | long type; | 451 | int BIO_socket_ioctl(int fd, long type, unsigned long *arg) |
| 421 | unsigned long *arg; | ||
| 422 | { | 452 | { |
| 423 | int i; | 453 | int i; |
| 424 | 454 | ||
| @@ -427,12 +457,11 @@ unsigned long *arg; | |||
| 427 | SYSerr(SYS_F_IOCTLSOCKET,get_last_socket_error()); | 457 | SYSerr(SYS_F_IOCTLSOCKET,get_last_socket_error()); |
| 428 | return(i); | 458 | return(i); |
| 429 | } | 459 | } |
| 460 | #endif /* __VMS_VER */ | ||
| 430 | 461 | ||
| 431 | /* The reason I have implemented this instead of using sscanf is because | 462 | /* The reason I have implemented this instead of using sscanf is because |
| 432 | * Visual C 1.52c gives an unresolved external when linking a DLL :-( */ | 463 | * Visual C 1.52c gives an unresolved external when linking a DLL :-( */ |
| 433 | static int get_ip(str,ip) | 464 | static int get_ip(const char *str, unsigned char ip[4]) |
| 434 | char *str; | ||
| 435 | unsigned char ip[4]; | ||
| 436 | { | 465 | { |
| 437 | unsigned int tmp[4]; | 466 | unsigned int tmp[4]; |
| 438 | int num=0,c,ok=0; | 467 | int num=0,c,ok=0; |
| @@ -467,16 +496,17 @@ unsigned char ip[4]; | |||
| 467 | return(1); | 496 | return(1); |
| 468 | } | 497 | } |
| 469 | 498 | ||
| 470 | int BIO_get_accept_socket(host) | 499 | int BIO_get_accept_socket(char *host, int bind_mode) |
| 471 | char *host; | ||
| 472 | { | 500 | { |
| 473 | int ret=0; | 501 | int ret=0; |
| 474 | struct sockaddr_in server; | 502 | struct sockaddr_in server,client; |
| 475 | int s= -1; | 503 | int s= -1,cs; |
| 476 | unsigned char ip[4]; | 504 | unsigned char ip[4]; |
| 477 | short port; | 505 | unsigned short port; |
| 478 | char *str,*h,*p,*e; | 506 | char *str,*e; |
| 507 | const char *h,*p; | ||
| 479 | unsigned long l; | 508 | unsigned long l; |
| 509 | int err_num; | ||
| 480 | 510 | ||
| 481 | if (!BIO_sock_init()) return(INVALID_SOCKET); | 511 | if (!BIO_sock_init()) return(INVALID_SOCKET); |
| 482 | 512 | ||
| @@ -508,7 +538,7 @@ char *host; | |||
| 508 | 538 | ||
| 509 | memset((char *)&server,0,sizeof(server)); | 539 | memset((char *)&server,0,sizeof(server)); |
| 510 | server.sin_family=AF_INET; | 540 | server.sin_family=AF_INET; |
| 511 | server.sin_port=htons((unsigned short)port); | 541 | server.sin_port=htons(port); |
| 512 | 542 | ||
| 513 | if (strcmp(h,"*") == 0) | 543 | if (strcmp(h,"*") == 0) |
| 514 | server.sin_addr.s_addr=INADDR_ANY; | 544 | server.sin_addr.s_addr=INADDR_ANY; |
| @@ -517,12 +547,13 @@ char *host; | |||
| 517 | if (!BIO_get_host_ip(h,&(ip[0]))) return(INVALID_SOCKET); | 547 | if (!BIO_get_host_ip(h,&(ip[0]))) return(INVALID_SOCKET); |
| 518 | l=(unsigned long) | 548 | l=(unsigned long) |
| 519 | ((unsigned long)ip[0]<<24L)| | 549 | ((unsigned long)ip[0]<<24L)| |
| 520 | ((unsigned long)ip[0]<<16L)| | 550 | ((unsigned long)ip[1]<<16L)| |
| 521 | ((unsigned long)ip[0]<< 8L)| | 551 | ((unsigned long)ip[2]<< 8L)| |
| 522 | ((unsigned long)ip[0]); | 552 | ((unsigned long)ip[3]); |
| 523 | server.sin_addr.s_addr=htonl(l); | 553 | server.sin_addr.s_addr=htonl(l); |
| 524 | } | 554 | } |
| 525 | 555 | ||
| 556 | again: | ||
| 526 | s=socket(AF_INET,SOCK_STREAM,SOCKET_PROTOCOL); | 557 | s=socket(AF_INET,SOCK_STREAM,SOCKET_PROTOCOL); |
| 527 | if (s == INVALID_SOCKET) | 558 | if (s == INVALID_SOCKET) |
| 528 | { | 559 | { |
| @@ -531,9 +562,45 @@ char *host; | |||
| 531 | BIOerr(BIO_F_BIO_GET_ACCEPT_SOCKET,BIO_R_UNABLE_TO_CREATE_SOCKET); | 562 | BIOerr(BIO_F_BIO_GET_ACCEPT_SOCKET,BIO_R_UNABLE_TO_CREATE_SOCKET); |
| 532 | goto err; | 563 | goto err; |
| 533 | } | 564 | } |
| 565 | |||
| 566 | #ifdef SO_REUSEADDR | ||
| 567 | if (bind_mode == BIO_BIND_REUSEADDR) | ||
| 568 | { | ||
| 569 | int i=1; | ||
| 570 | |||
| 571 | ret=setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char *)&i,sizeof(i)); | ||
| 572 | bind_mode=BIO_BIND_NORMAL; | ||
| 573 | } | ||
| 574 | #endif | ||
| 534 | if (bind(s,(struct sockaddr *)&server,sizeof(server)) == -1) | 575 | if (bind(s,(struct sockaddr *)&server,sizeof(server)) == -1) |
| 535 | { | 576 | { |
| 536 | SYSerr(SYS_F_BIND,get_last_socket_error()); | 577 | #ifdef SO_REUSEADDR |
| 578 | err_num=get_last_socket_error(); | ||
| 579 | if ((bind_mode == BIO_BIND_REUSEADDR_IF_UNUSED) && | ||
| 580 | (err_num == EADDRINUSE)) | ||
| 581 | { | ||
| 582 | memcpy((char *)&client,(char *)&server,sizeof(server)); | ||
| 583 | if (strcmp(h,"*") == 0) | ||
| 584 | client.sin_addr.s_addr=htonl(0x7F000001); | ||
| 585 | cs=socket(AF_INET,SOCK_STREAM,SOCKET_PROTOCOL); | ||
| 586 | if (cs != INVALID_SOCKET) | ||
| 587 | { | ||
| 588 | int ii; | ||
| 589 | ii=connect(cs,(struct sockaddr *)&client, | ||
| 590 | sizeof(client)); | ||
| 591 | closesocket(cs); | ||
| 592 | if (ii == INVALID_SOCKET) | ||
| 593 | { | ||
| 594 | bind_mode=BIO_BIND_REUSEADDR; | ||
| 595 | closesocket(s); | ||
| 596 | goto again; | ||
| 597 | } | ||
| 598 | /* else error */ | ||
| 599 | } | ||
| 600 | /* else error */ | ||
| 601 | } | ||
| 602 | #endif | ||
| 603 | SYSerr(SYS_F_BIND,err_num); | ||
| 537 | ERR_add_error_data(3,"port='",host,"'"); | 604 | ERR_add_error_data(3,"port='",host,"'"); |
| 538 | BIOerr(BIO_F_BIO_GET_ACCEPT_SOCKET,BIO_R_UNABLE_TO_BIND_SOCKET); | 605 | BIOerr(BIO_F_BIO_GET_ACCEPT_SOCKET,BIO_R_UNABLE_TO_BIND_SOCKET); |
| 539 | goto err; | 606 | goto err; |
| @@ -550,30 +617,29 @@ err: | |||
| 550 | if (str != NULL) Free(str); | 617 | if (str != NULL) Free(str); |
| 551 | if ((ret == 0) && (s != INVALID_SOCKET)) | 618 | if ((ret == 0) && (s != INVALID_SOCKET)) |
| 552 | { | 619 | { |
| 553 | #ifdef WINDOWS | ||
| 554 | closesocket(s); | 620 | closesocket(s); |
| 555 | #else | ||
| 556 | close(s); | ||
| 557 | #endif | ||
| 558 | s= INVALID_SOCKET; | 621 | s= INVALID_SOCKET; |
| 559 | } | 622 | } |
| 560 | return(s); | 623 | return(s); |
| 561 | } | 624 | } |
| 562 | 625 | ||
| 563 | int BIO_accept(sock,addr) | 626 | int BIO_accept(int sock, char **addr) |
| 564 | int sock; | ||
| 565 | char **addr; | ||
| 566 | { | 627 | { |
| 567 | int ret=INVALID_SOCKET; | 628 | int ret=INVALID_SOCKET; |
| 568 | static struct sockaddr_in from; | 629 | static struct sockaddr_in from; |
| 569 | unsigned long l; | 630 | unsigned long l; |
| 570 | short port; | 631 | unsigned short port; |
| 571 | int len; | 632 | int len; |
| 572 | char *p; | 633 | char *p; |
| 573 | 634 | ||
| 574 | memset((char *)&from,0,sizeof(from)); | 635 | memset((char *)&from,0,sizeof(from)); |
| 575 | len=sizeof(from); | 636 | len=sizeof(from); |
| 576 | ret=accept(sock,(struct sockaddr *)&from,&len); | 637 | /* Note: under VMS with SOCKETSHR the fourth parameter is currently |
| 638 | * of type (int *) whereas under other systems it is (void *) if | ||
| 639 | * you don't have a cast it will choke the compiler: if you do | ||
| 640 | * have a cast then you can either go for (int *) or (void *). | ||
| 641 | */ | ||
| 642 | ret=accept(sock,(struct sockaddr *)&from,(void *)&len); | ||
| 577 | if (ret == INVALID_SOCKET) | 643 | if (ret == INVALID_SOCKET) |
| 578 | { | 644 | { |
| 579 | SYSerr(SYS_F_ACCEPT,get_last_socket_error()); | 645 | SYSerr(SYS_F_ACCEPT,get_last_socket_error()); |
| @@ -604,9 +670,7 @@ end: | |||
| 604 | return(ret); | 670 | return(ret); |
| 605 | } | 671 | } |
| 606 | 672 | ||
| 607 | int BIO_set_tcp_ndelay(s,on) | 673 | int BIO_set_tcp_ndelay(int s, int on) |
| 608 | int s; | ||
| 609 | int on; | ||
| 610 | { | 674 | { |
| 611 | int ret=0; | 675 | int ret=0; |
| 612 | #if defined(TCP_NODELAY) && (defined(IPPROTO_TCP) || defined(SOL_TCP)) | 676 | #if defined(TCP_NODELAY) && (defined(IPPROTO_TCP) || defined(SOL_TCP)) |
| @@ -626,3 +690,14 @@ int on; | |||
| 626 | } | 690 | } |
| 627 | #endif | 691 | #endif |
| 628 | 692 | ||
| 693 | int BIO_socket_nbio(int s, int mode) | ||
| 694 | { | ||
| 695 | int ret= -1; | ||
| 696 | unsigned long l; | ||
| 697 | |||
| 698 | l=mode; | ||
| 699 | #ifdef FIONBIO | ||
| 700 | ret=BIO_socket_ioctl(s,FIONBIO,&l); | ||
| 701 | #endif | ||
| 702 | return(ret == 0); | ||
| 703 | } | ||
diff --git a/src/lib/libcrypto/bio/bf_buff.c b/src/lib/libcrypto/bio/bf_buff.c index 7912b88473..acd8148138 100644 --- a/src/lib/libcrypto/bio/bf_buff.c +++ b/src/lib/libcrypto/bio/bf_buff.c | |||
| @@ -59,10 +59,9 @@ | |||
| 59 | #include <stdio.h> | 59 | #include <stdio.h> |
| 60 | #include <errno.h> | 60 | #include <errno.h> |
| 61 | #include "cryptlib.h" | 61 | #include "cryptlib.h" |
| 62 | #include "bio.h" | 62 | #include <openssl/bio.h> |
| 63 | #include "evp.h" | 63 | #include <openssl/evp.h> |
| 64 | 64 | ||
| 65 | #ifndef NOPROTO | ||
| 66 | static int buffer_write(BIO *h,char *buf,int num); | 65 | static int buffer_write(BIO *h,char *buf,int num); |
| 67 | static int buffer_read(BIO *h,char *buf,int size); | 66 | static int buffer_read(BIO *h,char *buf,int size); |
| 68 | static int buffer_puts(BIO *h,char *str); | 67 | static int buffer_puts(BIO *h,char *str); |
| @@ -70,16 +69,6 @@ static int buffer_gets(BIO *h,char *str,int size); | |||
| 70 | static long buffer_ctrl(BIO *h,int cmd,long arg1,char *arg2); | 69 | static long buffer_ctrl(BIO *h,int cmd,long arg1,char *arg2); |
| 71 | static int buffer_new(BIO *h); | 70 | static int buffer_new(BIO *h); |
| 72 | static int buffer_free(BIO *data); | 71 | static int buffer_free(BIO *data); |
| 73 | #else | ||
| 74 | static int buffer_write(); | ||
| 75 | static int buffer_read(); | ||
| 76 | static int buffer_puts(); | ||
| 77 | static int buffer_gets(); | ||
| 78 | static long buffer_ctrl(); | ||
| 79 | static int buffer_new(); | ||
| 80 | static int buffer_free(); | ||
| 81 | #endif | ||
| 82 | |||
| 83 | #define DEFAULT_BUFFER_SIZE 1024 | 72 | #define DEFAULT_BUFFER_SIZE 1024 |
| 84 | 73 | ||
| 85 | static BIO_METHOD methods_buffer= | 74 | static BIO_METHOD methods_buffer= |
| @@ -95,13 +84,12 @@ static BIO_METHOD methods_buffer= | |||
| 95 | buffer_free, | 84 | buffer_free, |
| 96 | }; | 85 | }; |
| 97 | 86 | ||
| 98 | BIO_METHOD *BIO_f_buffer() | 87 | BIO_METHOD *BIO_f_buffer(void) |
| 99 | { | 88 | { |
| 100 | return(&methods_buffer); | 89 | return(&methods_buffer); |
| 101 | } | 90 | } |
| 102 | 91 | ||
| 103 | static int buffer_new(bi) | 92 | static int buffer_new(BIO *bi) |
| 104 | BIO *bi; | ||
| 105 | { | 93 | { |
| 106 | BIO_F_BUFFER_CTX *ctx; | 94 | BIO_F_BUFFER_CTX *ctx; |
| 107 | 95 | ||
| @@ -124,8 +112,7 @@ BIO *bi; | |||
| 124 | return(1); | 112 | return(1); |
| 125 | } | 113 | } |
| 126 | 114 | ||
| 127 | static int buffer_free(a) | 115 | static int buffer_free(BIO *a) |
| 128 | BIO *a; | ||
| 129 | { | 116 | { |
| 130 | BIO_F_BUFFER_CTX *b; | 117 | BIO_F_BUFFER_CTX *b; |
| 131 | 118 | ||
| @@ -140,10 +127,7 @@ BIO *a; | |||
| 140 | return(1); | 127 | return(1); |
| 141 | } | 128 | } |
| 142 | 129 | ||
| 143 | static int buffer_read(b,out,outl) | 130 | static int buffer_read(BIO *b, char *out, int outl) |
| 144 | BIO *b; | ||
| 145 | char *out; | ||
| 146 | int outl; | ||
| 147 | { | 131 | { |
| 148 | int i,num=0; | 132 | int i,num=0; |
| 149 | BIO_F_BUFFER_CTX *ctx; | 133 | BIO_F_BUFFER_CTX *ctx; |
| @@ -209,10 +193,7 @@ start: | |||
| 209 | goto start; | 193 | goto start; |
| 210 | } | 194 | } |
| 211 | 195 | ||
| 212 | static int buffer_write(b,in,inl) | 196 | static int buffer_write(BIO *b, char *in, int inl) |
| 213 | BIO *b; | ||
| 214 | char *in; | ||
| 215 | int inl; | ||
| 216 | { | 197 | { |
| 217 | int i,num=0; | 198 | int i,num=0; |
| 218 | BIO_F_BUFFER_CTX *ctx; | 199 | BIO_F_BUFFER_CTX *ctx; |
| @@ -285,11 +266,7 @@ start: | |||
| 285 | goto start; | 266 | goto start; |
| 286 | } | 267 | } |
| 287 | 268 | ||
| 288 | static long buffer_ctrl(b,cmd,num,ptr) | 269 | static long buffer_ctrl(BIO *b, int cmd, long num, char *ptr) |
| 289 | BIO *b; | ||
| 290 | int cmd; | ||
| 291 | long num; | ||
| 292 | char *ptr; | ||
| 293 | { | 270 | { |
| 294 | BIO *dbio; | 271 | BIO *dbio; |
| 295 | BIO_F_BUFFER_CTX *ctx; | 272 | BIO_F_BUFFER_CTX *ctx; |
| @@ -432,6 +409,7 @@ fprintf(stderr,"FLUSH [%3d] %3d -> %3d\n",ctx->obuf_off,ctx->obuf_len-ctx->obuf_ | |||
| 432 | break; | 409 | break; |
| 433 | } | 410 | } |
| 434 | } | 411 | } |
| 412 | ret=BIO_ctrl(b->next_bio,cmd,num,ptr); | ||
| 435 | break; | 413 | break; |
| 436 | case BIO_CTRL_DUP: | 414 | case BIO_CTRL_DUP: |
| 437 | dbio=(BIO *)ptr; | 415 | dbio=(BIO *)ptr; |
| @@ -449,10 +427,7 @@ malloc_error: | |||
| 449 | return(0); | 427 | return(0); |
| 450 | } | 428 | } |
| 451 | 429 | ||
| 452 | static int buffer_gets(b,buf,size) | 430 | static int buffer_gets(BIO *b, char *buf, int size) |
| 453 | BIO *b; | ||
| 454 | char *buf; | ||
| 455 | int size; | ||
| 456 | { | 431 | { |
| 457 | BIO_F_BUFFER_CTX *ctx; | 432 | BIO_F_BUFFER_CTX *ctx; |
| 458 | int num=0,i,flag; | 433 | int num=0,i,flag; |
| @@ -503,9 +478,7 @@ int size; | |||
| 503 | } | 478 | } |
| 504 | } | 479 | } |
| 505 | 480 | ||
| 506 | static int buffer_puts(b,str) | 481 | static int buffer_puts(BIO *b, char *str) |
| 507 | BIO *b; | ||
| 508 | char *str; | ||
| 509 | { | 482 | { |
| 510 | return(BIO_write(b,str,strlen(str))); | 483 | return(BIO_write(b,str,strlen(str))); |
| 511 | } | 484 | } |
diff --git a/src/lib/libcrypto/bio/bf_nbio.c b/src/lib/libcrypto/bio/bf_nbio.c index 034b3024df..cbec2bae29 100644 --- a/src/lib/libcrypto/bio/bf_nbio.c +++ b/src/lib/libcrypto/bio/bf_nbio.c | |||
| @@ -59,14 +59,13 @@ | |||
| 59 | #include <stdio.h> | 59 | #include <stdio.h> |
| 60 | #include <errno.h> | 60 | #include <errno.h> |
| 61 | #include "cryptlib.h" | 61 | #include "cryptlib.h" |
| 62 | #include "rand.h" | 62 | #include <openssl/rand.h> |
| 63 | #include "bio.h" | 63 | #include <openssl/bio.h> |
| 64 | #include "evp.h" | 64 | #include <openssl/evp.h> |
| 65 | 65 | ||
| 66 | /* BIO_put and BIO_get both add to the digest, | 66 | /* BIO_put and BIO_get both add to the digest, |
| 67 | * BIO_gets returns the digest */ | 67 | * BIO_gets returns the digest */ |
| 68 | 68 | ||
| 69 | #ifndef NOPROTO | ||
| 70 | static int nbiof_write(BIO *h,char *buf,int num); | 69 | static int nbiof_write(BIO *h,char *buf,int num); |
| 71 | static int nbiof_read(BIO *h,char *buf,int size); | 70 | static int nbiof_read(BIO *h,char *buf,int size); |
| 72 | static int nbiof_puts(BIO *h,char *str); | 71 | static int nbiof_puts(BIO *h,char *str); |
| @@ -74,16 +73,6 @@ static int nbiof_gets(BIO *h,char *str,int size); | |||
| 74 | static long nbiof_ctrl(BIO *h,int cmd,long arg1,char *arg2); | 73 | static long nbiof_ctrl(BIO *h,int cmd,long arg1,char *arg2); |
| 75 | static int nbiof_new(BIO *h); | 74 | static int nbiof_new(BIO *h); |
| 76 | static int nbiof_free(BIO *data); | 75 | static int nbiof_free(BIO *data); |
| 77 | #else | ||
| 78 | static int nbiof_write(); | ||
| 79 | static int nbiof_read(); | ||
| 80 | static int nbiof_puts(); | ||
| 81 | static int nbiof_gets(); | ||
| 82 | static long nbiof_ctrl(); | ||
| 83 | static int nbiof_new(); | ||
| 84 | static int nbiof_free(); | ||
| 85 | #endif | ||
| 86 | |||
| 87 | typedef struct nbio_test_st | 76 | typedef struct nbio_test_st |
| 88 | { | 77 | { |
| 89 | /* only set if we sent a 'should retry' error */ | 78 | /* only set if we sent a 'should retry' error */ |
| @@ -104,13 +93,12 @@ static BIO_METHOD methods_nbiof= | |||
| 104 | nbiof_free, | 93 | nbiof_free, |
| 105 | }; | 94 | }; |
| 106 | 95 | ||
| 107 | BIO_METHOD *BIO_f_nbio_test() | 96 | BIO_METHOD *BIO_f_nbio_test(void) |
| 108 | { | 97 | { |
| 109 | return(&methods_nbiof); | 98 | return(&methods_nbiof); |
| 110 | } | 99 | } |
| 111 | 100 | ||
| 112 | static int nbiof_new(bi) | 101 | static int nbiof_new(BIO *bi) |
| 113 | BIO *bi; | ||
| 114 | { | 102 | { |
| 115 | NBIO_TEST *nt; | 103 | NBIO_TEST *nt; |
| 116 | 104 | ||
| @@ -123,8 +111,7 @@ BIO *bi; | |||
| 123 | return(1); | 111 | return(1); |
| 124 | } | 112 | } |
| 125 | 113 | ||
| 126 | static int nbiof_free(a) | 114 | static int nbiof_free(BIO *a) |
| 127 | BIO *a; | ||
| 128 | { | 115 | { |
| 129 | if (a == NULL) return(0); | 116 | if (a == NULL) return(0); |
| 130 | if (a->ptr != NULL) | 117 | if (a->ptr != NULL) |
| @@ -135,10 +122,7 @@ BIO *a; | |||
| 135 | return(1); | 122 | return(1); |
| 136 | } | 123 | } |
| 137 | 124 | ||
| 138 | static int nbiof_read(b,out,outl) | 125 | static int nbiof_read(BIO *b, char *out, int outl) |
| 139 | BIO *b; | ||
| 140 | char *out; | ||
| 141 | int outl; | ||
| 142 | { | 126 | { |
| 143 | NBIO_TEST *nt; | 127 | NBIO_TEST *nt; |
| 144 | int ret=0; | 128 | int ret=0; |
| @@ -173,10 +157,7 @@ int outl; | |||
| 173 | return(ret); | 157 | return(ret); |
| 174 | } | 158 | } |
| 175 | 159 | ||
| 176 | static int nbiof_write(b,in,inl) | 160 | static int nbiof_write(BIO *b, char *in, int inl) |
| 177 | BIO *b; | ||
| 178 | char *in; | ||
| 179 | int inl; | ||
| 180 | { | 161 | { |
| 181 | NBIO_TEST *nt; | 162 | NBIO_TEST *nt; |
| 182 | int ret=0; | 163 | int ret=0; |
| @@ -221,11 +202,7 @@ int inl; | |||
| 221 | return(ret); | 202 | return(ret); |
| 222 | } | 203 | } |
| 223 | 204 | ||
| 224 | static long nbiof_ctrl(b,cmd,num,ptr) | 205 | static long nbiof_ctrl(BIO *b, int cmd, long num, char *ptr) |
| 225 | BIO *b; | ||
| 226 | int cmd; | ||
| 227 | long num; | ||
| 228 | char *ptr; | ||
| 229 | { | 206 | { |
| 230 | long ret; | 207 | long ret; |
| 231 | 208 | ||
| @@ -247,19 +224,14 @@ char *ptr; | |||
| 247 | return(ret); | 224 | return(ret); |
| 248 | } | 225 | } |
| 249 | 226 | ||
| 250 | static int nbiof_gets(bp,buf,size) | 227 | static int nbiof_gets(BIO *bp, char *buf, int size) |
| 251 | BIO *bp; | ||
| 252 | char *buf; | ||
| 253 | int size; | ||
| 254 | { | 228 | { |
| 255 | if (bp->next_bio == NULL) return(0); | 229 | if (bp->next_bio == NULL) return(0); |
| 256 | return(BIO_gets(bp->next_bio,buf,size)); | 230 | return(BIO_gets(bp->next_bio,buf,size)); |
| 257 | } | 231 | } |
| 258 | 232 | ||
| 259 | 233 | ||
| 260 | static int nbiof_puts(bp,str) | 234 | static int nbiof_puts(BIO *bp, char *str) |
| 261 | BIO *bp; | ||
| 262 | char *str; | ||
| 263 | { | 235 | { |
| 264 | if (bp->next_bio == NULL) return(0); | 236 | if (bp->next_bio == NULL) return(0); |
| 265 | return(BIO_puts(bp->next_bio,str)); | 237 | return(BIO_puts(bp->next_bio,str)); |
diff --git a/src/lib/libcrypto/bio/bf_null.c b/src/lib/libcrypto/bio/bf_null.c index a47a65741a..3254a55dce 100644 --- a/src/lib/libcrypto/bio/bf_null.c +++ b/src/lib/libcrypto/bio/bf_null.c | |||
| @@ -59,13 +59,12 @@ | |||
| 59 | #include <stdio.h> | 59 | #include <stdio.h> |
| 60 | #include <errno.h> | 60 | #include <errno.h> |
| 61 | #include "cryptlib.h" | 61 | #include "cryptlib.h" |
| 62 | #include "bio.h" | 62 | #include <openssl/bio.h> |
| 63 | #include "evp.h" | 63 | #include <openssl/evp.h> |
| 64 | 64 | ||
| 65 | /* BIO_put and BIO_get both add to the digest, | 65 | /* BIO_put and BIO_get both add to the digest, |
| 66 | * BIO_gets returns the digest */ | 66 | * BIO_gets returns the digest */ |
| 67 | 67 | ||
| 68 | #ifndef NOPROTO | ||
| 69 | static int nullf_write(BIO *h,char *buf,int num); | 68 | static int nullf_write(BIO *h,char *buf,int num); |
| 70 | static int nullf_read(BIO *h,char *buf,int size); | 69 | static int nullf_read(BIO *h,char *buf,int size); |
| 71 | static int nullf_puts(BIO *h,char *str); | 70 | static int nullf_puts(BIO *h,char *str); |
| @@ -73,16 +72,6 @@ static int nullf_gets(BIO *h,char *str,int size); | |||
| 73 | static long nullf_ctrl(BIO *h,int cmd,long arg1,char *arg2); | 72 | static long nullf_ctrl(BIO *h,int cmd,long arg1,char *arg2); |
| 74 | static int nullf_new(BIO *h); | 73 | static int nullf_new(BIO *h); |
| 75 | static int nullf_free(BIO *data); | 74 | static int nullf_free(BIO *data); |
| 76 | #else | ||
| 77 | static int nullf_write(); | ||
| 78 | static int nullf_read(); | ||
| 79 | static int nullf_puts(); | ||
| 80 | static int nullf_gets(); | ||
| 81 | static long nullf_ctrl(); | ||
| 82 | static int nullf_new(); | ||
| 83 | static int nullf_free(); | ||
| 84 | #endif | ||
| 85 | |||
| 86 | static BIO_METHOD methods_nullf= | 75 | static BIO_METHOD methods_nullf= |
| 87 | { | 76 | { |
| 88 | BIO_TYPE_NULL_FILTER, | 77 | BIO_TYPE_NULL_FILTER, |
| @@ -96,13 +85,12 @@ static BIO_METHOD methods_nullf= | |||
| 96 | nullf_free, | 85 | nullf_free, |
| 97 | }; | 86 | }; |
| 98 | 87 | ||
| 99 | BIO_METHOD *BIO_f_null() | 88 | BIO_METHOD *BIO_f_null(void) |
| 100 | { | 89 | { |
| 101 | return(&methods_nullf); | 90 | return(&methods_nullf); |
| 102 | } | 91 | } |
| 103 | 92 | ||
| 104 | static int nullf_new(bi) | 93 | static int nullf_new(BIO *bi) |
| 105 | BIO *bi; | ||
| 106 | { | 94 | { |
| 107 | bi->init=1; | 95 | bi->init=1; |
| 108 | bi->ptr=NULL; | 96 | bi->ptr=NULL; |
| @@ -110,8 +98,7 @@ BIO *bi; | |||
| 110 | return(1); | 98 | return(1); |
| 111 | } | 99 | } |
| 112 | 100 | ||
| 113 | static int nullf_free(a) | 101 | static int nullf_free(BIO *a) |
| 114 | BIO *a; | ||
| 115 | { | 102 | { |
| 116 | if (a == NULL) return(0); | 103 | if (a == NULL) return(0); |
| 117 | /* a->ptr=NULL; | 104 | /* a->ptr=NULL; |
| @@ -120,10 +107,7 @@ BIO *a; | |||
| 120 | return(1); | 107 | return(1); |
| 121 | } | 108 | } |
| 122 | 109 | ||
| 123 | static int nullf_read(b,out,outl) | 110 | static int nullf_read(BIO *b, char *out, int outl) |
| 124 | BIO *b; | ||
| 125 | char *out; | ||
| 126 | int outl; | ||
| 127 | { | 111 | { |
| 128 | int ret=0; | 112 | int ret=0; |
| 129 | 113 | ||
| @@ -135,10 +119,7 @@ int outl; | |||
| 135 | return(ret); | 119 | return(ret); |
| 136 | } | 120 | } |
| 137 | 121 | ||
| 138 | static int nullf_write(b,in,inl) | 122 | static int nullf_write(BIO *b, char *in, int inl) |
| 139 | BIO *b; | ||
| 140 | char *in; | ||
| 141 | int inl; | ||
| 142 | { | 123 | { |
| 143 | int ret=0; | 124 | int ret=0; |
| 144 | 125 | ||
| @@ -150,11 +131,7 @@ int inl; | |||
| 150 | return(ret); | 131 | return(ret); |
| 151 | } | 132 | } |
| 152 | 133 | ||
| 153 | static long nullf_ctrl(b,cmd,num,ptr) | 134 | static long nullf_ctrl(BIO *b, int cmd, long num, char *ptr) |
| 154 | BIO *b; | ||
| 155 | int cmd; | ||
| 156 | long num; | ||
| 157 | char *ptr; | ||
| 158 | { | 135 | { |
| 159 | long ret; | 136 | long ret; |
| 160 | 137 | ||
| @@ -175,19 +152,14 @@ char *ptr; | |||
| 175 | return(ret); | 152 | return(ret); |
| 176 | } | 153 | } |
| 177 | 154 | ||
| 178 | static int nullf_gets(bp,buf,size) | 155 | static int nullf_gets(BIO *bp, char *buf, int size) |
| 179 | BIO *bp; | ||
| 180 | char *buf; | ||
| 181 | int size; | ||
| 182 | { | 156 | { |
| 183 | if (bp->next_bio == NULL) return(0); | 157 | if (bp->next_bio == NULL) return(0); |
| 184 | return(BIO_gets(bp->next_bio,buf,size)); | 158 | return(BIO_gets(bp->next_bio,buf,size)); |
| 185 | } | 159 | } |
| 186 | 160 | ||
| 187 | 161 | ||
| 188 | static int nullf_puts(bp,str) | 162 | static int nullf_puts(BIO *bp, char *str) |
| 189 | BIO *bp; | ||
| 190 | char *str; | ||
| 191 | { | 163 | { |
| 192 | if (bp->next_bio == NULL) return(0); | 164 | if (bp->next_bio == NULL) return(0); |
| 193 | return(BIO_puts(bp->next_bio,str)); | 165 | return(BIO_puts(bp->next_bio,str)); |
diff --git a/src/lib/libcrypto/bio/bio.err b/src/lib/libcrypto/bio/bio.err deleted file mode 100644 index 6e2f2b63ca..0000000000 --- a/src/lib/libcrypto/bio/bio.err +++ /dev/null | |||
| @@ -1,46 +0,0 @@ | |||
| 1 | /* Error codes for the BIO functions. */ | ||
| 2 | |||
| 3 | /* Function codes. */ | ||
| 4 | #define BIO_F_ACPT_STATE 100 | ||
| 5 | #define BIO_F_BIO_ACCEPT 101 | ||
| 6 | #define BIO_F_BIO_CTRL 102 | ||
| 7 | #define BIO_F_BIO_GETS 103 | ||
| 8 | #define BIO_F_BIO_GET_ACCEPT_SOCKET 104 | ||
| 9 | #define BIO_F_BIO_GET_HOST_IP 105 | ||
| 10 | #define BIO_F_BIO_GET_PORT 106 | ||
| 11 | #define BIO_F_BIO_NEW 107 | ||
| 12 | #define BIO_F_BIO_NEW_FILE 108 | ||
| 13 | #define BIO_F_BIO_PUTS 109 | ||
| 14 | #define BIO_F_BIO_READ 110 | ||
| 15 | #define BIO_F_BIO_SOCK_INIT 111 | ||
| 16 | #define BIO_F_BIO_WRITE 112 | ||
| 17 | #define BIO_F_BUFFER_CTRL 113 | ||
| 18 | #define BIO_F_CONN_STATE 114 | ||
| 19 | #define BIO_F_FILE_CTRL 115 | ||
| 20 | #define BIO_F_MEM_WRITE 116 | ||
| 21 | #define BIO_F_SSL_NEW 117 | ||
| 22 | #define BIO_F_WSASTARTUP 118 | ||
| 23 | |||
| 24 | /* Reason codes. */ | ||
| 25 | #define BIO_R_ACCEPT_ERROR 100 | ||
| 26 | #define BIO_R_BAD_FOPEN_MODE 101 | ||
| 27 | #define BIO_R_BAD_HOSTNAME_LOOKUP 102 | ||
| 28 | #define BIO_R_CONNECT_ERROR 103 | ||
| 29 | #define BIO_R_ERROR_SETTING_NBIO 104 | ||
| 30 | #define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET 105 | ||
| 31 | #define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET 106 | ||
| 32 | #define BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET 107 | ||
| 33 | #define BIO_R_INVALID_IP_ADDRESS 108 | ||
| 34 | #define BIO_R_KEEPALIVE 109 | ||
| 35 | #define BIO_R_NBIO_CONNECT_ERROR 110 | ||
| 36 | #define BIO_R_NO_ACCEPT_PORT_SPECIFIED 111 | ||
| 37 | #define BIO_R_NO_HOSTHNAME_SPECIFIED 112 | ||
| 38 | #define BIO_R_NO_PORT_DEFINED 113 | ||
| 39 | #define BIO_R_NO_PORT_SPECIFIED 114 | ||
| 40 | #define BIO_R_NULL_PARAMETER 115 | ||
| 41 | #define BIO_R_UNABLE_TO_BIND_SOCKET 116 | ||
| 42 | #define BIO_R_UNABLE_TO_CREATE_SOCKET 117 | ||
| 43 | #define BIO_R_UNABLE_TO_LISTEN_SOCKET 118 | ||
| 44 | #define BIO_R_UNINITALISED 119 | ||
| 45 | #define BIO_R_UNSUPPORTED_METHOD 120 | ||
| 46 | #define BIO_R_WSASTARTUP 121 | ||
diff --git a/src/lib/libcrypto/bio/bio.h b/src/lib/libcrypto/bio/bio.h index 300b330e00..54bf622a3b 100644 --- a/src/lib/libcrypto/bio/bio.h +++ b/src/lib/libcrypto/bio/bio.h | |||
| @@ -63,7 +63,9 @@ | |||
| 63 | extern "C" { | 63 | extern "C" { |
| 64 | #endif | 64 | #endif |
| 65 | 65 | ||
| 66 | #include "crypto.h" | 66 | #include <stdio.h> |
| 67 | #include <stdlib.h> | ||
| 68 | #include <openssl/crypto.h> | ||
| 67 | 69 | ||
| 68 | /* These are the 'types' of BIOs */ | 70 | /* These are the 'types' of BIOs */ |
| 69 | #define BIO_TYPE_NONE 0 | 71 | #define BIO_TYPE_NONE 0 |
| @@ -84,6 +86,8 @@ extern "C" { | |||
| 84 | #define BIO_TYPE_PROXY_SERVER (15|0x0200) /* server proxy BIO */ | 86 | #define BIO_TYPE_PROXY_SERVER (15|0x0200) /* server proxy BIO */ |
| 85 | #define BIO_TYPE_NBIO_TEST (16|0x0200) /* server proxy BIO */ | 87 | #define BIO_TYPE_NBIO_TEST (16|0x0200) /* server proxy BIO */ |
| 86 | #define BIO_TYPE_NULL_FILTER (17|0x0200) | 88 | #define BIO_TYPE_NULL_FILTER (17|0x0200) |
| 89 | #define BIO_TYPE_BER (18|0x0200) /* BER -> bin filter */ | ||
| 90 | #define BIO_TYPE_BIO (19|0x0400) /* (half a) BIO pair */ | ||
| 87 | 91 | ||
| 88 | #define BIO_TYPE_DESCRIPTOR 0x0100 /* socket, fd, connect or accept */ | 92 | #define BIO_TYPE_DESCRIPTOR 0x0100 /* socket, fd, connect or accept */ |
| 89 | #define BIO_TYPE_FILTER 0x0200 | 93 | #define BIO_TYPE_FILTER 0x0200 |
| @@ -202,7 +206,7 @@ extern "C" { | |||
| 202 | typedef struct bio_method_st | 206 | typedef struct bio_method_st |
| 203 | { | 207 | { |
| 204 | int type; | 208 | int type; |
| 205 | char *name; | 209 | const char *name; |
| 206 | int (*bwrite)(); | 210 | int (*bwrite)(); |
| 207 | int (*bread)(); | 211 | int (*bread)(); |
| 208 | int (*bputs)(); | 212 | int (*bputs)(); |
| @@ -215,7 +219,7 @@ typedef struct bio_method_st | |||
| 215 | typedef struct bio_method_st | 219 | typedef struct bio_method_st |
| 216 | { | 220 | { |
| 217 | int type; | 221 | int type; |
| 218 | char *name; | 222 | const char *name; |
| 219 | int (_far *bwrite)(); | 223 | int (_far *bwrite)(); |
| 220 | int (_far *bread)(); | 224 | int (_far *bread)(); |
| 221 | int (_far *bputs)(); | 225 | int (_far *bputs)(); |
| @@ -229,12 +233,8 @@ typedef struct bio_method_st | |||
| 229 | typedef struct bio_st | 233 | typedef struct bio_st |
| 230 | { | 234 | { |
| 231 | BIO_METHOD *method; | 235 | BIO_METHOD *method; |
| 232 | #ifndef NOPROTO | ||
| 233 | /* bio, mode, argp, argi, argl, ret */ | 236 | /* bio, mode, argp, argi, argl, ret */ |
| 234 | long (*callback)(struct bio_st *,int,char *,int, long,long); | 237 | long (*callback)(struct bio_st *,int,const char *,int, long,long); |
| 235 | #else | ||
| 236 | long (*callback)(); | ||
| 237 | #endif | ||
| 238 | char *cb_arg; /* first argument for the callback */ | 238 | char *cb_arg; /* first argument for the callback */ |
| 239 | 239 | ||
| 240 | int init; | 240 | int init; |
| @@ -242,7 +242,7 @@ typedef struct bio_st | |||
| 242 | int flags; /* extra storage */ | 242 | int flags; /* extra storage */ |
| 243 | int retry_reason; | 243 | int retry_reason; |
| 244 | int num; | 244 | int num; |
| 245 | char *ptr; | 245 | void *ptr; |
| 246 | struct bio_st *next_bio; /* used by filter BIOs */ | 246 | struct bio_st *next_bio; /* used by filter BIOs */ |
| 247 | struct bio_st *prev_bio; /* used by filter BIOs */ | 247 | struct bio_st *prev_bio; /* used by filter BIOs */ |
| 248 | int references; | 248 | int references; |
| @@ -276,7 +276,7 @@ typedef struct bio_f_buffer_ctx_struct | |||
| 276 | #define BIO_CONN_S_OK 6 | 276 | #define BIO_CONN_S_OK 6 |
| 277 | #define BIO_CONN_S_BLOCKED_CONNECT 7 | 277 | #define BIO_CONN_S_BLOCKED_CONNECT 7 |
| 278 | #define BIO_CONN_S_NBIO 8 | 278 | #define BIO_CONN_S_NBIO 8 |
| 279 | #define BIO_CONN_get_param_hostname BIO_ctrl | 279 | /*#define BIO_CONN_get_param_hostname BIO_ctrl */ |
| 280 | 280 | ||
| 281 | #define BIO_number_read(b) ((b)->num_read) | 281 | #define BIO_number_read(b) ((b)->num_read) |
| 282 | #define BIO_number_written(b) ((b)->num_write) | 282 | #define BIO_number_written(b) ((b)->num_write) |
| @@ -309,18 +309,28 @@ typedef struct bio_f_buffer_ctx_struct | |||
| 309 | #define BIO_C_SET_SSL_RENEGOTIATE_BYTES 125 | 309 | #define BIO_C_SET_SSL_RENEGOTIATE_BYTES 125 |
| 310 | #define BIO_C_GET_SSL_NUM_RENEGOTIATES 126 | 310 | #define BIO_C_GET_SSL_NUM_RENEGOTIATES 126 |
| 311 | #define BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT 127 | 311 | #define BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT 127 |
| 312 | #define BIO_C_FILE_SEEK 128 | ||
| 313 | #define BIO_C_GET_CIPHER_CTX 129 | ||
| 314 | #define BIO_C_SET_BUF_MEM_EOF_RETURN 130/*return end of input value*/ | ||
| 315 | #define BIO_C_SET_BIND_MODE 131 | ||
| 316 | #define BIO_C_GET_BIND_MODE 132 | ||
| 317 | #define BIO_C_FILE_TELL 133 | ||
| 318 | #define BIO_C_GET_SOCKS 134 | ||
| 319 | #define BIO_C_SET_SOCKS 135 | ||
| 320 | |||
| 321 | #define BIO_C_SET_WRITE_BUF_SIZE 136/* for BIO_s_bio */ | ||
| 322 | #define BIO_C_GET_WRITE_BUF_SIZE 137 | ||
| 323 | #define BIO_C_MAKE_BIO_PAIR 138 | ||
| 324 | #define BIO_C_DESTROY_BIO_PAIR 139 | ||
| 325 | #define BIO_C_GET_WRITE_GUARANTEE 140 | ||
| 326 | #define BIO_C_GET_READ_REQUEST 141 | ||
| 327 | #define BIO_C_SHUTDOWN_WR 142 | ||
| 328 | |||
| 312 | 329 | ||
| 313 | #define BIO_set_app_data(s,arg) BIO_set_ex_data(s,0,(char *)arg) | 330 | #define BIO_set_app_data(s,arg) BIO_set_ex_data(s,0,(char *)arg) |
| 314 | #define BIO_get_app_data(s) BIO_get_ex_data(s,0) | 331 | #define BIO_get_app_data(s) BIO_get_ex_data(s,0) |
| 315 | 332 | ||
| 316 | int BIO_get_ex_num(BIO *bio); | 333 | /* BIO_s_connect() and BIO_s_socks4a_connect() */ |
| 317 | int BIO_set_ex_data(BIO *bio,int idx,char *data); | ||
| 318 | char *BIO_get_ex_data(BIO *bio,int idx); | ||
| 319 | void BIO_set_ex_free_func(BIO *bio,int idx,void (*cb)()); | ||
| 320 | int BIO_get_ex_new_index(long argl, char *argp, int (*new_func)(), | ||
| 321 | int (*dup_func)(), void (*free_func)()); | ||
| 322 | |||
| 323 | /* BIO_s_connect_socket() */ | ||
| 324 | #define BIO_set_conn_hostname(b,name) BIO_ctrl(b,BIO_C_SET_CONNECT,0,(char *)name) | 334 | #define BIO_set_conn_hostname(b,name) BIO_ctrl(b,BIO_C_SET_CONNECT,0,(char *)name) |
| 325 | #define BIO_set_conn_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,1,(char *)port) | 335 | #define BIO_set_conn_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,1,(char *)port) |
| 326 | #define BIO_set_conn_ip(b,ip) BIO_ctrl(b,BIO_C_SET_CONNECT,2,(char *)ip) | 336 | #define BIO_set_conn_ip(b,ip) BIO_ctrl(b,BIO_C_SET_CONNECT,2,(char *)ip) |
| @@ -328,7 +338,8 @@ int BIO_get_ex_new_index(long argl, char *argp, int (*new_func)(), | |||
| 328 | #define BIO_get_conn_hostname(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0) | 338 | #define BIO_get_conn_hostname(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0) |
| 329 | #define BIO_get_conn_port(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1) | 339 | #define BIO_get_conn_port(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1) |
| 330 | #define BIO_get_conn_ip(b,ip) BIO_ptr_ctrl(b,BIO_C_SET_CONNECT,2) | 340 | #define BIO_get_conn_ip(b,ip) BIO_ptr_ctrl(b,BIO_C_SET_CONNECT,2) |
| 331 | #define BIO_get_conn_int port(b,port) BIO_int_ctrl(b,BIO_C_SET_CONNECT,3,port) | 341 | #define BIO_get_conn_int_port(b,port) BIO_int_ctrl(b,BIO_C_SET_CONNECT,3,port) |
| 342 | |||
| 332 | 343 | ||
| 333 | #define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) | 344 | #define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) |
| 334 | 345 | ||
| @@ -339,6 +350,12 @@ int BIO_get_ex_new_index(long argl, char *argp, int (*new_func)(), | |||
| 339 | #define BIO_set_nbio_accept(b,n) BIO_ctrl(b,BIO_C_SET_ACCEPT,1,(n)?"a":NULL) | 350 | #define BIO_set_nbio_accept(b,n) BIO_ctrl(b,BIO_C_SET_ACCEPT,1,(n)?"a":NULL) |
| 340 | #define BIO_set_accept_bios(b,bio) BIO_ctrl(b,BIO_C_SET_ACCEPT,2,(char *)bio) | 351 | #define BIO_set_accept_bios(b,bio) BIO_ctrl(b,BIO_C_SET_ACCEPT,2,(char *)bio) |
| 341 | 352 | ||
| 353 | #define BIO_BIND_NORMAL 0 | ||
| 354 | #define BIO_BIND_REUSEADDR_IF_UNUSED 1 | ||
| 355 | #define BIO_BIND_REUSEADDR 2 | ||
| 356 | #define BIO_set_bind_mode(b,mode) BIO_ctrl(b,BIO_C_SET_BIND_MODE,mode,NULL) | ||
| 357 | #define BIO_get_bind_mode(b,mode) BIO_ctrl(b,BIO_C_GET_BIND_MODE,0,NULL) | ||
| 358 | |||
| 342 | #define BIO_do_connect(b) BIO_do_handshake(b) | 359 | #define BIO_do_connect(b) BIO_do_handshake(b) |
| 343 | #define BIO_do_accept(b) BIO_do_handshake(b) | 360 | #define BIO_do_accept(b) BIO_do_handshake(b) |
| 344 | #define BIO_do_handshake(b) BIO_ctrl(b,BIO_C_DO_STATE_MACHINE,0,NULL) | 361 | #define BIO_do_handshake(b) BIO_ctrl(b,BIO_C_DO_STATE_MACHINE,0,NULL) |
| @@ -364,12 +381,26 @@ int BIO_get_ex_new_index(long argl, char *argp, int (*new_func)(), | |||
| 364 | #define BIO_set_fp(b,fp,c) BIO_ctrl(b,BIO_C_SET_FILE_PTR,c,(char *)fp) | 381 | #define BIO_set_fp(b,fp,c) BIO_ctrl(b,BIO_C_SET_FILE_PTR,c,(char *)fp) |
| 365 | #define BIO_get_fp(b,fpp) BIO_ctrl(b,BIO_C_GET_FILE_PTR,0,(char *)fpp) | 382 | #define BIO_get_fp(b,fpp) BIO_ctrl(b,BIO_C_GET_FILE_PTR,0,(char *)fpp) |
| 366 | 383 | ||
| 384 | #define BIO_seek(b,ofs) (int)BIO_ctrl(b,BIO_C_FILE_SEEK,ofs,NULL) | ||
| 385 | #define BIO_tell(b) (int)BIO_ctrl(b,BIO_C_FILE_TELL,0,NULL) | ||
| 386 | |||
| 387 | /* name is cast to lose const, but might be better to route through a function | ||
| 388 | so we can do it safely */ | ||
| 389 | #ifdef CONST_STRICT | ||
| 390 | /* If you are wondering why this isn't defined, its because CONST_STRICT is | ||
| 391 | * purely a compile-time kludge to allow const to be checked. | ||
| 392 | */ | ||
| 393 | int BIO_read_filename(BIO *b,const char *name); | ||
| 394 | #else | ||
| 367 | #define BIO_read_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \ | 395 | #define BIO_read_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \ |
| 368 | BIO_CLOSE|BIO_FP_READ,name) | 396 | BIO_CLOSE|BIO_FP_READ,(char *)name) |
| 397 | #endif | ||
| 369 | #define BIO_write_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \ | 398 | #define BIO_write_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \ |
| 370 | BIO_CLOSE|BIO_FP_WRITE,name) | 399 | BIO_CLOSE|BIO_FP_WRITE,name) |
| 371 | #define BIO_append_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \ | 400 | #define BIO_append_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \ |
| 372 | BIO_CLOSE|BIO_FP_APPEND,name) | 401 | BIO_CLOSE|BIO_FP_APPEND,name) |
| 402 | #define BIO_rw_filename(b,name) BIO_ctrl(b,BIO_C_SET_FILENAME, \ | ||
| 403 | BIO_CLOSE|BIO_FP_READ|BIO_FP_WRITE,name) | ||
| 373 | 404 | ||
| 374 | /* WARNING WARNING, this ups the reference count on the read bio of the | 405 | /* WARNING WARNING, this ups the reference count on the read bio of the |
| 375 | * SSL structure. This is because the ssl read BIO is now pointed to by | 406 | * SSL structure. This is because the ssl read BIO is now pointed to by |
| @@ -388,8 +419,11 @@ int BIO_get_ex_new_index(long argl, char *argp, int (*new_func)(), | |||
| 388 | /* defined in evp.h */ | 419 | /* defined in evp.h */ |
| 389 | /* #define BIO_set_md(b,md) BIO_ctrl(b,BIO_C_SET_MD,1,(char *)md) */ | 420 | /* #define BIO_set_md(b,md) BIO_ctrl(b,BIO_C_SET_MD,1,(char *)md) */ |
| 390 | 421 | ||
| 422 | #define BIO_get_mem_data(b,pp) BIO_ctrl(b,BIO_CTRL_INFO,0,(char *)pp) | ||
| 391 | #define BIO_set_mem_buf(b,bm,c) BIO_ctrl(b,BIO_C_SET_BUF_MEM,c,(char *)bm) | 423 | #define BIO_set_mem_buf(b,bm,c) BIO_ctrl(b,BIO_C_SET_BUF_MEM,c,(char *)bm) |
| 392 | #define BIO_get_mem_ptr(b,pp) BIO_ctrl(b,BIO_C_GET_BUF_MEM_PTR,0,(char *)pp) | 424 | #define BIO_get_mem_ptr(b,pp) BIO_ctrl(b,BIO_C_GET_BUF_MEM_PTR,0,(char *)pp) |
| 425 | #define BIO_set_mem_eof_return(b,v) \ | ||
| 426 | BIO_ctrl(b,BIO_C_SET_BUF_MEM_EOF_RETURN,v,NULL) | ||
| 393 | 427 | ||
| 394 | /* For the BIO_f_buffer() type */ | 428 | /* For the BIO_f_buffer() type */ |
| 395 | #define BIO_get_buffer_num_lines(b) BIO_ctrl(b,BIO_C_GET_BUFF_NUM_LINES,0,NULL) | 429 | #define BIO_get_buffer_num_lines(b) BIO_ctrl(b,BIO_C_GET_BUFF_NUM_LINES,0,NULL) |
| @@ -407,6 +441,9 @@ int BIO_get_ex_new_index(long argl, char *argp, int (*new_func)(), | |||
| 407 | #define BIO_get_close(b) (int)BIO_ctrl(b,BIO_CTRL_GET_CLOSE,0,NULL) | 441 | #define BIO_get_close(b) (int)BIO_ctrl(b,BIO_CTRL_GET_CLOSE,0,NULL) |
| 408 | #define BIO_pending(b) (int)BIO_ctrl(b,BIO_CTRL_PENDING,0,NULL) | 442 | #define BIO_pending(b) (int)BIO_ctrl(b,BIO_CTRL_PENDING,0,NULL) |
| 409 | #define BIO_wpending(b) (int)BIO_ctrl(b,BIO_CTRL_WPENDING,0,NULL) | 443 | #define BIO_wpending(b) (int)BIO_ctrl(b,BIO_CTRL_WPENDING,0,NULL) |
| 444 | /* ...pending macros have inappropriate return type */ | ||
| 445 | size_t BIO_ctrl_pending(BIO *b); | ||
| 446 | size_t BIO_ctrl_wpending(BIO *b); | ||
| 410 | #define BIO_flush(b) (int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL) | 447 | #define BIO_flush(b) (int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL) |
| 411 | #define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0,(char *)cbp) | 448 | #define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0,(char *)cbp) |
| 412 | #define BIO_set_info_callback(b,cb) (int)BIO_ctrl(b,BIO_CTRL_SET_CALLBACK,0,(char *)cb) | 449 | #define BIO_set_info_callback(b,cb) (int)BIO_ctrl(b,BIO_CTRL_SET_CALLBACK,0,(char *)cb) |
| @@ -414,11 +451,32 @@ int BIO_get_ex_new_index(long argl, char *argp, int (*new_func)(), | |||
| 414 | /* For the BIO_f_buffer() type */ | 451 | /* For the BIO_f_buffer() type */ |
| 415 | #define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL) | 452 | #define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL) |
| 416 | 453 | ||
| 454 | /* For BIO_s_bio() */ | ||
| 455 | #define BIO_set_write_buf_size(b,size) (int)BIO_ctrl(b,BIO_C_SET_WRITE_BUF_SIZE,size,NULL) | ||
| 456 | #define BIO_get_write_buf_size(b,size) (size_t)BIO_ctrl(b,BIO_C_GET_WRITE_BUF_SIZE,size,NULL) | ||
| 457 | #define BIO_make_bio_pair(b1,b2) (int)BIO_ctrl(b1,BIO_C_MAKE_BIO_PAIR,0,b2) | ||
| 458 | #define BIO_destroy_bio_pair(b) (int)BIO_ctrl(b,BIO_C_DESTROY_BIO_PAIR,0,NULL) | ||
| 459 | /* macros with inappropriate type -- but ...pending macros use int too: */ | ||
| 460 | #define BIO_get_write_guarantee(b) (int)BIO_ctrl(b,BIO_C_GET_WRITE_GUARANTEE,0,NULL) | ||
| 461 | #define BIO_get_read_request(b) (int)BIO_ctrl(b,BIO_C_GET_READ_REQUEST,0,NULL) | ||
| 462 | size_t BIO_ctrl_get_write_guarantee(BIO *b); | ||
| 463 | size_t BIO_ctrl_get_read_request(BIO *b); | ||
| 464 | |||
| 465 | |||
| 466 | |||
| 417 | #ifdef NO_STDIO | 467 | #ifdef NO_STDIO |
| 418 | #define NO_FP_API | 468 | #define NO_FP_API |
| 419 | #endif | 469 | #endif |
| 420 | 470 | ||
| 421 | #ifndef NOPROTO | 471 | |
| 472 | /* These two aren't currently implemented */ | ||
| 473 | /* int BIO_get_ex_num(BIO *bio); */ | ||
| 474 | /* void BIO_set_ex_free_func(BIO *bio,int idx,void (*cb)()); */ | ||
| 475 | int BIO_set_ex_data(BIO *bio,int idx,char *data); | ||
| 476 | char *BIO_get_ex_data(BIO *bio,int idx); | ||
| 477 | int BIO_get_ex_new_index(long argl, char *argp, int (*new_func)(), | ||
| 478 | int (*dup_func)(), void (*free_func)()); | ||
| 479 | |||
| 422 | # if defined(WIN16) && defined(_WINDLL) | 480 | # if defined(WIN16) && defined(_WINDLL) |
| 423 | BIO_METHOD *BIO_s_file_internal(void); | 481 | BIO_METHOD *BIO_s_file_internal(void); |
| 424 | BIO *BIO_new_file_internal(char *filename, char *mode); | 482 | BIO *BIO_new_file_internal(char *filename, char *mode); |
| @@ -428,39 +486,20 @@ BIO *BIO_new_fp_internal(FILE *stream, int close_flag); | |||
| 428 | # define BIO_new_fp BIO_new_fp_internal | 486 | # define BIO_new_fp BIO_new_fp_internal |
| 429 | # else /* FP_API */ | 487 | # else /* FP_API */ |
| 430 | BIO_METHOD *BIO_s_file(void ); | 488 | BIO_METHOD *BIO_s_file(void ); |
| 431 | BIO *BIO_new_file(char *filename, char *mode); | 489 | BIO *BIO_new_file(const char *filename, const char *mode); |
| 432 | BIO *BIO_new_fp(FILE *stream, int close_flag); | 490 | BIO *BIO_new_fp(FILE *stream, int close_flag); |
| 433 | # define BIO_s_file_internal BIO_s_file | 491 | # define BIO_s_file_internal BIO_s_file |
| 434 | # define BIO_new_file_internal BIO_new_file | 492 | # define BIO_new_file_internal BIO_new_file |
| 435 | # define BIO_new_fp_internal BIO_s_file | 493 | # define BIO_new_fp_internal BIO_s_file |
| 436 | # endif /* FP_API */ | 494 | # endif /* FP_API */ |
| 437 | #else | ||
| 438 | # if defined(WIN16) && defined(_WINDLL) | ||
| 439 | BIO_METHOD *BIO_s_file_internal(); | ||
| 440 | BIO *BIO_new_file_internal(); | ||
| 441 | BIO *BIO_new_fp_internal(); | ||
| 442 | # define BIO_s_file BIO_s_file_internal | ||
| 443 | # define BIO_new_file BIO_new_file_internal | ||
| 444 | # define BIO_new_fp BIO_new_fp_internal | ||
| 445 | # else /* FP_API */ | ||
| 446 | BIO_METHOD *BIO_s_file(); | ||
| 447 | BIO *BIO_new_file(); | ||
| 448 | BIO *BIO_new_fp(); | ||
| 449 | # define BIO_s_file_internal BIO_s_file | ||
| 450 | # define BIO_new_file_internal BIO_new_file | ||
| 451 | # define BIO_new_fp_internal BIO_s_file | ||
| 452 | # endif /* FP_API */ | ||
| 453 | #endif | ||
| 454 | |||
| 455 | #ifndef NOPROTO | ||
| 456 | BIO * BIO_new(BIO_METHOD *type); | 495 | BIO * BIO_new(BIO_METHOD *type); |
| 457 | int BIO_set(BIO *a,BIO_METHOD *type); | 496 | int BIO_set(BIO *a,BIO_METHOD *type); |
| 458 | int BIO_free(BIO *a); | 497 | int BIO_free(BIO *a); |
| 459 | int BIO_read(BIO *b, char *data, int len); | 498 | int BIO_read(BIO *b, void *data, int len); |
| 460 | int BIO_gets(BIO *bp,char *buf, int size); | 499 | int BIO_gets(BIO *bp,char *buf, int size); |
| 461 | int BIO_write(BIO *b, char *data, int len); | 500 | int BIO_write(BIO *b, const char *data, int len); |
| 462 | int BIO_puts(BIO *bp,char *buf); | 501 | int BIO_puts(BIO *bp,const char *buf); |
| 463 | long BIO_ctrl(BIO *bp,int cmd,long larg,char *parg); | 502 | long BIO_ctrl(BIO *bp,int cmd,long larg,void *parg); |
| 464 | char * BIO_ptr_ctrl(BIO *bp,int cmd,long larg); | 503 | char * BIO_ptr_ctrl(BIO *bp,int cmd,long larg); |
| 465 | long BIO_int_ctrl(BIO *bp,int cmd,long larg,int iarg); | 504 | long BIO_int_ctrl(BIO *bp,int cmd,long larg,int iarg); |
| 466 | BIO * BIO_push(BIO *b,BIO *append); | 505 | BIO * BIO_push(BIO *b,BIO *append); |
| @@ -472,10 +511,10 @@ int BIO_get_retry_reason(BIO *bio); | |||
| 472 | BIO * BIO_dup_chain(BIO *in); | 511 | BIO * BIO_dup_chain(BIO *in); |
| 473 | 512 | ||
| 474 | #ifndef WIN16 | 513 | #ifndef WIN16 |
| 475 | long BIO_debug_callback(BIO *bio,int cmd,char *argp,int argi, | 514 | long BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi, |
| 476 | long argl,long ret); | 515 | long argl,long ret); |
| 477 | #else | 516 | #else |
| 478 | long _far _loadds BIO_debug_callback(BIO *bio,int cmd,char *argp,int argi, | 517 | long _far _loadds BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi, |
| 479 | long argl,long ret); | 518 | long argl,long ret); |
| 480 | #endif | 519 | #endif |
| 481 | 520 | ||
| @@ -484,23 +523,35 @@ BIO_METHOD *BIO_s_socket(void); | |||
| 484 | BIO_METHOD *BIO_s_connect(void); | 523 | BIO_METHOD *BIO_s_connect(void); |
| 485 | BIO_METHOD *BIO_s_accept(void); | 524 | BIO_METHOD *BIO_s_accept(void); |
| 486 | BIO_METHOD *BIO_s_fd(void); | 525 | BIO_METHOD *BIO_s_fd(void); |
| 526 | BIO_METHOD *BIO_s_log(void); | ||
| 527 | BIO_METHOD *BIO_s_bio(void); | ||
| 487 | BIO_METHOD *BIO_s_null(void); | 528 | BIO_METHOD *BIO_s_null(void); |
| 488 | BIO_METHOD *BIO_f_null(void); | 529 | BIO_METHOD *BIO_f_null(void); |
| 489 | BIO_METHOD *BIO_f_nbio_test(void); | ||
| 490 | BIO_METHOD *BIO_f_buffer(void); | 530 | BIO_METHOD *BIO_f_buffer(void); |
| 531 | BIO_METHOD *BIO_f_nbio_test(void); | ||
| 532 | /* BIO_METHOD *BIO_f_ber(void); */ | ||
| 491 | 533 | ||
| 492 | int BIO_sock_should_retry(int i); | 534 | int BIO_sock_should_retry(int i); |
| 493 | int BIO_sock_non_fatal_error(int error); | 535 | int BIO_sock_non_fatal_error(int error); |
| 494 | int BIO_fd_should_retry(int i); | 536 | int BIO_fd_should_retry(int i); |
| 495 | int BIO_fd_non_fatal_error(int error); | 537 | int BIO_fd_non_fatal_error(int error); |
| 496 | int BIO_dump(BIO *b,char *bytes,int len); | 538 | int BIO_dump(BIO *b,const char *bytes,int len); |
| 497 | 539 | ||
| 498 | struct hostent *BIO_gethostbyname(char *name); | 540 | struct hostent *BIO_gethostbyname(const char *name); |
| 541 | /* We might want a thread-safe interface too: | ||
| 542 | * struct hostent *BIO_gethostbyname_r(const char *name, | ||
| 543 | * struct hostent *result, void *buffer, size_t buflen); | ||
| 544 | * or something similar (caller allocates a struct hostent, | ||
| 545 | * pointed to by "result", and additional buffer space for the various | ||
| 546 | * substructures; if the buffer does not suffice, NULL is returned | ||
| 547 | * and an appropriate error code is set). | ||
| 548 | */ | ||
| 499 | int BIO_sock_error(int sock); | 549 | int BIO_sock_error(int sock); |
| 500 | int BIO_socket_ioctl(int fd, long type, unsigned long *arg); | 550 | int BIO_socket_ioctl(int fd, long type, unsigned long *arg); |
| 501 | int BIO_get_port(char *str, short *port_ptr); | 551 | int BIO_socket_nbio(int fd,int mode); |
| 502 | int BIO_get_host_ip(char *str, unsigned char *ip); | 552 | int BIO_get_port(const char *str, unsigned short *port_ptr); |
| 503 | int BIO_get_accept_socket(char *host_port); | 553 | int BIO_get_host_ip(const char *str, unsigned char *ip); |
| 554 | int BIO_get_accept_socket(char *host_port,int mode); | ||
| 504 | int BIO_accept(int sock,char **ip_port); | 555 | int BIO_accept(int sock,char **ip_port); |
| 505 | int BIO_sock_init(void ); | 556 | int BIO_sock_init(void ); |
| 506 | void BIO_sock_cleanup(void); | 557 | void BIO_sock_cleanup(void); |
| @@ -513,174 +564,78 @@ BIO *BIO_new_fd(int fd, int close_flag); | |||
| 513 | BIO *BIO_new_connect(char *host_port); | 564 | BIO *BIO_new_connect(char *host_port); |
| 514 | BIO *BIO_new_accept(char *host_port); | 565 | BIO *BIO_new_accept(char *host_port); |
| 515 | 566 | ||
| 567 | int BIO_new_bio_pair(BIO **bio1, size_t writebuf1, | ||
| 568 | BIO **bio2, size_t writebuf2); | ||
| 569 | /* If successful, returns 1 and in *bio1, *bio2 two BIO pair endpoints. | ||
| 570 | * Otherwise returns 0 and sets *bio1 and *bio2 to NULL. | ||
| 571 | * Size 0 uses default value. | ||
| 572 | */ | ||
| 573 | |||
| 516 | void BIO_copy_next_retry(BIO *b); | 574 | void BIO_copy_next_retry(BIO *b); |
| 517 | 575 | ||
| 518 | long BIO_ghbn_ctrl(int cmd,int iarg,char *parg); | 576 | long BIO_ghbn_ctrl(int cmd,int iarg,char *parg); |
| 519 | 577 | ||
| 520 | #else | 578 | int BIO_printf(BIO *bio, ...); |
| 521 | |||
| 522 | BIO * BIO_new(); | ||
| 523 | int BIO_set(); | ||
| 524 | int BIO_free(); | ||
| 525 | int BIO_read(); | ||
| 526 | int BIO_gets(); | ||
| 527 | int BIO_write(); | ||
| 528 | int BIO_puts(); | ||
| 529 | char * BIO_ptr_ctrl(); | ||
| 530 | long BIO_ctrl(); | ||
| 531 | long BIO_int_ctrl(); | ||
| 532 | BIO * BIO_push(); | ||
| 533 | BIO * BIO_pop(); | ||
| 534 | void BIO_free_all(); | ||
| 535 | BIO * BIO_find_type(); | ||
| 536 | BIO * BIO_get_retry_BIO(); | ||
| 537 | int BIO_get_retry_reason(); | ||
| 538 | BIO * BIO_dup_chain(); | ||
| 539 | |||
| 540 | #ifndef WIN16 | ||
| 541 | long BIO_debug_callback(); | ||
| 542 | #else | ||
| 543 | long _far _loadds BIO_debug_callback(); | ||
| 544 | #endif | ||
| 545 | |||
| 546 | BIO_METHOD *BIO_s_mem(); | ||
| 547 | BIO_METHOD *BIO_s_socket(); | ||
| 548 | BIO_METHOD *BIO_s_connect(); | ||
| 549 | BIO_METHOD *BIO_s_accept(); | ||
| 550 | BIO_METHOD *BIO_s_fd(); | ||
| 551 | BIO_METHOD *BIO_s_null(); | ||
| 552 | BIO_METHOD *BIO_f_null(); | ||
| 553 | BIO_METHOD *BIO_f_buffer(); | ||
| 554 | BIO_METHOD *BIO_f_nbio_test(); | ||
| 555 | |||
| 556 | int BIO_sock_should_retry(); | ||
| 557 | int BIO_sock_non_fatal_error(); | ||
| 558 | int BIO_fd_should_retry(); | ||
| 559 | int BIO_fd_non_fatal_error(); | ||
| 560 | int BIO_dump(); | ||
| 561 | |||
| 562 | struct hostent *BIO_gethostbyname(); | ||
| 563 | int BIO_sock_error(); | ||
| 564 | int BIO_socket_ioctl(); | ||
| 565 | int BIO_get_port(); | ||
| 566 | int BIO_get_host_ip(); | ||
| 567 | int BIO_get_accept_socket(); | ||
| 568 | int BIO_accept(); | ||
| 569 | int BIO_sock_init(); | ||
| 570 | void BIO_sock_cleanup(); | ||
| 571 | int BIO_set_tcp_ndelay(); | ||
| 572 | |||
| 573 | void ERR_load_BIO_strings(); | ||
| 574 | |||
| 575 | BIO *BIO_new_socket(); | ||
| 576 | BIO *BIO_new_fd(); | ||
| 577 | BIO *BIO_new_connect(); | ||
| 578 | BIO *BIO_new_accept(); | ||
| 579 | |||
| 580 | void BIO_copy_next_retry(); | ||
| 581 | |||
| 582 | int BIO_ghbn_ctrl(); | ||
| 583 | |||
| 584 | #endif | ||
| 585 | |||
| 586 | /* Tim Hudson's portable varargs stuff */ | ||
| 587 | |||
| 588 | #ifndef NOPROTO | ||
| 589 | #define VAR_ANSI /* select ANSI version by default */ | ||
| 590 | #endif | ||
| 591 | |||
| 592 | #ifdef VAR_ANSI | ||
| 593 | /* ANSI version of a "portable" macro set for variable length args */ | ||
| 594 | #ifndef __STDARG_H__ /**/ | ||
| 595 | #include <stdarg.h> | ||
| 596 | #endif /**/ | ||
| 597 | |||
| 598 | #define VAR_PLIST(arg1type,arg1) arg1type arg1, ... | ||
| 599 | #define VAR_PLIST2(arg1type,arg1,arg2type,arg2) arg1type arg1,arg2type arg2,... | ||
| 600 | #define VAR_ALIST | ||
| 601 | #define VAR_BDEFN(args,arg1type,arg1) va_list args | ||
| 602 | #define VAR_BDEFN2(args,arg1type,arg1,arg2type,arg2) va_list args | ||
| 603 | #define VAR_INIT(args,arg1type,arg1) va_start(args,arg1); | ||
| 604 | #define VAR_INIT2(args,arg1type,arg1,arg2type,arg2) va_start(args,arg2); | ||
| 605 | #define VAR_ARG(args,type,arg) arg=va_arg(args,type) | ||
| 606 | #define VAR_END(args) va_end(args); | ||
| 607 | |||
| 608 | #else | ||
| 609 | |||
| 610 | /* K&R version of a "portable" macro set for variable length args */ | ||
| 611 | #ifndef __VARARGS_H__ | ||
| 612 | #include <varargs.h> | ||
| 613 | #endif | ||
| 614 | |||
| 615 | #define VAR_PLIST(arg1type,arg1) va_alist | ||
| 616 | #define VAR_PLIST2(arg1type,arg1,arg2type,arg2) va_alist | ||
| 617 | #define VAR_ALIST va_dcl | ||
| 618 | #define VAR_BDEFN(args,arg1type,arg1) va_list args; arg1type arg1 | ||
| 619 | #define VAR_BDEFN2(args,arg1type,arg1,arg2type,arg2) va_list args; \ | ||
| 620 | arg1type arg1; arg2type arg2 | ||
| 621 | #define VAR_INIT(args,arg1type,arg1) va_start(args); \ | ||
| 622 | arg1=va_arg(args,arg1type); | ||
| 623 | #define VAR_INIT2(args,arg1type,arg1,arg2type,arg2) va_start(args); \ | ||
| 624 | arg1=va_arg(args,arg1type); arg2=va_arg(args,arg2type); | ||
| 625 | #define VAR_ARG(args,type,arg) arg=va_arg(args,type) | ||
| 626 | #define VAR_END(args) va_end(args); | ||
| 627 | |||
| 628 | #endif | ||
| 629 | |||
| 630 | #ifndef NOPROTO | ||
| 631 | int BIO_printf( VAR_PLIST( BIO *, bio ) ); | ||
| 632 | #else | ||
| 633 | int BIO_printf(); | ||
| 634 | #endif | ||
| 635 | 579 | ||
| 636 | /* BEGIN ERROR CODES */ | 580 | /* BEGIN ERROR CODES */ |
| 581 | /* The following lines are auto generated by the script mkerr.pl. Any changes | ||
| 582 | * made after this point may be overwritten when the script is next run. | ||
| 583 | */ | ||
| 584 | |||
| 637 | /* Error codes for the BIO functions. */ | 585 | /* Error codes for the BIO functions. */ |
| 638 | 586 | ||
| 639 | /* Function codes. */ | 587 | /* Function codes. */ |
| 640 | #define BIO_F_ACPT_STATE 100 | 588 | #define BIO_F_ACPT_STATE 100 |
| 641 | #define BIO_F_BIO_ACCEPT 101 | 589 | #define BIO_F_BIO_ACCEPT 101 |
| 642 | #define BIO_F_BIO_CTRL 102 | 590 | #define BIO_F_BIO_BER_GET_HEADER 102 |
| 643 | #define BIO_F_BIO_GETS 103 | 591 | #define BIO_F_BIO_CTRL 103 |
| 644 | #define BIO_F_BIO_GET_ACCEPT_SOCKET 104 | 592 | #define BIO_F_BIO_GETHOSTBYNAME 120 |
| 645 | #define BIO_F_BIO_GET_HOST_IP 105 | 593 | #define BIO_F_BIO_GETS 104 |
| 646 | #define BIO_F_BIO_GET_PORT 106 | 594 | #define BIO_F_BIO_GET_ACCEPT_SOCKET 105 |
| 647 | #define BIO_F_BIO_NEW 107 | 595 | #define BIO_F_BIO_GET_HOST_IP 106 |
| 648 | #define BIO_F_BIO_NEW_FILE 108 | 596 | #define BIO_F_BIO_GET_PORT 107 |
| 649 | #define BIO_F_BIO_PUTS 109 | 597 | #define BIO_F_BIO_MAKE_PAIR 121 |
| 650 | #define BIO_F_BIO_READ 110 | 598 | #define BIO_F_BIO_NEW 108 |
| 651 | #define BIO_F_BIO_SOCK_INIT 111 | 599 | #define BIO_F_BIO_NEW_FILE 109 |
| 652 | #define BIO_F_BIO_WRITE 112 | 600 | #define BIO_F_BIO_PUTS 110 |
| 653 | #define BIO_F_BUFFER_CTRL 113 | 601 | #define BIO_F_BIO_READ 111 |
| 654 | #define BIO_F_CONN_STATE 114 | 602 | #define BIO_F_BIO_SOCK_INIT 112 |
| 655 | #define BIO_F_FILE_CTRL 115 | 603 | #define BIO_F_BIO_WRITE 113 |
| 656 | #define BIO_F_MEM_WRITE 116 | 604 | #define BIO_F_BUFFER_CTRL 114 |
| 657 | #define BIO_F_SSL_NEW 117 | 605 | #define BIO_F_CONN_STATE 115 |
| 658 | #define BIO_F_WSASTARTUP 118 | 606 | #define BIO_F_FILE_CTRL 116 |
| 607 | #define BIO_F_MEM_WRITE 117 | ||
| 608 | #define BIO_F_SSL_NEW 118 | ||
| 609 | #define BIO_F_WSASTARTUP 119 | ||
| 659 | 610 | ||
| 660 | /* Reason codes. */ | 611 | /* Reason codes. */ |
| 661 | #define BIO_R_ACCEPT_ERROR 100 | 612 | #define BIO_R_ACCEPT_ERROR 100 |
| 662 | #define BIO_R_BAD_FOPEN_MODE 101 | 613 | #define BIO_R_BAD_FOPEN_MODE 101 |
| 663 | #define BIO_R_BAD_HOSTNAME_LOOKUP 102 | 614 | #define BIO_R_BAD_HOSTNAME_LOOKUP 102 |
| 615 | #define BIO_R_BROKEN_PIPE 124 | ||
| 664 | #define BIO_R_CONNECT_ERROR 103 | 616 | #define BIO_R_CONNECT_ERROR 103 |
| 665 | #define BIO_R_ERROR_SETTING_NBIO 104 | 617 | #define BIO_R_ERROR_SETTING_NBIO 104 |
| 666 | #define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET 105 | 618 | #define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET 105 |
| 667 | #define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET 106 | 619 | #define BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET 106 |
| 668 | #define BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET 107 | 620 | #define BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET 107 |
| 621 | #define BIO_R_INVALID_ARGUMENT 125 | ||
| 669 | #define BIO_R_INVALID_IP_ADDRESS 108 | 622 | #define BIO_R_INVALID_IP_ADDRESS 108 |
| 623 | #define BIO_R_IN_USE 123 | ||
| 670 | #define BIO_R_KEEPALIVE 109 | 624 | #define BIO_R_KEEPALIVE 109 |
| 671 | #define BIO_R_NBIO_CONNECT_ERROR 110 | 625 | #define BIO_R_NBIO_CONNECT_ERROR 110 |
| 672 | #define BIO_R_NO_ACCEPT_PORT_SPECIFIED 111 | 626 | #define BIO_R_NO_ACCEPT_PORT_SPECIFIED 111 |
| 673 | #define BIO_R_NO_HOSTHNAME_SPECIFIED 112 | 627 | #define BIO_R_NO_HOSTNAME_SPECIFIED 112 |
| 674 | #define BIO_R_NO_PORT_DEFINED 113 | 628 | #define BIO_R_NO_PORT_DEFINED 113 |
| 675 | #define BIO_R_NO_PORT_SPECIFIED 114 | 629 | #define BIO_R_NO_PORT_SPECIFIED 114 |
| 676 | #define BIO_R_NULL_PARAMETER 115 | 630 | #define BIO_R_NULL_PARAMETER 115 |
| 677 | #define BIO_R_UNABLE_TO_BIND_SOCKET 116 | 631 | #define BIO_R_TAG_MISMATCH 116 |
| 678 | #define BIO_R_UNABLE_TO_CREATE_SOCKET 117 | 632 | #define BIO_R_UNABLE_TO_BIND_SOCKET 117 |
| 679 | #define BIO_R_UNABLE_TO_LISTEN_SOCKET 118 | 633 | #define BIO_R_UNABLE_TO_CREATE_SOCKET 118 |
| 680 | #define BIO_R_UNINITALISED 119 | 634 | #define BIO_R_UNABLE_TO_LISTEN_SOCKET 119 |
| 681 | #define BIO_R_UNSUPPORTED_METHOD 120 | 635 | #define BIO_R_UNINITIALIZED 120 |
| 682 | #define BIO_R_WSASTARTUP 121 | 636 | #define BIO_R_UNSUPPORTED_METHOD 121 |
| 683 | 637 | #define BIO_R_WSASTARTUP 122 | |
| 638 | |||
| 684 | #ifdef __cplusplus | 639 | #ifdef __cplusplus |
| 685 | } | 640 | } |
| 686 | #endif | 641 | #endif |
diff --git a/src/lib/libcrypto/bio/bio_cb.c b/src/lib/libcrypto/bio/bio_cb.c index bc6ed9eda1..37c7c22666 100644 --- a/src/lib/libcrypto/bio/bio_cb.c +++ b/src/lib/libcrypto/bio/bio_cb.c | |||
| @@ -60,16 +60,11 @@ | |||
| 60 | #include <string.h> | 60 | #include <string.h> |
| 61 | #include <stdlib.h> | 61 | #include <stdlib.h> |
| 62 | #include "cryptlib.h" | 62 | #include "cryptlib.h" |
| 63 | #include "bio.h" | 63 | #include <openssl/bio.h> |
| 64 | #include "err.h" | 64 | #include <openssl/err.h> |
| 65 | 65 | ||
| 66 | long MS_CALLBACK BIO_debug_callback(bio,cmd,argp,argi,argl,ret) | 66 | long MS_CALLBACK BIO_debug_callback(BIO *bio, int cmd, const char *argp, |
| 67 | BIO *bio; | 67 | int argi, long argl, long ret) |
| 68 | int cmd; | ||
| 69 | char *argp; | ||
| 70 | int argi; | ||
| 71 | long argl; | ||
| 72 | long ret; | ||
| 73 | { | 68 | { |
| 74 | BIO *b; | 69 | BIO *b; |
| 75 | MS_STATIC char buf[256]; | 70 | MS_STATIC char buf[256]; |
diff --git a/src/lib/libcrypto/bio/bio_err.c b/src/lib/libcrypto/bio/bio_err.c index 37e14ca107..712d98a3a1 100644 --- a/src/lib/libcrypto/bio/bio_err.c +++ b/src/lib/libcrypto/bio/bio_err.c | |||
| @@ -1,63 +1,65 @@ | |||
| 1 | /* lib/bio/bio_err.c */ | 1 | /* crypto/bio/bio_err.c */ |
| 2 | /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) | 2 | /* ==================================================================== |
| 3 | * All rights reserved. | 3 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. |
| 4 | * | 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 | 5 | * Redistribution and use in source and binary forms, with or without |
| 24 | * modification, are permitted provided that the following conditions | 6 | * modification, are permitted provided that the following conditions |
| 25 | * are met: | 7 | * are met: |
| 26 | * 1. Redistributions of source code must retain the copyright | 8 | * |
| 27 | * notice, this list of conditions and the following disclaimer. | 9 | * 1. Redistributions of source code must retain the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer. | ||
| 11 | * | ||
| 28 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
| 29 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in |
| 30 | * documentation and/or other materials provided with the distribution. | 14 | * the documentation and/or other materials provided with the |
| 31 | * 3. All advertising materials mentioning features or use of this software | 15 | * distribution. |
| 32 | * must display the following acknowledgement: | 16 | * |
| 33 | * "This product includes cryptographic software written by | 17 | * 3. All advertising materials mentioning features or use of this |
| 34 | * Eric Young (eay@cryptsoft.com)" | 18 | * software must display the following acknowledgment: |
| 35 | * The word 'cryptographic' can be left out if the rouines from the library | 19 | * "This product includes software developed by the OpenSSL Project |
| 36 | * being used are not cryptographic related :-). | 20 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" |
| 37 | * 4. If you include any Windows specific code (or a derivative thereof) from | 21 | * |
| 38 | * the apps directory (application code) you must include an acknowledgement: | 22 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to |
| 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | 23 | * endorse or promote products derived from this software without |
| 40 | * | 24 | * prior written permission. For written permission, please contact |
| 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | 25 | * openssl-core@OpenSSL.org. |
| 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 26 | * |
| 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 27 | * 5. Products derived from this software may not be called "OpenSSL" |
| 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | 28 | * nor may "OpenSSL" appear in their names without prior written |
| 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 29 | * permission of the OpenSSL Project. |
| 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 30 | * |
| 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 31 | * 6. Redistributions of any form whatsoever must retain the following |
| 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 32 | * acknowledgment: |
| 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 33 | * "This product includes software developed by the OpenSSL Project |
| 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 34 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" |
| 51 | * SUCH DAMAGE. | 35 | * |
| 52 | * | 36 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY |
| 53 | * The licence and distribution terms for any publically available version or | 37 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | 38 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 55 | * copied and put under another distribution licence | 39 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR |
| 56 | * [including the GNU Public Licence.] | 40 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 41 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 42 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 43 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 44 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 45 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 46 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 47 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 48 | * ==================================================================== | ||
| 49 | * | ||
| 50 | * This product includes cryptographic software written by Eric Young | ||
| 51 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 52 | * Hudson (tjh@cryptsoft.com). | ||
| 53 | * | ||
| 57 | */ | 54 | */ |
| 55 | |||
| 56 | /* NOTE: this file was auto generated by the mkerr.pl script: any changes | ||
| 57 | * made to it will be overwritten when the script next updates this file. | ||
| 58 | */ | ||
| 59 | |||
| 58 | #include <stdio.h> | 60 | #include <stdio.h> |
| 59 | #include "err.h" | 61 | #include <openssl/err.h> |
| 60 | #include "bio.h" | 62 | #include <openssl/bio.h> |
| 61 | 63 | ||
| 62 | /* BEGIN ERROR CODES */ | 64 | /* BEGIN ERROR CODES */ |
| 63 | #ifndef NO_ERR | 65 | #ifndef NO_ERR |
| @@ -65,11 +67,14 @@ static ERR_STRING_DATA BIO_str_functs[]= | |||
| 65 | { | 67 | { |
| 66 | {ERR_PACK(0,BIO_F_ACPT_STATE,0), "ACPT_STATE"}, | 68 | {ERR_PACK(0,BIO_F_ACPT_STATE,0), "ACPT_STATE"}, |
| 67 | {ERR_PACK(0,BIO_F_BIO_ACCEPT,0), "BIO_accept"}, | 69 | {ERR_PACK(0,BIO_F_BIO_ACCEPT,0), "BIO_accept"}, |
| 70 | {ERR_PACK(0,BIO_F_BIO_BER_GET_HEADER,0), "BIO_BER_GET_HEADER"}, | ||
| 68 | {ERR_PACK(0,BIO_F_BIO_CTRL,0), "BIO_ctrl"}, | 71 | {ERR_PACK(0,BIO_F_BIO_CTRL,0), "BIO_ctrl"}, |
| 72 | {ERR_PACK(0,BIO_F_BIO_GETHOSTBYNAME,0), "BIO_gethostbyname"}, | ||
| 69 | {ERR_PACK(0,BIO_F_BIO_GETS,0), "BIO_gets"}, | 73 | {ERR_PACK(0,BIO_F_BIO_GETS,0), "BIO_gets"}, |
| 70 | {ERR_PACK(0,BIO_F_BIO_GET_ACCEPT_SOCKET,0), "BIO_get_accept_socket"}, | 74 | {ERR_PACK(0,BIO_F_BIO_GET_ACCEPT_SOCKET,0), "BIO_get_accept_socket"}, |
| 71 | {ERR_PACK(0,BIO_F_BIO_GET_HOST_IP,0), "BIO_get_host_ip"}, | 75 | {ERR_PACK(0,BIO_F_BIO_GET_HOST_IP,0), "BIO_get_host_ip"}, |
| 72 | {ERR_PACK(0,BIO_F_BIO_GET_PORT,0), "BIO_get_port"}, | 76 | {ERR_PACK(0,BIO_F_BIO_GET_PORT,0), "BIO_get_port"}, |
| 77 | {ERR_PACK(0,BIO_F_BIO_MAKE_PAIR,0), "BIO_MAKE_PAIR"}, | ||
| 73 | {ERR_PACK(0,BIO_F_BIO_NEW,0), "BIO_new"}, | 78 | {ERR_PACK(0,BIO_F_BIO_NEW,0), "BIO_new"}, |
| 74 | {ERR_PACK(0,BIO_F_BIO_NEW_FILE,0), "BIO_new_file"}, | 79 | {ERR_PACK(0,BIO_F_BIO_NEW_FILE,0), "BIO_new_file"}, |
| 75 | {ERR_PACK(0,BIO_F_BIO_PUTS,0), "BIO_puts"}, | 80 | {ERR_PACK(0,BIO_F_BIO_PUTS,0), "BIO_puts"}, |
| @@ -80,9 +85,9 @@ static ERR_STRING_DATA BIO_str_functs[]= | |||
| 80 | {ERR_PACK(0,BIO_F_CONN_STATE,0), "CONN_STATE"}, | 85 | {ERR_PACK(0,BIO_F_CONN_STATE,0), "CONN_STATE"}, |
| 81 | {ERR_PACK(0,BIO_F_FILE_CTRL,0), "FILE_CTRL"}, | 86 | {ERR_PACK(0,BIO_F_FILE_CTRL,0), "FILE_CTRL"}, |
| 82 | {ERR_PACK(0,BIO_F_MEM_WRITE,0), "MEM_WRITE"}, | 87 | {ERR_PACK(0,BIO_F_MEM_WRITE,0), "MEM_WRITE"}, |
| 83 | {ERR_PACK(0,BIO_F_SSL_NEW,0), "SSL_NEW"}, | 88 | {ERR_PACK(0,BIO_F_SSL_NEW,0), "SSL_new"}, |
| 84 | {ERR_PACK(0,BIO_F_WSASTARTUP,0), "WSASTARTUP"}, | 89 | {ERR_PACK(0,BIO_F_WSASTARTUP,0), "WSASTARTUP"}, |
| 85 | {0,NULL}, | 90 | {0,NULL} |
| 86 | }; | 91 | }; |
| 87 | 92 | ||
| 88 | static ERR_STRING_DATA BIO_str_reasons[]= | 93 | static ERR_STRING_DATA BIO_str_reasons[]= |
| @@ -90,36 +95,40 @@ static ERR_STRING_DATA BIO_str_reasons[]= | |||
| 90 | {BIO_R_ACCEPT_ERROR ,"accept error"}, | 95 | {BIO_R_ACCEPT_ERROR ,"accept error"}, |
| 91 | {BIO_R_BAD_FOPEN_MODE ,"bad fopen mode"}, | 96 | {BIO_R_BAD_FOPEN_MODE ,"bad fopen mode"}, |
| 92 | {BIO_R_BAD_HOSTNAME_LOOKUP ,"bad hostname lookup"}, | 97 | {BIO_R_BAD_HOSTNAME_LOOKUP ,"bad hostname lookup"}, |
| 98 | {BIO_R_BROKEN_PIPE ,"broken pipe"}, | ||
| 93 | {BIO_R_CONNECT_ERROR ,"connect error"}, | 99 | {BIO_R_CONNECT_ERROR ,"connect error"}, |
| 94 | {BIO_R_ERROR_SETTING_NBIO ,"error setting nbio"}, | 100 | {BIO_R_ERROR_SETTING_NBIO ,"error setting nbio"}, |
| 95 | {BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET,"error setting nbio on accepted socket"}, | 101 | {BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET,"error setting nbio on accepted socket"}, |
| 96 | {BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET,"error setting nbio on accept socket"}, | 102 | {BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET,"error setting nbio on accept socket"}, |
| 97 | {BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET ,"gethostbyname addr is not af inet"}, | 103 | {BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET ,"gethostbyname addr is not af inet"}, |
| 104 | {BIO_R_INVALID_ARGUMENT ,"invalid argument"}, | ||
| 98 | {BIO_R_INVALID_IP_ADDRESS ,"invalid ip address"}, | 105 | {BIO_R_INVALID_IP_ADDRESS ,"invalid ip address"}, |
| 106 | {BIO_R_IN_USE ,"in use"}, | ||
| 99 | {BIO_R_KEEPALIVE ,"keepalive"}, | 107 | {BIO_R_KEEPALIVE ,"keepalive"}, |
| 100 | {BIO_R_NBIO_CONNECT_ERROR ,"nbio connect error"}, | 108 | {BIO_R_NBIO_CONNECT_ERROR ,"nbio connect error"}, |
| 101 | {BIO_R_NO_ACCEPT_PORT_SPECIFIED ,"no accept port specified"}, | 109 | {BIO_R_NO_ACCEPT_PORT_SPECIFIED ,"no accept port specified"}, |
| 102 | {BIO_R_NO_HOSTHNAME_SPECIFIED ,"no hosthname specified"}, | 110 | {BIO_R_NO_HOSTNAME_SPECIFIED ,"no hostname specified"}, |
| 103 | {BIO_R_NO_PORT_DEFINED ,"no port defined"}, | 111 | {BIO_R_NO_PORT_DEFINED ,"no port defined"}, |
| 104 | {BIO_R_NO_PORT_SPECIFIED ,"no port specified"}, | 112 | {BIO_R_NO_PORT_SPECIFIED ,"no port specified"}, |
| 105 | {BIO_R_NULL_PARAMETER ,"null parameter"}, | 113 | {BIO_R_NULL_PARAMETER ,"null parameter"}, |
| 114 | {BIO_R_TAG_MISMATCH ,"tag mismatch"}, | ||
| 106 | {BIO_R_UNABLE_TO_BIND_SOCKET ,"unable to bind socket"}, | 115 | {BIO_R_UNABLE_TO_BIND_SOCKET ,"unable to bind socket"}, |
| 107 | {BIO_R_UNABLE_TO_CREATE_SOCKET ,"unable to create socket"}, | 116 | {BIO_R_UNABLE_TO_CREATE_SOCKET ,"unable to create socket"}, |
| 108 | {BIO_R_UNABLE_TO_LISTEN_SOCKET ,"unable to listen socket"}, | 117 | {BIO_R_UNABLE_TO_LISTEN_SOCKET ,"unable to listen socket"}, |
| 109 | {BIO_R_UNINITALISED ,"uninitalised"}, | 118 | {BIO_R_UNINITIALIZED ,"uninitialized"}, |
| 110 | {BIO_R_UNSUPPORTED_METHOD ,"unsupported method"}, | 119 | {BIO_R_UNSUPPORTED_METHOD ,"unsupported method"}, |
| 111 | {BIO_R_WSASTARTUP ,"wsastartup"}, | 120 | {BIO_R_WSASTARTUP ,"wsastartup"}, |
| 112 | {0,NULL}, | 121 | {0,NULL} |
| 113 | }; | 122 | }; |
| 114 | 123 | ||
| 115 | #endif | 124 | #endif |
| 116 | 125 | ||
| 117 | void ERR_load_BIO_strings() | 126 | void ERR_load_BIO_strings(void) |
| 118 | { | 127 | { |
| 119 | static int init=1; | 128 | static int init=1; |
| 120 | 129 | ||
| 121 | if (init); | 130 | if (init) |
| 122 | {; | 131 | { |
| 123 | init=0; | 132 | init=0; |
| 124 | #ifndef NO_ERR | 133 | #ifndef NO_ERR |
| 125 | ERR_load_strings(ERR_LIB_BIO,BIO_str_functs); | 134 | ERR_load_strings(ERR_LIB_BIO,BIO_str_functs); |
diff --git a/src/lib/libcrypto/bio/bio_lib.c b/src/lib/libcrypto/bio/bio_lib.c index 7a66b0892e..b72688ea90 100644 --- a/src/lib/libcrypto/bio/bio_lib.c +++ b/src/lib/libcrypto/bio/bio_lib.c | |||
| @@ -58,16 +58,15 @@ | |||
| 58 | 58 | ||
| 59 | #include <stdio.h> | 59 | #include <stdio.h> |
| 60 | #include <errno.h> | 60 | #include <errno.h> |
| 61 | #include "crypto.h" | 61 | #include <openssl/crypto.h> |
| 62 | #include "cryptlib.h" | 62 | #include "cryptlib.h" |
| 63 | #include "bio.h" | 63 | #include <openssl/bio.h> |
| 64 | #include "stack.h" | 64 | #include <openssl/stack.h> |
| 65 | 65 | ||
| 66 | static STACK *bio_meth=NULL; | 66 | static STACK *bio_meth=NULL; |
| 67 | static int bio_meth_num=0; | 67 | static int bio_meth_num=0; |
| 68 | 68 | ||
| 69 | BIO *BIO_new(method) | 69 | BIO *BIO_new(BIO_METHOD *method) |
| 70 | BIO_METHOD *method; | ||
| 71 | { | 70 | { |
| 72 | BIO *ret=NULL; | 71 | BIO *ret=NULL; |
| 73 | 72 | ||
| @@ -85,9 +84,7 @@ BIO_METHOD *method; | |||
| 85 | return(ret); | 84 | return(ret); |
| 86 | } | 85 | } |
| 87 | 86 | ||
| 88 | int BIO_set(bio,method) | 87 | int BIO_set(BIO *bio, BIO_METHOD *method) |
| 89 | BIO *bio; | ||
| 90 | BIO_METHOD *method; | ||
| 91 | { | 88 | { |
| 92 | bio->method=method; | 89 | bio->method=method; |
| 93 | bio->callback=NULL; | 90 | bio->callback=NULL; |
| @@ -110,8 +107,7 @@ BIO_METHOD *method; | |||
| 110 | return(1); | 107 | return(1); |
| 111 | } | 108 | } |
| 112 | 109 | ||
| 113 | int BIO_free(a) | 110 | int BIO_free(BIO *a) |
| 114 | BIO *a; | ||
| 115 | { | 111 | { |
| 116 | int ret=0,i; | 112 | int ret=0,i; |
| 117 | 113 | ||
| @@ -121,7 +117,7 @@ BIO *a; | |||
| 121 | #ifdef REF_PRINT | 117 | #ifdef REF_PRINT |
| 122 | REF_PRINT("BIO",a); | 118 | REF_PRINT("BIO",a); |
| 123 | #endif | 119 | #endif |
| 124 | if (i > 0) return(1); | 120 | if (i > 0) return(1); |
| 125 | #ifdef REF_CHECK | 121 | #ifdef REF_CHECK |
| 126 | if (i < 0) | 122 | if (i < 0) |
| 127 | { | 123 | { |
| @@ -141,10 +137,7 @@ BIO *a; | |||
| 141 | return(1); | 137 | return(1); |
| 142 | } | 138 | } |
| 143 | 139 | ||
| 144 | int BIO_read(b,out,outl) | 140 | int BIO_read(BIO *b, void *out, int outl) |
| 145 | BIO *b; | ||
| 146 | char *out; | ||
| 147 | int outl; | ||
| 148 | { | 141 | { |
| 149 | int i; | 142 | int i; |
| 150 | long (*cb)(); | 143 | long (*cb)(); |
| @@ -162,11 +155,12 @@ int outl; | |||
| 162 | 155 | ||
| 163 | if (!b->init) | 156 | if (!b->init) |
| 164 | { | 157 | { |
| 165 | BIOerr(BIO_F_BIO_READ,BIO_R_UNINITALISED); | 158 | BIOerr(BIO_F_BIO_READ,BIO_R_UNINITIALIZED); |
| 166 | return(-2); | 159 | return(-2); |
| 167 | } | 160 | } |
| 168 | 161 | ||
| 169 | i=b->method->bread(b,out,outl); | 162 | i=b->method->bread(b,out,outl); |
| 163 | |||
| 170 | if (i > 0) b->num_read+=(unsigned long)i; | 164 | if (i > 0) b->num_read+=(unsigned long)i; |
| 171 | 165 | ||
| 172 | if (cb != NULL) | 166 | if (cb != NULL) |
| @@ -175,10 +169,7 @@ int outl; | |||
| 175 | return(i); | 169 | return(i); |
| 176 | } | 170 | } |
| 177 | 171 | ||
| 178 | int BIO_write(b,in,inl) | 172 | int BIO_write(BIO *b, const char *in, int inl) |
| 179 | BIO *b; | ||
| 180 | char *in; | ||
| 181 | int inl; | ||
| 182 | { | 173 | { |
| 183 | int i; | 174 | int i; |
| 184 | long (*cb)(); | 175 | long (*cb)(); |
| @@ -199,22 +190,27 @@ int inl; | |||
| 199 | 190 | ||
| 200 | if (!b->init) | 191 | if (!b->init) |
| 201 | { | 192 | { |
| 202 | BIOerr(BIO_F_BIO_WRITE,BIO_R_UNINITALISED); | 193 | BIOerr(BIO_F_BIO_WRITE,BIO_R_UNINITIALIZED); |
| 203 | return(-2); | 194 | return(-2); |
| 204 | } | 195 | } |
| 205 | 196 | ||
| 206 | i=b->method->bwrite(b,in,inl); | 197 | i=b->method->bwrite(b,in,inl); |
| 198 | |||
| 207 | if (i > 0) b->num_write+=(unsigned long)i; | 199 | if (i > 0) b->num_write+=(unsigned long)i; |
| 208 | 200 | ||
| 209 | if (cb != NULL) | 201 | /* This is evil and not thread safe. If the BIO has been freed, |
| 202 | * we must not call the callback. The only way to be able to | ||
| 203 | * determine this is the reference count which is now invalid since | ||
| 204 | * the memory has been free()ed. | ||
| 205 | */ | ||
| 206 | if (b->references <= 0) abort(); | ||
| 207 | if (cb != NULL) /* && (b->references >= 1)) */ | ||
| 210 | i=(int)cb(b,BIO_CB_WRITE|BIO_CB_RETURN,in,inl, | 208 | i=(int)cb(b,BIO_CB_WRITE|BIO_CB_RETURN,in,inl, |
| 211 | 0L,(long)i); | 209 | 0L,(long)i); |
| 212 | return(i); | 210 | return(i); |
| 213 | } | 211 | } |
| 214 | 212 | ||
| 215 | int BIO_puts(b,in) | 213 | int BIO_puts(BIO *b, const char *in) |
| 216 | BIO *b; | ||
| 217 | char *in; | ||
| 218 | { | 214 | { |
| 219 | int i; | 215 | int i; |
| 220 | long (*cb)(); | 216 | long (*cb)(); |
| @@ -233,7 +229,7 @@ char *in; | |||
| 233 | 229 | ||
| 234 | if (!b->init) | 230 | if (!b->init) |
| 235 | { | 231 | { |
| 236 | BIOerr(BIO_F_BIO_PUTS,BIO_R_UNINITALISED); | 232 | BIOerr(BIO_F_BIO_PUTS,BIO_R_UNINITIALIZED); |
| 237 | return(-2); | 233 | return(-2); |
| 238 | } | 234 | } |
| 239 | 235 | ||
| @@ -245,10 +241,7 @@ char *in; | |||
| 245 | return(i); | 241 | return(i); |
| 246 | } | 242 | } |
| 247 | 243 | ||
| 248 | int BIO_gets(b,in,inl) | 244 | int BIO_gets(BIO *b, char *in, int inl) |
| 249 | BIO *b; | ||
| 250 | char *in; | ||
| 251 | int inl; | ||
| 252 | { | 245 | { |
| 253 | int i; | 246 | int i; |
| 254 | long (*cb)(); | 247 | long (*cb)(); |
| @@ -267,7 +260,7 @@ int inl; | |||
| 267 | 260 | ||
| 268 | if (!b->init) | 261 | if (!b->init) |
| 269 | { | 262 | { |
| 270 | BIOerr(BIO_F_BIO_GETS,BIO_R_UNINITALISED); | 263 | BIOerr(BIO_F_BIO_GETS,BIO_R_UNINITIALIZED); |
| 271 | return(-2); | 264 | return(-2); |
| 272 | } | 265 | } |
| 273 | 266 | ||
| @@ -279,11 +272,7 @@ int inl; | |||
| 279 | return(i); | 272 | return(i); |
| 280 | } | 273 | } |
| 281 | 274 | ||
| 282 | long BIO_int_ctrl(b,cmd,larg,iarg) | 275 | long BIO_int_ctrl(BIO *b, int cmd, long larg, int iarg) |
| 283 | BIO *b; | ||
| 284 | int cmd; | ||
| 285 | long larg; | ||
| 286 | int iarg; | ||
| 287 | { | 276 | { |
| 288 | int i; | 277 | int i; |
| 289 | 278 | ||
| @@ -291,10 +280,7 @@ int iarg; | |||
| 291 | return(BIO_ctrl(b,cmd,larg,(char *)&i)); | 280 | return(BIO_ctrl(b,cmd,larg,(char *)&i)); |
| 292 | } | 281 | } |
| 293 | 282 | ||
| 294 | char *BIO_ptr_ctrl(b,cmd,larg) | 283 | char *BIO_ptr_ctrl(BIO *b, int cmd, long larg) |
| 295 | BIO *b; | ||
| 296 | int cmd; | ||
| 297 | long larg; | ||
| 298 | { | 284 | { |
| 299 | char *p=NULL; | 285 | char *p=NULL; |
| 300 | 286 | ||
| @@ -304,11 +290,7 @@ long larg; | |||
| 304 | return(p); | 290 | return(p); |
| 305 | } | 291 | } |
| 306 | 292 | ||
| 307 | long BIO_ctrl(b,cmd,larg,parg) | 293 | long BIO_ctrl(BIO *b, int cmd, long larg, void *parg) |
| 308 | BIO *b; | ||
| 309 | int cmd; | ||
| 310 | long larg; | ||
| 311 | char *parg; | ||
| 312 | { | 294 | { |
| 313 | long ret; | 295 | long ret; |
| 314 | long (*cb)(); | 296 | long (*cb)(); |
| @@ -335,9 +317,22 @@ char *parg; | |||
| 335 | return(ret); | 317 | return(ret); |
| 336 | } | 318 | } |
| 337 | 319 | ||
| 320 | /* It is unfortunate to duplicate in functions what the BIO_(w)pending macros | ||
| 321 | * do; but those macros have inappropriate return type, and for interfacing | ||
| 322 | * from other programming languages, C macros aren't much of a help anyway. */ | ||
| 323 | size_t BIO_ctrl_pending(BIO *bio) | ||
| 324 | { | ||
| 325 | return BIO_ctrl(bio, BIO_CTRL_PENDING, 0, NULL); | ||
| 326 | } | ||
| 327 | |||
| 328 | size_t BIO_ctrl_wpending(BIO *bio) | ||
| 329 | { | ||
| 330 | return BIO_ctrl(bio, BIO_CTRL_WPENDING, 0, NULL); | ||
| 331 | } | ||
| 332 | |||
| 333 | |||
| 338 | /* put the 'bio' on the end of b's list of operators */ | 334 | /* put the 'bio' on the end of b's list of operators */ |
| 339 | BIO *BIO_push(b,bio) | 335 | BIO *BIO_push(BIO *b, BIO *bio) |
| 340 | BIO *b,*bio; | ||
| 341 | { | 336 | { |
| 342 | BIO *lb; | 337 | BIO *lb; |
| 343 | 338 | ||
| @@ -354,8 +349,7 @@ BIO *b,*bio; | |||
| 354 | } | 349 | } |
| 355 | 350 | ||
| 356 | /* Remove the first and return the rest */ | 351 | /* Remove the first and return the rest */ |
| 357 | BIO *BIO_pop(b) | 352 | BIO *BIO_pop(BIO *b) |
| 358 | BIO *b; | ||
| 359 | { | 353 | { |
| 360 | BIO *ret; | 354 | BIO *ret; |
| 361 | 355 | ||
| @@ -373,9 +367,7 @@ BIO *b; | |||
| 373 | return(ret); | 367 | return(ret); |
| 374 | } | 368 | } |
| 375 | 369 | ||
| 376 | BIO *BIO_get_retry_BIO(bio,reason) | 370 | BIO *BIO_get_retry_BIO(BIO *bio, int *reason) |
| 377 | BIO *bio; | ||
| 378 | int *reason; | ||
| 379 | { | 371 | { |
| 380 | BIO *b,*last; | 372 | BIO *b,*last; |
| 381 | 373 | ||
| @@ -391,15 +383,12 @@ int *reason; | |||
| 391 | return(last); | 383 | return(last); |
| 392 | } | 384 | } |
| 393 | 385 | ||
| 394 | int BIO_get_retry_reason(bio) | 386 | int BIO_get_retry_reason(BIO *bio) |
| 395 | BIO *bio; | ||
| 396 | { | 387 | { |
| 397 | return(bio->retry_reason); | 388 | return(bio->retry_reason); |
| 398 | } | 389 | } |
| 399 | 390 | ||
| 400 | BIO *BIO_find_type(bio,type) | 391 | BIO *BIO_find_type(BIO *bio, int type) |
| 401 | BIO *bio; | ||
| 402 | int type; | ||
| 403 | { | 392 | { |
| 404 | int mt,mask; | 393 | int mt,mask; |
| 405 | 394 | ||
| @@ -421,8 +410,7 @@ int type; | |||
| 421 | return(NULL); | 410 | return(NULL); |
| 422 | } | 411 | } |
| 423 | 412 | ||
| 424 | void BIO_free_all(bio) | 413 | void BIO_free_all(BIO *bio) |
| 425 | BIO *bio; | ||
| 426 | { | 414 | { |
| 427 | BIO *b; | 415 | BIO *b; |
| 428 | int ref; | 416 | int ref; |
| @@ -438,8 +426,7 @@ BIO *bio; | |||
| 438 | } | 426 | } |
| 439 | } | 427 | } |
| 440 | 428 | ||
| 441 | BIO *BIO_dup_chain(in) | 429 | BIO *BIO_dup_chain(BIO *in) |
| 442 | BIO *in; | ||
| 443 | { | 430 | { |
| 444 | BIO *ret=NULL,*eoc=NULL,*bio,*new; | 431 | BIO *ret=NULL,*eoc=NULL,*bio,*new; |
| 445 | 432 | ||
| @@ -461,9 +448,9 @@ BIO *in; | |||
| 461 | goto err; | 448 | goto err; |
| 462 | } | 449 | } |
| 463 | 450 | ||
| 464 | /* copy app data */ | 451 | /* copy app data */ |
| 465 | if (!CRYPTO_dup_ex_data(bio_meth,&new->ex_data,&bio->ex_data)) | 452 | if (!CRYPTO_dup_ex_data(bio_meth,&new->ex_data,&bio->ex_data)) |
| 466 | goto err; | 453 | goto err; |
| 467 | 454 | ||
| 468 | if (ret == NULL) | 455 | if (ret == NULL) |
| 469 | { | 456 | { |
| @@ -483,36 +470,26 @@ err: | |||
| 483 | return(NULL); | 470 | return(NULL); |
| 484 | } | 471 | } |
| 485 | 472 | ||
| 486 | void BIO_copy_next_retry(b) | 473 | void BIO_copy_next_retry(BIO *b) |
| 487 | BIO *b; | ||
| 488 | { | 474 | { |
| 489 | BIO_set_flags(b,BIO_get_retry_flags(b->next_bio)); | 475 | BIO_set_flags(b,BIO_get_retry_flags(b->next_bio)); |
| 490 | b->retry_reason=b->next_bio->retry_reason; | 476 | b->retry_reason=b->next_bio->retry_reason; |
| 491 | } | 477 | } |
| 492 | 478 | ||
| 493 | int BIO_get_ex_new_index(argl,argp,new_func,dup_func,free_func) | 479 | int BIO_get_ex_new_index(long argl, char *argp, int (*new_func)(), |
| 494 | long argl; | 480 | int (*dup_func)(), void (*free_func)()) |
| 495 | char *argp; | 481 | { |
| 496 | int (*new_func)(); | 482 | bio_meth_num++; |
| 497 | int (*dup_func)(); | 483 | return(CRYPTO_get_ex_new_index(bio_meth_num-1,&bio_meth, |
| 498 | void (*free_func)(); | 484 | argl,argp,new_func,dup_func,free_func)); |
| 499 | { | 485 | } |
| 500 | bio_meth_num++; | 486 | |
| 501 | return(CRYPTO_get_ex_new_index(bio_meth_num-1,&bio_meth, | 487 | int BIO_set_ex_data(BIO *bio, int idx, char *data) |
| 502 | argl,argp,new_func,dup_func,free_func)); | ||
| 503 | } | ||
| 504 | |||
| 505 | int BIO_set_ex_data(bio,idx,data) | ||
| 506 | BIO *bio; | ||
| 507 | int idx; | ||
| 508 | char *data; | ||
| 509 | { | 488 | { |
| 510 | return(CRYPTO_set_ex_data(&(bio->ex_data),idx,data)); | 489 | return(CRYPTO_set_ex_data(&(bio->ex_data),idx,data)); |
| 511 | } | 490 | } |
| 512 | 491 | ||
| 513 | char *BIO_get_ex_data(bio,idx) | 492 | char *BIO_get_ex_data(BIO *bio, int idx) |
| 514 | BIO *bio; | ||
| 515 | int idx; | ||
| 516 | { | 493 | { |
| 517 | return(CRYPTO_get_ex_data(&(bio->ex_data),idx)); | 494 | return(CRYPTO_get_ex_data(&(bio->ex_data),idx)); |
| 518 | } | 495 | } |
diff --git a/src/lib/libcrypto/bio/bss_acpt.c b/src/lib/libcrypto/bio/bss_acpt.c index e49902fa9f..47af80f76d 100644 --- a/src/lib/libcrypto/bio/bss_acpt.c +++ b/src/lib/libcrypto/bio/bss_acpt.c | |||
| @@ -62,9 +62,7 @@ | |||
| 62 | #include <errno.h> | 62 | #include <errno.h> |
| 63 | #define USE_SOCKETS | 63 | #define USE_SOCKETS |
| 64 | #include "cryptlib.h" | 64 | #include "cryptlib.h" |
| 65 | #include "bio.h" | 65 | #include <openssl/bio.h> |
| 66 | |||
| 67 | /* BIOerr(BIO_F_WSASTARTUP,BIO_R_WSASTARTUP ); */ | ||
| 68 | 66 | ||
| 69 | #ifdef WIN16 | 67 | #ifdef WIN16 |
| 70 | #define SOCKET_PROTOCOL 0 /* more microsoft stupidity */ | 68 | #define SOCKET_PROTOCOL 0 /* more microsoft stupidity */ |
| @@ -72,6 +70,11 @@ | |||
| 72 | #define SOCKET_PROTOCOL IPPROTO_TCP | 70 | #define SOCKET_PROTOCOL IPPROTO_TCP |
| 73 | #endif | 71 | #endif |
| 74 | 72 | ||
| 73 | #if (defined(VMS) && __VMS_VER < 70000000) | ||
| 74 | /* FIONBIO used as a switch to enable ioctl, and that isn't in VMS < 7.0 */ | ||
| 75 | #undef FIONBIO | ||
| 76 | #endif | ||
| 77 | |||
| 75 | typedef struct bio_accept_st | 78 | typedef struct bio_accept_st |
| 76 | { | 79 | { |
| 77 | int state; | 80 | int state; |
| @@ -82,39 +85,24 @@ typedef struct bio_accept_st | |||
| 82 | 85 | ||
| 83 | char *addr; | 86 | char *addr; |
| 84 | int nbio; | 87 | int nbio; |
| 88 | /* If 0, it means normal, if 1, do a connect on bind failure, | ||
| 89 | * and if there is no-one listening, bind with SO_REUSEADDR. | ||
| 90 | * If 2, always use SO_REUSEADDR. */ | ||
| 91 | int bind_mode; | ||
| 85 | BIO *bio_chain; | 92 | BIO *bio_chain; |
| 86 | } BIO_ACCEPT; | 93 | } BIO_ACCEPT; |
| 87 | 94 | ||
| 88 | #ifndef NOPROTO | ||
| 89 | static int acpt_write(BIO *h,char *buf,int num); | 95 | static int acpt_write(BIO *h,char *buf,int num); |
| 90 | static int acpt_read(BIO *h,char *buf,int size); | 96 | static int acpt_read(BIO *h,char *buf,int size); |
| 91 | static int acpt_puts(BIO *h,char *str); | 97 | static int acpt_puts(BIO *h,char *str); |
| 92 | static long acpt_ctrl(BIO *h,int cmd,long arg1,char *arg2); | 98 | static long acpt_ctrl(BIO *h,int cmd,long arg1,char *arg2); |
| 93 | static int acpt_new(BIO *h); | 99 | static int acpt_new(BIO *h); |
| 94 | static int acpt_free(BIO *data); | 100 | static int acpt_free(BIO *data); |
| 95 | #else | ||
| 96 | static int acpt_write(); | ||
| 97 | static int acpt_read(); | ||
| 98 | static int acpt_puts(); | ||
| 99 | static long acpt_ctrl(); | ||
| 100 | static int acpt_new(); | ||
| 101 | static int acpt_free(); | ||
| 102 | #endif | ||
| 103 | |||
| 104 | #ifndef NOPROTO | ||
| 105 | static int acpt_state(BIO *b, BIO_ACCEPT *c); | 101 | static int acpt_state(BIO *b, BIO_ACCEPT *c); |
| 106 | static void acpt_close_socket(BIO *data); | 102 | static void acpt_close_socket(BIO *data); |
| 107 | BIO_ACCEPT *BIO_ACCEPT_new(void ); | 103 | BIO_ACCEPT *BIO_ACCEPT_new(void ); |
| 108 | void BIO_ACCEPT_free(BIO_ACCEPT *a); | 104 | void BIO_ACCEPT_free(BIO_ACCEPT *a); |
| 109 | 105 | ||
| 110 | #else | ||
| 111 | |||
| 112 | static int acpt_state(); | ||
| 113 | static void acpt_close_socket(); | ||
| 114 | BIO_ACCEPT *BIO_ACCEPT_new(); | ||
| 115 | void BIO_ACCEPT_free(); | ||
| 116 | #endif | ||
| 117 | |||
| 118 | #define ACPT_S_BEFORE 1 | 106 | #define ACPT_S_BEFORE 1 |
| 119 | #define ACPT_S_GET_ACCEPT_SOCKET 2 | 107 | #define ACPT_S_GET_ACCEPT_SOCKET 2 |
| 120 | #define ACPT_S_OK 3 | 108 | #define ACPT_S_OK 3 |
| @@ -132,13 +120,12 @@ static BIO_METHOD methods_acceptp= | |||
| 132 | acpt_free, | 120 | acpt_free, |
| 133 | }; | 121 | }; |
| 134 | 122 | ||
| 135 | BIO_METHOD *BIO_s_accept() | 123 | BIO_METHOD *BIO_s_accept(void) |
| 136 | { | 124 | { |
| 137 | return(&methods_acceptp); | 125 | return(&methods_acceptp); |
| 138 | } | 126 | } |
| 139 | 127 | ||
| 140 | static int acpt_new(bi) | 128 | static int acpt_new(BIO *bi) |
| 141 | BIO *bi; | ||
| 142 | { | 129 | { |
| 143 | BIO_ACCEPT *ba; | 130 | BIO_ACCEPT *ba; |
| 144 | 131 | ||
| @@ -153,7 +140,7 @@ BIO *bi; | |||
| 153 | return(1); | 140 | return(1); |
| 154 | } | 141 | } |
| 155 | 142 | ||
| 156 | BIO_ACCEPT *BIO_ACCEPT_new() | 143 | BIO_ACCEPT *BIO_ACCEPT_new(void) |
| 157 | { | 144 | { |
| 158 | BIO_ACCEPT *ret; | 145 | BIO_ACCEPT *ret; |
| 159 | 146 | ||
| @@ -162,20 +149,22 @@ BIO_ACCEPT *BIO_ACCEPT_new() | |||
| 162 | 149 | ||
| 163 | memset(ret,0,sizeof(BIO_ACCEPT)); | 150 | memset(ret,0,sizeof(BIO_ACCEPT)); |
| 164 | ret->accept_sock=INVALID_SOCKET; | 151 | ret->accept_sock=INVALID_SOCKET; |
| 152 | ret->bind_mode=BIO_BIND_NORMAL; | ||
| 165 | return(ret); | 153 | return(ret); |
| 166 | } | 154 | } |
| 167 | 155 | ||
| 168 | void BIO_ACCEPT_free(a) | 156 | void BIO_ACCEPT_free(BIO_ACCEPT *a) |
| 169 | BIO_ACCEPT *a; | ||
| 170 | { | 157 | { |
| 158 | if(a == NULL) | ||
| 159 | return; | ||
| 160 | |||
| 171 | if (a->param_addr != NULL) Free(a->param_addr); | 161 | if (a->param_addr != NULL) Free(a->param_addr); |
| 172 | if (a->addr != NULL) Free(a->addr); | 162 | if (a->addr != NULL) Free(a->addr); |
| 173 | if (a->bio_chain != NULL) BIO_free(a->bio_chain); | 163 | if (a->bio_chain != NULL) BIO_free(a->bio_chain); |
| 174 | Free(a); | 164 | Free(a); |
| 175 | } | 165 | } |
| 176 | 166 | ||
| 177 | static void acpt_close_socket(bio) | 167 | static void acpt_close_socket(BIO *bio) |
| 178 | BIO *bio; | ||
| 179 | { | 168 | { |
| 180 | BIO_ACCEPT *c; | 169 | BIO_ACCEPT *c; |
| 181 | 170 | ||
| @@ -183,18 +172,13 @@ BIO *bio; | |||
| 183 | if (c->accept_sock != INVALID_SOCKET) | 172 | if (c->accept_sock != INVALID_SOCKET) |
| 184 | { | 173 | { |
| 185 | shutdown(c->accept_sock,2); | 174 | shutdown(c->accept_sock,2); |
| 186 | # ifdef WINDOWS | ||
| 187 | closesocket(c->accept_sock); | 175 | closesocket(c->accept_sock); |
| 188 | # else | ||
| 189 | close(c->accept_sock); | ||
| 190 | # endif | ||
| 191 | c->accept_sock=INVALID_SOCKET; | 176 | c->accept_sock=INVALID_SOCKET; |
| 192 | bio->num=INVALID_SOCKET; | 177 | bio->num=INVALID_SOCKET; |
| 193 | } | 178 | } |
| 194 | } | 179 | } |
| 195 | 180 | ||
| 196 | static int acpt_free(a) | 181 | static int acpt_free(BIO *a) |
| 197 | BIO *a; | ||
| 198 | { | 182 | { |
| 199 | BIO_ACCEPT *data; | 183 | BIO_ACCEPT *data; |
| 200 | 184 | ||
| @@ -212,12 +196,9 @@ BIO *a; | |||
| 212 | return(1); | 196 | return(1); |
| 213 | } | 197 | } |
| 214 | 198 | ||
| 215 | static int acpt_state(b,c) | 199 | static int acpt_state(BIO *b, BIO_ACCEPT *c) |
| 216 | BIO *b; | ||
| 217 | BIO_ACCEPT *c; | ||
| 218 | { | 200 | { |
| 219 | BIO *bio=NULL,*dbio; | 201 | BIO *bio=NULL,*dbio; |
| 220 | unsigned long l=1; | ||
| 221 | int s= -1; | 202 | int s= -1; |
| 222 | int i; | 203 | int i; |
| 223 | 204 | ||
| @@ -230,31 +211,24 @@ again: | |||
| 230 | BIOerr(BIO_F_ACPT_STATE,BIO_R_NO_ACCEPT_PORT_SPECIFIED); | 211 | BIOerr(BIO_F_ACPT_STATE,BIO_R_NO_ACCEPT_PORT_SPECIFIED); |
| 231 | return(-1); | 212 | return(-1); |
| 232 | } | 213 | } |
| 233 | s=BIO_get_accept_socket(c->param_addr); | 214 | s=BIO_get_accept_socket(c->param_addr,c->bind_mode); |
| 234 | if (s == INVALID_SOCKET) | 215 | if (s == INVALID_SOCKET) |
| 235 | return(-1); | 216 | return(-1); |
| 236 | 217 | ||
| 237 | #ifdef FIONBIO | ||
| 238 | if (c->accept_nbio) | 218 | if (c->accept_nbio) |
| 239 | { | 219 | { |
| 240 | i=BIO_socket_ioctl(b->num,FIONBIO,&l); | 220 | if (!BIO_socket_nbio(s,1)) |
| 241 | if (i < 0) | ||
| 242 | { | 221 | { |
| 243 | #ifdef WINDOWS | ||
| 244 | closesocket(s); | 222 | closesocket(s); |
| 245 | #else | ||
| 246 | close(s); | ||
| 247 | # endif | ||
| 248 | BIOerr(BIO_F_ACPT_STATE,BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET); | 223 | BIOerr(BIO_F_ACPT_STATE,BIO_R_ERROR_SETTING_NBIO_ON_ACCEPT_SOCKET); |
| 249 | return(-1); | 224 | return(-1); |
| 250 | } | 225 | } |
| 251 | } | 226 | } |
| 252 | #endif | ||
| 253 | c->accept_sock=s; | 227 | c->accept_sock=s; |
| 254 | b->num=s; | 228 | b->num=s; |
| 255 | c->state=ACPT_S_GET_ACCEPT_SOCKET; | 229 | c->state=ACPT_S_GET_ACCEPT_SOCKET; |
| 256 | return(1); | 230 | return(1); |
| 257 | break; | 231 | /* break; */ |
| 258 | case ACPT_S_GET_ACCEPT_SOCKET: | 232 | case ACPT_S_GET_ACCEPT_SOCKET: |
| 259 | if (b->next_bio != NULL) | 233 | if (b->next_bio != NULL) |
| 260 | { | 234 | { |
| @@ -269,17 +243,14 @@ again: | |||
| 269 | BIO_set_callback(bio,BIO_get_callback(b)); | 243 | BIO_set_callback(bio,BIO_get_callback(b)); |
| 270 | BIO_set_callback_arg(bio,BIO_get_callback_arg(b)); | 244 | BIO_set_callback_arg(bio,BIO_get_callback_arg(b)); |
| 271 | 245 | ||
| 272 | #ifdef FIONBIO | ||
| 273 | if (c->nbio) | 246 | if (c->nbio) |
| 274 | { | 247 | { |
| 275 | i=BIO_socket_ioctl(i,FIONBIO,&l); | 248 | if (!BIO_socket_nbio(i,1)) |
| 276 | if (i < 0) | ||
| 277 | { | 249 | { |
| 278 | BIOerr(BIO_F_ACPT_STATE,BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET); | 250 | BIOerr(BIO_F_ACPT_STATE,BIO_R_ERROR_SETTING_NBIO_ON_ACCEPTED_SOCKET); |
| 279 | goto err; | 251 | goto err; |
| 280 | } | 252 | } |
| 281 | } | 253 | } |
| 282 | #endif | ||
| 283 | 254 | ||
| 284 | /* If the accept BIO has an bio_chain, we dup it and | 255 | /* If the accept BIO has an bio_chain, we dup it and |
| 285 | * put the new socket at the end. */ | 256 | * put the new socket at the end. */ |
| @@ -298,15 +269,9 @@ err: | |||
| 298 | if (bio != NULL) | 269 | if (bio != NULL) |
| 299 | BIO_free(bio); | 270 | BIO_free(bio); |
| 300 | else if (s >= 0) | 271 | else if (s >= 0) |
| 301 | { | ||
| 302 | #ifdef WINDOWS | ||
| 303 | closesocket(s); | 272 | closesocket(s); |
| 304 | #else | ||
| 305 | close(s); | ||
| 306 | # endif | ||
| 307 | } | ||
| 308 | return(0); | 273 | return(0); |
| 309 | break; | 274 | /* break; */ |
| 310 | case ACPT_S_OK: | 275 | case ACPT_S_OK: |
| 311 | if (b->next_bio == NULL) | 276 | if (b->next_bio == NULL) |
| 312 | { | 277 | { |
| @@ -314,23 +279,20 @@ err: | |||
| 314 | goto again; | 279 | goto again; |
| 315 | } | 280 | } |
| 316 | return(1); | 281 | return(1); |
| 317 | break; | 282 | /* break; */ |
| 318 | default: | 283 | default: |
| 319 | return(0); | 284 | return(0); |
| 320 | break; | 285 | /* break; */ |
| 321 | } | 286 | } |
| 322 | 287 | ||
| 323 | } | 288 | } |
| 324 | 289 | ||
| 325 | static int acpt_read(b,out,outl) | 290 | static int acpt_read(BIO *b, char *out, int outl) |
| 326 | BIO *b; | ||
| 327 | char *out; | ||
| 328 | int outl; | ||
| 329 | { | 291 | { |
| 330 | int ret=0; | 292 | int ret=0; |
| 331 | BIO_ACCEPT *data; | 293 | BIO_ACCEPT *data; |
| 332 | 294 | ||
| 333 | BIO_clear_retry_flags(b); | 295 | BIO_clear_retry_flags(b); |
| 334 | data=(BIO_ACCEPT *)b->ptr; | 296 | data=(BIO_ACCEPT *)b->ptr; |
| 335 | 297 | ||
| 336 | while (b->next_bio == NULL) | 298 | while (b->next_bio == NULL) |
| @@ -344,10 +306,7 @@ int outl; | |||
| 344 | return(ret); | 306 | return(ret); |
| 345 | } | 307 | } |
| 346 | 308 | ||
| 347 | static int acpt_write(b,in,inl) | 309 | static int acpt_write(BIO *b, char *in, int inl) |
| 348 | BIO *b; | ||
| 349 | char *in; | ||
| 350 | int inl; | ||
| 351 | { | 310 | { |
| 352 | int ret; | 311 | int ret; |
| 353 | BIO_ACCEPT *data; | 312 | BIO_ACCEPT *data; |
| @@ -366,11 +325,7 @@ int inl; | |||
| 366 | return(ret); | 325 | return(ret); |
| 367 | } | 326 | } |
| 368 | 327 | ||
| 369 | static long acpt_ctrl(b,cmd,num,ptr) | 328 | static long acpt_ctrl(BIO *b, int cmd, long num, char *ptr) |
| 370 | BIO *b; | ||
| 371 | int cmd; | ||
| 372 | long num; | ||
| 373 | char *ptr; | ||
| 374 | { | 329 | { |
| 375 | BIO *dbio; | 330 | BIO *dbio; |
| 376 | int *ip; | 331 | int *ip; |
| @@ -417,13 +372,21 @@ char *ptr; | |||
| 417 | case BIO_C_SET_NBIO: | 372 | case BIO_C_SET_NBIO: |
| 418 | data->nbio=(int)num; | 373 | data->nbio=(int)num; |
| 419 | break; | 374 | break; |
| 375 | case BIO_C_SET_FD: | ||
| 376 | b->init=1; | ||
| 377 | b->num= *((int *)ptr); | ||
| 378 | data->accept_sock=b->num; | ||
| 379 | data->state=ACPT_S_GET_ACCEPT_SOCKET; | ||
| 380 | b->shutdown=(int)num; | ||
| 381 | b->init=1; | ||
| 382 | break; | ||
| 420 | case BIO_C_GET_FD: | 383 | case BIO_C_GET_FD: |
| 421 | if (b->init) | 384 | if (b->init) |
| 422 | { | 385 | { |
| 423 | ip=(int *)ptr; | 386 | ip=(int *)ptr; |
| 424 | if (ip != NULL) | 387 | if (ip != NULL) |
| 425 | *ip=data->accept_sock; | 388 | *ip=data->accept_sock; |
| 426 | ret=b->num; | 389 | ret=data->accept_sock; |
| 427 | } | 390 | } |
| 428 | else | 391 | else |
| 429 | ret= -1; | 392 | ret= -1; |
| @@ -454,6 +417,12 @@ char *ptr; | |||
| 454 | break; | 417 | break; |
| 455 | case BIO_CTRL_FLUSH: | 418 | case BIO_CTRL_FLUSH: |
| 456 | break; | 419 | break; |
| 420 | case BIO_C_SET_BIND_MODE: | ||
| 421 | data->bind_mode=(int)num; | ||
| 422 | break; | ||
| 423 | case BIO_C_GET_BIND_MODE: | ||
| 424 | ret=(long)data->bind_mode; | ||
| 425 | break; | ||
| 457 | case BIO_CTRL_DUP: | 426 | case BIO_CTRL_DUP: |
| 458 | dbio=(BIO *)ptr; | 427 | dbio=(BIO *)ptr; |
| 459 | /* if (data->param_port) EAY EAY | 428 | /* if (data->param_port) EAY EAY |
| @@ -470,9 +439,7 @@ char *ptr; | |||
| 470 | return(ret); | 439 | return(ret); |
| 471 | } | 440 | } |
| 472 | 441 | ||
| 473 | static int acpt_puts(bp,str) | 442 | static int acpt_puts(BIO *bp, char *str) |
| 474 | BIO *bp; | ||
| 475 | char *str; | ||
| 476 | { | 443 | { |
| 477 | int n,ret; | 444 | int n,ret; |
| 478 | 445 | ||
| @@ -481,8 +448,7 @@ char *str; | |||
| 481 | return(ret); | 448 | return(ret); |
| 482 | } | 449 | } |
| 483 | 450 | ||
| 484 | BIO *BIO_new_accept(str) | 451 | BIO *BIO_new_accept(char *str) |
| 485 | char *str; | ||
| 486 | { | 452 | { |
| 487 | BIO *ret; | 453 | BIO *ret; |
| 488 | 454 | ||
diff --git a/src/lib/libcrypto/bio/bss_bio.c b/src/lib/libcrypto/bio/bss_bio.c new file mode 100644 index 0000000000..562e9d8de2 --- /dev/null +++ b/src/lib/libcrypto/bio/bss_bio.c | |||
| @@ -0,0 +1,588 @@ | |||
| 1 | /* crypto/bio/bss_bio.c -*- Mode: C; c-file-style: "eay" -*- */ | ||
| 2 | |||
| 3 | /* Special method for a BIO where the other endpoint is also a BIO | ||
| 4 | * of this kind, handled by the same thread (i.e. the "peer" is actually | ||
| 5 | * ourselves, wearing a different hat). | ||
| 6 | * Such "BIO pairs" are mainly for using the SSL library with I/O interfaces | ||
| 7 | * for which no specific BIO method is available. | ||
| 8 | * See ssl/ssltest.c for some hints on how this can be used. */ | ||
| 9 | |||
| 10 | #ifndef BIO_PAIR_DEBUG | ||
| 11 | # undef NDEBUG /* avoid conflicting definitions */ | ||
| 12 | # define NDEBUG | ||
| 13 | #endif | ||
| 14 | |||
| 15 | #include <assert.h> | ||
| 16 | #include <stdlib.h> | ||
| 17 | #include <string.h> | ||
| 18 | |||
| 19 | #include <openssl/bio.h> | ||
| 20 | #include <openssl/err.h> | ||
| 21 | #include <openssl/crypto.h> | ||
| 22 | |||
| 23 | static int bio_new(BIO *bio); | ||
| 24 | static int bio_free(BIO *bio); | ||
| 25 | static int bio_read(BIO *bio, char *buf, int size); | ||
| 26 | static int bio_write(BIO *bio, char *buf, int num); | ||
| 27 | static long bio_ctrl(BIO *bio, int cmd, long num, void *ptr); | ||
| 28 | static int bio_puts(BIO *bio, char *str); | ||
| 29 | |||
| 30 | static int bio_make_pair(BIO *bio1, BIO *bio2); | ||
| 31 | static void bio_destroy_pair(BIO *bio); | ||
| 32 | |||
| 33 | static BIO_METHOD methods_biop = | ||
| 34 | { | ||
| 35 | BIO_TYPE_BIO, | ||
| 36 | "BIO pair", | ||
| 37 | bio_write, | ||
| 38 | bio_read, | ||
| 39 | bio_puts, | ||
| 40 | NULL /* no bio_gets */, | ||
| 41 | bio_ctrl, | ||
| 42 | bio_new, | ||
| 43 | bio_free | ||
| 44 | }; | ||
| 45 | |||
| 46 | BIO_METHOD *BIO_s_bio(void) | ||
| 47 | { | ||
| 48 | return &methods_biop; | ||
| 49 | } | ||
| 50 | |||
| 51 | struct bio_bio_st | ||
| 52 | { | ||
| 53 | BIO *peer; /* NULL if buf == NULL. | ||
| 54 | * If peer != NULL, then peer->ptr is also a bio_bio_st, | ||
| 55 | * and its "peer" member points back to us. | ||
| 56 | * peer != NULL iff init != 0 in the BIO. */ | ||
| 57 | |||
| 58 | /* This is for what we write (i.e. reading uses peer's struct): */ | ||
| 59 | int closed; /* valid iff peer != NULL */ | ||
| 60 | size_t len; /* valid iff buf != NULL; 0 if peer == NULL */ | ||
| 61 | size_t offset; /* valid iff buf != NULL; 0 if len == 0 */ | ||
| 62 | size_t size; | ||
| 63 | char *buf; /* "size" elements (if != NULL) */ | ||
| 64 | |||
| 65 | size_t request; /* valid iff peer != NULL; 0 if len != 0, | ||
| 66 | * otherwise set by peer to number of bytes | ||
| 67 | * it (unsuccesfully) tried to read, | ||
| 68 | * never more than buffer space (size-len) warrants. */ | ||
| 69 | }; | ||
| 70 | |||
| 71 | static int bio_new(BIO *bio) | ||
| 72 | { | ||
| 73 | struct bio_bio_st *b; | ||
| 74 | |||
| 75 | b = Malloc(sizeof *b); | ||
| 76 | if (b == NULL) | ||
| 77 | return 0; | ||
| 78 | |||
| 79 | b->peer = NULL; | ||
| 80 | b->size = 17*1024; /* enough for one TLS record (just a default) */ | ||
| 81 | b->buf = NULL; | ||
| 82 | |||
| 83 | bio->ptr = b; | ||
| 84 | return 1; | ||
| 85 | } | ||
| 86 | |||
| 87 | |||
| 88 | static int bio_free(BIO *bio) | ||
| 89 | { | ||
| 90 | struct bio_bio_st *b; | ||
| 91 | |||
| 92 | if (bio == NULL) | ||
| 93 | return 0; | ||
| 94 | b = bio->ptr; | ||
| 95 | |||
| 96 | assert(b != NULL); | ||
| 97 | |||
| 98 | if (b->peer) | ||
| 99 | bio_destroy_pair(bio); | ||
| 100 | |||
| 101 | if (b->buf != NULL) | ||
| 102 | { | ||
| 103 | Free(b->buf); | ||
| 104 | } | ||
| 105 | |||
| 106 | Free(b); | ||
| 107 | |||
| 108 | return 1; | ||
| 109 | } | ||
| 110 | |||
| 111 | |||
| 112 | |||
| 113 | static int bio_read(BIO *bio, char *buf, int size_) | ||
| 114 | { | ||
| 115 | size_t size = size_; | ||
| 116 | size_t rest; | ||
| 117 | struct bio_bio_st *b, *peer_b; | ||
| 118 | |||
| 119 | BIO_clear_retry_flags(bio); | ||
| 120 | |||
| 121 | if (!bio->init) | ||
| 122 | return 0; | ||
| 123 | |||
| 124 | b = bio->ptr; | ||
| 125 | assert(b != NULL); | ||
| 126 | assert(b->peer != NULL); | ||
| 127 | peer_b = b->peer->ptr; | ||
| 128 | assert(peer_b != NULL); | ||
| 129 | assert(peer_b->buf != NULL); | ||
| 130 | |||
| 131 | peer_b->request = 0; /* will be set in "retry_read" situation */ | ||
| 132 | |||
| 133 | if (buf == NULL || size == 0) | ||
| 134 | return 0; | ||
| 135 | |||
| 136 | if (peer_b->len == 0) | ||
| 137 | { | ||
| 138 | if (peer_b->closed) | ||
| 139 | return 0; /* writer has closed, and no data is left */ | ||
| 140 | else | ||
| 141 | { | ||
| 142 | BIO_set_retry_read(bio); /* buffer is empty */ | ||
| 143 | if (size <= peer_b->size) | ||
| 144 | peer_b->request = size; | ||
| 145 | else | ||
| 146 | /* don't ask for more than the peer can | ||
| 147 | * deliver in one write */ | ||
| 148 | peer_b->request = peer_b->size; | ||
| 149 | return -1; | ||
| 150 | } | ||
| 151 | } | ||
| 152 | |||
| 153 | /* we can read */ | ||
| 154 | if (peer_b->len < size) | ||
| 155 | size = peer_b->len; | ||
| 156 | |||
| 157 | /* now read "size" bytes */ | ||
| 158 | |||
| 159 | rest = size; | ||
| 160 | |||
| 161 | assert(rest > 0); | ||
| 162 | do /* one or two iterations */ | ||
| 163 | { | ||
| 164 | size_t chunk; | ||
| 165 | |||
| 166 | assert(rest <= peer_b->len); | ||
| 167 | if (peer_b->offset + rest <= peer_b->size) | ||
| 168 | chunk = rest; | ||
| 169 | else | ||
| 170 | /* wrap around ring buffer */ | ||
| 171 | chunk = peer_b->size - peer_b->offset; | ||
| 172 | assert(peer_b->offset + chunk <= peer_b->size); | ||
| 173 | |||
| 174 | memcpy(buf, peer_b->buf + peer_b->offset, chunk); | ||
| 175 | |||
| 176 | peer_b->len -= chunk; | ||
| 177 | if (peer_b->len) | ||
| 178 | { | ||
| 179 | peer_b->offset += chunk; | ||
| 180 | assert(peer_b->offset <= peer_b->size); | ||
| 181 | if (peer_b->offset == peer_b->size) | ||
| 182 | peer_b->offset = 0; | ||
| 183 | buf += chunk; | ||
| 184 | } | ||
| 185 | else | ||
| 186 | { | ||
| 187 | /* buffer now empty, no need to advance "buf" */ | ||
| 188 | assert(chunk == rest); | ||
| 189 | peer_b->offset = 0; | ||
| 190 | } | ||
| 191 | rest -= chunk; | ||
| 192 | } | ||
| 193 | while (rest); | ||
| 194 | |||
| 195 | return size; | ||
| 196 | } | ||
| 197 | |||
| 198 | static int bio_write(BIO *bio, char *buf, int num_) | ||
| 199 | { | ||
| 200 | size_t num = num_; | ||
| 201 | size_t rest; | ||
| 202 | struct bio_bio_st *b; | ||
| 203 | |||
| 204 | BIO_clear_retry_flags(bio); | ||
| 205 | |||
| 206 | if (!bio->init || buf == NULL || num == 0) | ||
| 207 | return 0; | ||
| 208 | |||
| 209 | b = bio->ptr; | ||
| 210 | assert(b != NULL); | ||
| 211 | assert(b->peer != NULL); | ||
| 212 | assert(b->buf != NULL); | ||
| 213 | |||
| 214 | b->request = 0; | ||
| 215 | if (b->closed) | ||
| 216 | { | ||
| 217 | /* we already closed */ | ||
| 218 | BIOerr(BIO_F_BIO_WRITE, BIO_R_BROKEN_PIPE); | ||
| 219 | return -1; | ||
| 220 | } | ||
| 221 | |||
| 222 | assert(b->len <= b->size); | ||
| 223 | |||
| 224 | if (b->len == b->size) | ||
| 225 | { | ||
| 226 | BIO_set_retry_write(bio); /* buffer is full */ | ||
| 227 | return -1; | ||
| 228 | } | ||
| 229 | |||
| 230 | /* we can write */ | ||
| 231 | if (num > b->size - b->len) | ||
| 232 | num = b->size - b->len; | ||
| 233 | |||
| 234 | /* now write "num" bytes */ | ||
| 235 | |||
| 236 | rest = num; | ||
| 237 | |||
| 238 | assert(rest > 0); | ||
| 239 | do /* one or two iterations */ | ||
| 240 | { | ||
| 241 | size_t write_offset; | ||
| 242 | size_t chunk; | ||
| 243 | |||
| 244 | assert(b->len + rest <= b->size); | ||
| 245 | |||
| 246 | write_offset = b->offset + b->len; | ||
| 247 | if (write_offset >= b->size) | ||
| 248 | write_offset -= b->size; | ||
| 249 | /* b->buf[write_offset] is the first byte we can write to. */ | ||
| 250 | |||
| 251 | if (write_offset + rest <= b->size) | ||
| 252 | chunk = rest; | ||
| 253 | else | ||
| 254 | /* wrap around ring buffer */ | ||
| 255 | chunk = b->size - write_offset; | ||
| 256 | |||
| 257 | memcpy(b->buf + write_offset, buf, chunk); | ||
| 258 | |||
| 259 | b->len += chunk; | ||
| 260 | |||
| 261 | assert(b->len <= b->size); | ||
| 262 | |||
| 263 | rest -= chunk; | ||
| 264 | buf += chunk; | ||
| 265 | } | ||
| 266 | while (rest); | ||
| 267 | |||
| 268 | return num; | ||
| 269 | } | ||
| 270 | |||
| 271 | |||
| 272 | static long bio_ctrl(BIO *bio, int cmd, long num, void *ptr) | ||
| 273 | { | ||
| 274 | long ret; | ||
| 275 | struct bio_bio_st *b = bio->ptr; | ||
| 276 | |||
| 277 | assert(b != NULL); | ||
| 278 | |||
| 279 | switch (cmd) | ||
| 280 | { | ||
| 281 | /* specific CTRL codes */ | ||
| 282 | |||
| 283 | case BIO_C_SET_WRITE_BUF_SIZE: | ||
| 284 | if (b->peer) | ||
| 285 | { | ||
| 286 | BIOerr(BIO_F_BIO_CTRL, BIO_R_IN_USE); | ||
| 287 | ret = 0; | ||
| 288 | } | ||
| 289 | else if (num == 0) | ||
| 290 | { | ||
| 291 | BIOerr(BIO_F_BIO_CTRL, BIO_R_INVALID_ARGUMENT); | ||
| 292 | ret = 0; | ||
| 293 | } | ||
| 294 | else | ||
| 295 | { | ||
| 296 | size_t new_size = num; | ||
| 297 | |||
| 298 | if (b->size != new_size) | ||
| 299 | { | ||
| 300 | if (b->buf) | ||
| 301 | { | ||
| 302 | Free(b->buf); | ||
| 303 | b->buf = NULL; | ||
| 304 | } | ||
| 305 | b->size = new_size; | ||
| 306 | } | ||
| 307 | ret = 1; | ||
| 308 | } | ||
| 309 | break; | ||
| 310 | |||
| 311 | case BIO_C_GET_WRITE_BUF_SIZE: | ||
| 312 | num = (long) b->size; | ||
| 313 | |||
| 314 | case BIO_C_MAKE_BIO_PAIR: | ||
| 315 | { | ||
| 316 | BIO *other_bio = ptr; | ||
| 317 | |||
| 318 | if (bio_make_pair(bio, other_bio)) | ||
| 319 | ret = 1; | ||
| 320 | else | ||
| 321 | ret = 0; | ||
| 322 | } | ||
| 323 | break; | ||
| 324 | |||
| 325 | case BIO_C_DESTROY_BIO_PAIR: | ||
| 326 | /* Effects both BIOs in the pair -- call just once! | ||
| 327 | * Or let BIO_free(bio1); BIO_free(bio2); do the job. */ | ||
| 328 | bio_destroy_pair(bio); | ||
| 329 | ret = 1; | ||
| 330 | break; | ||
| 331 | |||
| 332 | case BIO_C_GET_WRITE_GUARANTEE: | ||
| 333 | /* How many bytes can the caller feed to the next write | ||
| 334 | * withouth having to keep any? */ | ||
| 335 | if (b->peer == NULL || b->closed) | ||
| 336 | ret = 0; | ||
| 337 | else | ||
| 338 | ret = (long) b->size - b->len; | ||
| 339 | break; | ||
| 340 | |||
| 341 | case BIO_C_GET_READ_REQUEST: | ||
| 342 | /* If the peer unsuccesfully tried to read, how many bytes | ||
| 343 | * were requested? (As with BIO_CTRL_PENDING, that number | ||
| 344 | * can usually be treated as boolean.) */ | ||
| 345 | ret = (long) b->request; | ||
| 346 | break; | ||
| 347 | |||
| 348 | case BIO_C_SHUTDOWN_WR: | ||
| 349 | /* similar to shutdown(..., SHUT_WR) */ | ||
| 350 | b->closed = 1; | ||
| 351 | ret = 1; | ||
| 352 | break; | ||
| 353 | |||
| 354 | |||
| 355 | /* standard CTRL codes follow */ | ||
| 356 | |||
| 357 | case BIO_CTRL_RESET: | ||
| 358 | if (b->buf != NULL) | ||
| 359 | { | ||
| 360 | b->len = 0; | ||
| 361 | b->offset = 0; | ||
| 362 | } | ||
| 363 | ret = 0; | ||
| 364 | break; | ||
| 365 | |||
| 366 | case BIO_CTRL_GET_CLOSE: | ||
| 367 | ret = bio->shutdown; | ||
| 368 | break; | ||
| 369 | |||
| 370 | case BIO_CTRL_SET_CLOSE: | ||
| 371 | bio->shutdown = (int) num; | ||
| 372 | ret = 1; | ||
| 373 | break; | ||
| 374 | |||
| 375 | case BIO_CTRL_PENDING: | ||
| 376 | if (b->peer != NULL) | ||
| 377 | { | ||
| 378 | struct bio_bio_st *peer_b = b->peer->ptr; | ||
| 379 | |||
| 380 | ret = (long) peer_b->len; | ||
| 381 | } | ||
| 382 | else | ||
| 383 | ret = 0; | ||
| 384 | break; | ||
| 385 | |||
| 386 | case BIO_CTRL_WPENDING: | ||
| 387 | if (b->buf != NULL) | ||
| 388 | ret = (long) b->len; | ||
| 389 | else | ||
| 390 | ret = 0; | ||
| 391 | break; | ||
| 392 | |||
| 393 | case BIO_CTRL_DUP: | ||
| 394 | /* See BIO_dup_chain for circumstances we have to expect. */ | ||
| 395 | { | ||
| 396 | BIO *other_bio = ptr; | ||
| 397 | struct bio_bio_st *other_b; | ||
| 398 | |||
| 399 | assert(other_bio != NULL); | ||
| 400 | other_b = other_bio->ptr; | ||
| 401 | assert(other_b != NULL); | ||
| 402 | |||
| 403 | assert(other_b->buf == NULL); /* other_bio is always fresh */ | ||
| 404 | |||
| 405 | other_b->size = b->size; | ||
| 406 | } | ||
| 407 | |||
| 408 | ret = 1; | ||
| 409 | break; | ||
| 410 | |||
| 411 | case BIO_CTRL_FLUSH: | ||
| 412 | ret = 1; | ||
| 413 | break; | ||
| 414 | |||
| 415 | case BIO_CTRL_EOF: | ||
| 416 | { | ||
| 417 | BIO *other_bio = ptr; | ||
| 418 | |||
| 419 | if (other_bio) | ||
| 420 | { | ||
| 421 | struct bio_bio_st *other_b = other_bio->ptr; | ||
| 422 | |||
| 423 | assert(other_b != NULL); | ||
| 424 | ret = other_b->len == 0 && other_b->closed; | ||
| 425 | } | ||
| 426 | else | ||
| 427 | ret = 1; | ||
| 428 | } | ||
| 429 | break; | ||
| 430 | |||
| 431 | default: | ||
| 432 | ret = 0; | ||
| 433 | } | ||
| 434 | return ret; | ||
| 435 | } | ||
| 436 | |||
| 437 | static int bio_puts(BIO *bio, char *str) | ||
| 438 | { | ||
| 439 | return bio_write(bio, str, strlen(str)); | ||
| 440 | } | ||
| 441 | |||
| 442 | |||
| 443 | static int bio_make_pair(BIO *bio1, BIO *bio2) | ||
| 444 | { | ||
| 445 | struct bio_bio_st *b1, *b2; | ||
| 446 | |||
| 447 | assert(bio1 != NULL); | ||
| 448 | assert(bio2 != NULL); | ||
| 449 | |||
| 450 | b1 = bio1->ptr; | ||
| 451 | b2 = bio2->ptr; | ||
| 452 | |||
| 453 | if (b1->peer != NULL || b2->peer != NULL) | ||
| 454 | { | ||
| 455 | BIOerr(BIO_F_BIO_MAKE_PAIR, BIO_R_IN_USE); | ||
| 456 | return 0; | ||
| 457 | } | ||
| 458 | |||
| 459 | if (b1->buf == NULL) | ||
| 460 | { | ||
| 461 | b1->buf = Malloc(b1->size); | ||
| 462 | if (b1->buf == NULL) | ||
| 463 | { | ||
| 464 | BIOerr(BIO_F_BIO_MAKE_PAIR, ERR_R_MALLOC_FAILURE); | ||
| 465 | return 0; | ||
| 466 | } | ||
| 467 | b1->len = 0; | ||
| 468 | b1->offset = 0; | ||
| 469 | } | ||
| 470 | |||
| 471 | if (b2->buf == NULL) | ||
| 472 | { | ||
| 473 | b2->buf = Malloc(b2->size); | ||
| 474 | if (b2->buf == NULL) | ||
| 475 | { | ||
| 476 | BIOerr(BIO_F_BIO_MAKE_PAIR, ERR_R_MALLOC_FAILURE); | ||
| 477 | return 0; | ||
| 478 | } | ||
| 479 | b2->len = 0; | ||
| 480 | b2->offset = 0; | ||
| 481 | } | ||
| 482 | |||
| 483 | b1->peer = bio2; | ||
| 484 | b1->closed = 0; | ||
| 485 | b1->request = 0; | ||
| 486 | b2->peer = bio1; | ||
| 487 | b2->closed = 0; | ||
| 488 | b2->request = 0; | ||
| 489 | |||
| 490 | bio1->init = 1; | ||
| 491 | bio2->init = 1; | ||
| 492 | |||
| 493 | return 1; | ||
| 494 | } | ||
| 495 | |||
| 496 | static void bio_destroy_pair(BIO *bio) | ||
| 497 | { | ||
| 498 | struct bio_bio_st *b = bio->ptr; | ||
| 499 | |||
| 500 | if (b != NULL) | ||
| 501 | { | ||
| 502 | BIO *peer_bio = b->peer; | ||
| 503 | |||
| 504 | if (peer_bio != NULL) | ||
| 505 | { | ||
| 506 | struct bio_bio_st *peer_b = peer_bio->ptr; | ||
| 507 | |||
| 508 | assert(peer_b != NULL); | ||
| 509 | assert(peer_b->peer == bio); | ||
| 510 | |||
| 511 | peer_b->peer = NULL; | ||
| 512 | peer_bio->init = 0; | ||
| 513 | assert(peer_b->buf != NULL); | ||
| 514 | peer_b->len = 0; | ||
| 515 | peer_b->offset = 0; | ||
| 516 | |||
| 517 | b->peer = NULL; | ||
| 518 | bio->init = 0; | ||
| 519 | assert(b->buf != NULL); | ||
| 520 | b->len = 0; | ||
| 521 | b->offset = 0; | ||
| 522 | } | ||
| 523 | } | ||
| 524 | } | ||
| 525 | |||
| 526 | |||
| 527 | /* Exported convenience functions */ | ||
| 528 | int BIO_new_bio_pair(BIO **bio1_p, size_t writebuf1, | ||
| 529 | BIO **bio2_p, size_t writebuf2) | ||
| 530 | { | ||
| 531 | BIO *bio1 = NULL, *bio2 = NULL; | ||
| 532 | long r; | ||
| 533 | int ret = 0; | ||
| 534 | |||
| 535 | bio1 = BIO_new(BIO_s_bio()); | ||
| 536 | if (bio1 == NULL) | ||
| 537 | goto err; | ||
| 538 | bio2 = BIO_new(BIO_s_bio()); | ||
| 539 | if (bio2 == NULL) | ||
| 540 | goto err; | ||
| 541 | |||
| 542 | if (writebuf1) | ||
| 543 | { | ||
| 544 | r = BIO_set_write_buf_size(bio1, writebuf1); | ||
| 545 | if (!r) | ||
| 546 | goto err; | ||
| 547 | } | ||
| 548 | if (writebuf2) | ||
| 549 | { | ||
| 550 | r = BIO_set_write_buf_size(bio2, writebuf2); | ||
| 551 | if (!r) | ||
| 552 | goto err; | ||
| 553 | } | ||
| 554 | |||
| 555 | r = BIO_make_bio_pair(bio1, bio2); | ||
| 556 | if (!r) | ||
| 557 | goto err; | ||
| 558 | ret = 1; | ||
| 559 | |||
| 560 | err: | ||
| 561 | if (ret == 0) | ||
| 562 | { | ||
| 563 | if (bio1) | ||
| 564 | { | ||
| 565 | BIO_free(bio1); | ||
| 566 | bio1 = NULL; | ||
| 567 | } | ||
| 568 | if (bio2) | ||
| 569 | { | ||
| 570 | BIO_free(bio2); | ||
| 571 | bio2 = NULL; | ||
| 572 | } | ||
| 573 | } | ||
| 574 | |||
| 575 | *bio1_p = bio1; | ||
| 576 | *bio2_p = bio2; | ||
| 577 | return ret; | ||
| 578 | } | ||
| 579 | |||
| 580 | size_t BIO_ctrl_get_write_guarantee(BIO *bio) | ||
| 581 | { | ||
| 582 | return BIO_ctrl(bio, BIO_C_GET_WRITE_GUARANTEE, 0, NULL); | ||
| 583 | } | ||
| 584 | |||
| 585 | size_t BIO_ctrl_get_read_request(BIO *bio) | ||
| 586 | { | ||
| 587 | return BIO_ctrl(bio, BIO_C_GET_READ_REQUEST, 0, NULL); | ||
| 588 | } | ||
diff --git a/src/lib/libcrypto/bio/bss_conn.c b/src/lib/libcrypto/bio/bss_conn.c index 6e547bf866..68c46e3d69 100644 --- a/src/lib/libcrypto/bio/bss_conn.c +++ b/src/lib/libcrypto/bio/bss_conn.c | |||
| @@ -62,9 +62,7 @@ | |||
| 62 | #include <errno.h> | 62 | #include <errno.h> |
| 63 | #define USE_SOCKETS | 63 | #define USE_SOCKETS |
| 64 | #include "cryptlib.h" | 64 | #include "cryptlib.h" |
| 65 | #include "bio.h" | 65 | #include <openssl/bio.h> |
| 66 | |||
| 67 | /* BIOerr(BIO_F_WSASTARTUP,BIO_R_WSASTARTUP ); */ | ||
| 68 | 66 | ||
| 69 | #ifdef WIN16 | 67 | #ifdef WIN16 |
| 70 | #define SOCKET_PROTOCOL 0 /* more microsoft stupidity */ | 68 | #define SOCKET_PROTOCOL 0 /* more microsoft stupidity */ |
| @@ -72,6 +70,12 @@ | |||
| 72 | #define SOCKET_PROTOCOL IPPROTO_TCP | 70 | #define SOCKET_PROTOCOL IPPROTO_TCP |
| 73 | #endif | 71 | #endif |
| 74 | 72 | ||
| 73 | #if (defined(VMS) && __VMS_VER < 70000000) | ||
| 74 | /* FIONBIO used as a switch to enable ioctl, and that isn't in VMS < 7.0 */ | ||
| 75 | #undef FIONBIO | ||
| 76 | #endif | ||
| 77 | |||
| 78 | |||
| 75 | typedef struct bio_connect_st | 79 | typedef struct bio_connect_st |
| 76 | { | 80 | { |
| 77 | int state; | 81 | int state; |
| @@ -81,13 +85,12 @@ typedef struct bio_connect_st | |||
| 81 | int nbio; | 85 | int nbio; |
| 82 | 86 | ||
| 83 | unsigned char ip[4]; | 87 | unsigned char ip[4]; |
| 84 | short port; | 88 | unsigned short port; |
| 85 | 89 | ||
| 86 | struct sockaddr_in them; | 90 | struct sockaddr_in them; |
| 87 | 91 | ||
| 88 | /* int socket; this will be kept in bio->num so that it is | 92 | /* int socket; this will be kept in bio->num so that it is |
| 89 | * compatable with the bss_sock bio */ | 93 | * compatable with the bss_sock bio */ |
| 90 | int error; | ||
| 91 | 94 | ||
| 92 | /* called when the connection is initially made | 95 | /* called when the connection is initially made |
| 93 | * callback(BIO,state,ret); The callback should return | 96 | * callback(BIO,state,ret); The callback should return |
| @@ -95,38 +98,18 @@ typedef struct bio_connect_st | |||
| 95 | int (*info_callback)(); | 98 | int (*info_callback)(); |
| 96 | } BIO_CONNECT; | 99 | } BIO_CONNECT; |
| 97 | 100 | ||
| 98 | #ifndef NOPROTO | ||
| 99 | static int conn_write(BIO *h,char *buf,int num); | 101 | static int conn_write(BIO *h,char *buf,int num); |
| 100 | static int conn_read(BIO *h,char *buf,int size); | 102 | static int conn_read(BIO *h,char *buf,int size); |
| 101 | static int conn_puts(BIO *h,char *str); | 103 | static int conn_puts(BIO *h,char *str); |
| 102 | static long conn_ctrl(BIO *h,int cmd,long arg1,char *arg2); | 104 | static long conn_ctrl(BIO *h,int cmd,long arg1,char *arg2); |
| 103 | static int conn_new(BIO *h); | 105 | static int conn_new(BIO *h); |
| 104 | static int conn_free(BIO *data); | 106 | static int conn_free(BIO *data); |
| 105 | #else | ||
| 106 | static int conn_write(); | ||
| 107 | static int conn_read(); | ||
| 108 | static int conn_puts(); | ||
| 109 | static long conn_ctrl(); | ||
| 110 | static int conn_new(); | ||
| 111 | static int conn_free(); | ||
| 112 | #endif | ||
| 113 | |||
| 114 | #ifndef NOPROTO | ||
| 115 | 107 | ||
| 116 | static int conn_state(BIO *b, BIO_CONNECT *c); | 108 | static int conn_state(BIO *b, BIO_CONNECT *c); |
| 117 | static void conn_close_socket(BIO *data); | 109 | static void conn_close_socket(BIO *data); |
| 118 | BIO_CONNECT *BIO_CONNECT_new(void ); | 110 | BIO_CONNECT *BIO_CONNECT_new(void ); |
| 119 | void BIO_CONNECT_free(BIO_CONNECT *a); | 111 | void BIO_CONNECT_free(BIO_CONNECT *a); |
| 120 | 112 | ||
| 121 | #else | ||
| 122 | |||
| 123 | static int conn_state(); | ||
| 124 | static void conn_close_socket(); | ||
| 125 | BIO_CONNECT *BIO_CONNECT_new(); | ||
| 126 | void BIO_CONNECT_free(); | ||
| 127 | |||
| 128 | #endif | ||
| 129 | |||
| 130 | static BIO_METHOD methods_connectp= | 113 | static BIO_METHOD methods_connectp= |
| 131 | { | 114 | { |
| 132 | BIO_TYPE_CONNECT, | 115 | BIO_TYPE_CONNECT, |
| @@ -140,9 +123,7 @@ static BIO_METHOD methods_connectp= | |||
| 140 | conn_free, | 123 | conn_free, |
| 141 | }; | 124 | }; |
| 142 | 125 | ||
| 143 | static int conn_state(b,c) | 126 | static int conn_state(BIO *b, BIO_CONNECT *c) |
| 144 | BIO *b; | ||
| 145 | BIO_CONNECT *c; | ||
| 146 | { | 127 | { |
| 147 | int ret= -1,i; | 128 | int ret= -1,i; |
| 148 | unsigned long l; | 129 | unsigned long l; |
| @@ -160,7 +141,7 @@ BIO_CONNECT *c; | |||
| 160 | p=c->param_hostname; | 141 | p=c->param_hostname; |
| 161 | if (p == NULL) | 142 | if (p == NULL) |
| 162 | { | 143 | { |
| 163 | BIOerr(BIO_F_CONN_STATE,BIO_R_NO_HOSTHNAME_SPECIFIED); | 144 | BIOerr(BIO_F_CONN_STATE,BIO_R_NO_HOSTNAME_SPECIFIED); |
| 164 | goto exit_loop; | 145 | goto exit_loop; |
| 165 | } | 146 | } |
| 166 | for ( ; *p != '\0'; p++) | 147 | for ( ; *p != '\0'; p++) |
| @@ -187,7 +168,7 @@ BIO_CONNECT *c; | |||
| 187 | } | 168 | } |
| 188 | } | 169 | } |
| 189 | 170 | ||
| 190 | if (p == NULL) | 171 | if (c->param_port == NULL) |
| 191 | { | 172 | { |
| 192 | BIOerr(BIO_F_CONN_STATE,BIO_R_NO_PORT_SPECIFIED); | 173 | BIOerr(BIO_F_CONN_STATE,BIO_R_NO_PORT_SPECIFIED); |
| 193 | ERR_add_error_data(2,"host=",c->param_hostname); | 174 | ERR_add_error_data(2,"host=",c->param_hostname); |
| @@ -203,7 +184,12 @@ BIO_CONNECT *c; | |||
| 203 | break; | 184 | break; |
| 204 | 185 | ||
| 205 | case BIO_CONN_S_GET_PORT: | 186 | case BIO_CONN_S_GET_PORT: |
| 206 | if (BIO_get_port(c->param_port,&c->port) <= 0) | 187 | if (c->param_port == NULL) |
| 188 | { | ||
| 189 | abort(); | ||
| 190 | goto exit_loop; | ||
| 191 | } | ||
| 192 | else if (BIO_get_port(c->param_port,&c->port) <= 0) | ||
| 207 | goto exit_loop; | 193 | goto exit_loop; |
| 208 | c->state=BIO_CONN_S_CREATE_SOCKET; | 194 | c->state=BIO_CONN_S_CREATE_SOCKET; |
| 209 | break; | 195 | break; |
| @@ -235,12 +221,9 @@ BIO_CONNECT *c; | |||
| 235 | break; | 221 | break; |
| 236 | 222 | ||
| 237 | case BIO_CONN_S_NBIO: | 223 | case BIO_CONN_S_NBIO: |
| 238 | #ifdef FIONBIO | ||
| 239 | if (c->nbio) | 224 | if (c->nbio) |
| 240 | { | 225 | { |
| 241 | l=1; | 226 | if (!BIO_socket_nbio(b->num,1)) |
| 242 | ret=BIO_socket_ioctl(b->num,FIONBIO,&l); | ||
| 243 | if (ret < 0) | ||
| 244 | { | 227 | { |
| 245 | BIOerr(BIO_F_CONN_STATE,BIO_R_ERROR_SETTING_NBIO); | 228 | BIOerr(BIO_F_CONN_STATE,BIO_R_ERROR_SETTING_NBIO); |
| 246 | ERR_add_error_data(4,"host=", | 229 | ERR_add_error_data(4,"host=", |
| @@ -249,7 +232,6 @@ BIO_CONNECT *c; | |||
| 249 | goto exit_loop; | 232 | goto exit_loop; |
| 250 | } | 233 | } |
| 251 | } | 234 | } |
| 252 | #endif | ||
| 253 | c->state=BIO_CONN_S_CONNECT; | 235 | c->state=BIO_CONN_S_CONNECT; |
| 254 | 236 | ||
| 255 | #ifdef SO_KEEPALIVE | 237 | #ifdef SO_KEEPALIVE |
| @@ -326,17 +308,15 @@ BIO_CONNECT *c; | |||
| 326 | } | 308 | } |
| 327 | } | 309 | } |
| 328 | 310 | ||
| 329 | if (1) | 311 | /* Loop does not exit */ |
| 330 | { | ||
| 331 | exit_loop: | 312 | exit_loop: |
| 332 | if (cb != NULL) | 313 | if (cb != NULL) |
| 333 | ret=cb((BIO *)b,c->state,ret); | 314 | ret=cb((BIO *)b,c->state,ret); |
| 334 | } | ||
| 335 | end: | 315 | end: |
| 336 | return(ret); | 316 | return(ret); |
| 337 | } | 317 | } |
| 338 | 318 | ||
| 339 | BIO_CONNECT *BIO_CONNECT_new() | 319 | BIO_CONNECT *BIO_CONNECT_new(void) |
| 340 | { | 320 | { |
| 341 | BIO_CONNECT *ret; | 321 | BIO_CONNECT *ret; |
| 342 | 322 | ||
| @@ -353,13 +333,14 @@ BIO_CONNECT *BIO_CONNECT_new() | |||
| 353 | ret->ip[3]=0; | 333 | ret->ip[3]=0; |
| 354 | ret->port=0; | 334 | ret->port=0; |
| 355 | memset((char *)&ret->them,0,sizeof(ret->them)); | 335 | memset((char *)&ret->them,0,sizeof(ret->them)); |
| 356 | ret->error=0; | ||
| 357 | return(ret); | 336 | return(ret); |
| 358 | } | 337 | } |
| 359 | 338 | ||
| 360 | void BIO_CONNECT_free(a) | 339 | void BIO_CONNECT_free(BIO_CONNECT *a) |
| 361 | BIO_CONNECT *a; | ||
| 362 | { | 340 | { |
| 341 | if(a == NULL) | ||
| 342 | return; | ||
| 343 | |||
| 363 | if (a->param_hostname != NULL) | 344 | if (a->param_hostname != NULL) |
| 364 | Free(a->param_hostname); | 345 | Free(a->param_hostname); |
| 365 | if (a->param_port != NULL) | 346 | if (a->param_port != NULL) |
| @@ -367,13 +348,12 @@ BIO_CONNECT *a; | |||
| 367 | Free(a); | 348 | Free(a); |
| 368 | } | 349 | } |
| 369 | 350 | ||
| 370 | BIO_METHOD *BIO_s_connect() | 351 | BIO_METHOD *BIO_s_connect(void) |
| 371 | { | 352 | { |
| 372 | return(&methods_connectp); | 353 | return(&methods_connectp); |
| 373 | } | 354 | } |
| 374 | 355 | ||
| 375 | static int conn_new(bi) | 356 | static int conn_new(BIO *bi) |
| 376 | BIO *bi; | ||
| 377 | { | 357 | { |
| 378 | bi->init=0; | 358 | bi->init=0; |
| 379 | bi->num=INVALID_SOCKET; | 359 | bi->num=INVALID_SOCKET; |
| @@ -384,8 +364,7 @@ BIO *bi; | |||
| 384 | return(1); | 364 | return(1); |
| 385 | } | 365 | } |
| 386 | 366 | ||
| 387 | static void conn_close_socket(bio) | 367 | static void conn_close_socket(BIO *bio) |
| 388 | BIO *bio; | ||
| 389 | { | 368 | { |
| 390 | BIO_CONNECT *c; | 369 | BIO_CONNECT *c; |
| 391 | 370 | ||
| @@ -395,17 +374,12 @@ BIO *bio; | |||
| 395 | /* Only do a shutdown if things were established */ | 374 | /* Only do a shutdown if things were established */ |
| 396 | if (c->state == BIO_CONN_S_OK) | 375 | if (c->state == BIO_CONN_S_OK) |
| 397 | shutdown(bio->num,2); | 376 | shutdown(bio->num,2); |
| 398 | # ifdef WINDOWS | ||
| 399 | closesocket(bio->num); | 377 | closesocket(bio->num); |
| 400 | # else | ||
| 401 | close(bio->num); | ||
| 402 | # endif | ||
| 403 | bio->num=INVALID_SOCKET; | 378 | bio->num=INVALID_SOCKET; |
| 404 | } | 379 | } |
| 405 | } | 380 | } |
| 406 | 381 | ||
| 407 | static int conn_free(a) | 382 | static int conn_free(BIO *a) |
| 408 | BIO *a; | ||
| 409 | { | 383 | { |
| 410 | BIO_CONNECT *data; | 384 | BIO_CONNECT *data; |
| 411 | 385 | ||
| @@ -423,10 +397,7 @@ BIO *a; | |||
| 423 | return(1); | 397 | return(1); |
| 424 | } | 398 | } |
| 425 | 399 | ||
| 426 | static int conn_read(b,out,outl) | 400 | static int conn_read(BIO *b, char *out, int outl) |
| 427 | BIO *b; | ||
| 428 | char *out; | ||
| 429 | int outl; | ||
| 430 | { | 401 | { |
| 431 | int ret=0; | 402 | int ret=0; |
| 432 | BIO_CONNECT *data; | 403 | BIO_CONNECT *data; |
| @@ -442,11 +413,7 @@ int outl; | |||
| 442 | if (out != NULL) | 413 | if (out != NULL) |
| 443 | { | 414 | { |
| 444 | clear_socket_error(); | 415 | clear_socket_error(); |
| 445 | #if defined(WINDOWS) | 416 | ret=readsocket(b->num,out,outl); |
| 446 | ret=recv(b->num,out,outl,0); | ||
| 447 | #else | ||
| 448 | ret=read(b->num,out,outl); | ||
| 449 | #endif | ||
| 450 | BIO_clear_retry_flags(b); | 417 | BIO_clear_retry_flags(b); |
| 451 | if (ret <= 0) | 418 | if (ret <= 0) |
| 452 | { | 419 | { |
| @@ -457,10 +424,7 @@ int outl; | |||
| 457 | return(ret); | 424 | return(ret); |
| 458 | } | 425 | } |
| 459 | 426 | ||
| 460 | static int conn_write(b,in,inl) | 427 | static int conn_write(BIO *b, char *in, int inl) |
| 461 | BIO *b; | ||
| 462 | char *in; | ||
| 463 | int inl; | ||
| 464 | { | 428 | { |
| 465 | int ret; | 429 | int ret; |
| 466 | BIO_CONNECT *data; | 430 | BIO_CONNECT *data; |
| @@ -473,11 +437,7 @@ int inl; | |||
| 473 | } | 437 | } |
| 474 | 438 | ||
| 475 | clear_socket_error(); | 439 | clear_socket_error(); |
| 476 | #if defined(WINDOWS) | 440 | ret=writesocket(b->num,in,inl); |
| 477 | ret=send(b->num,in,inl,0); | ||
| 478 | #else | ||
| 479 | ret=write(b->num,in,inl); | ||
| 480 | #endif | ||
| 481 | BIO_clear_retry_flags(b); | 441 | BIO_clear_retry_flags(b); |
| 482 | if (ret <= 0) | 442 | if (ret <= 0) |
| 483 | { | 443 | { |
| @@ -487,15 +447,11 @@ int inl; | |||
| 487 | return(ret); | 447 | return(ret); |
| 488 | } | 448 | } |
| 489 | 449 | ||
| 490 | static long conn_ctrl(b,cmd,num,ptr) | 450 | static long conn_ctrl(BIO *b, int cmd, long num, char *ptr) |
| 491 | BIO *b; | ||
| 492 | int cmd; | ||
| 493 | long num; | ||
| 494 | char *ptr; | ||
| 495 | { | 451 | { |
| 496 | BIO *dbio; | 452 | BIO *dbio; |
| 497 | int *ip; | 453 | int *ip; |
| 498 | char **pptr; | 454 | const char **pptr; |
| 499 | long ret=1; | 455 | long ret=1; |
| 500 | BIO_CONNECT *data; | 456 | BIO_CONNECT *data; |
| 501 | 457 | ||
| @@ -519,7 +475,7 @@ char *ptr; | |||
| 519 | case BIO_C_GET_CONNECT: | 475 | case BIO_C_GET_CONNECT: |
| 520 | if (ptr != NULL) | 476 | if (ptr != NULL) |
| 521 | { | 477 | { |
| 522 | pptr=(char **)ptr; | 478 | pptr=(const char **)ptr; |
| 523 | if (num == 0) | 479 | if (num == 0) |
| 524 | { | 480 | { |
| 525 | *pptr=data->param_hostname; | 481 | *pptr=data->param_hostname; |
| @@ -559,9 +515,26 @@ char *ptr; | |||
| 559 | data->param_port=BUF_strdup(ptr); | 515 | data->param_port=BUF_strdup(ptr); |
| 560 | } | 516 | } |
| 561 | else if (num == 2) | 517 | else if (num == 2) |
| 562 | memcpy(data->ip,ptr,4); | 518 | { |
| 519 | char buf[16]; | ||
| 520 | |||
| 521 | sprintf(buf,"%d.%d.%d.%d", | ||
| 522 | ptr[0],ptr[1],ptr[2],ptr[3]); | ||
| 523 | if (data->param_hostname != NULL) | ||
| 524 | Free(data->param_hostname); | ||
| 525 | data->param_hostname=BUF_strdup(buf); | ||
| 526 | memcpy(&(data->ip[0]),ptr,4); | ||
| 527 | } | ||
| 563 | else if (num == 3) | 528 | else if (num == 3) |
| 529 | { | ||
| 530 | char buf[16]; | ||
| 531 | |||
| 532 | sprintf(buf,"%d",*(int *)ptr); | ||
| 533 | if (data->param_port != NULL) | ||
| 534 | Free(data->param_port); | ||
| 535 | data->param_port=BUF_strdup(buf); | ||
| 564 | data->port= *(int *)ptr; | 536 | data->port= *(int *)ptr; |
| 537 | } | ||
| 565 | } | 538 | } |
| 566 | break; | 539 | break; |
| 567 | case BIO_C_SET_NBIO: | 540 | case BIO_C_SET_NBIO: |
| @@ -597,7 +570,7 @@ char *ptr; | |||
| 597 | if (data->param_hostname) | 570 | if (data->param_hostname) |
| 598 | BIO_set_conn_hostname(dbio,data->param_hostname); | 571 | BIO_set_conn_hostname(dbio,data->param_hostname); |
| 599 | BIO_set_nbio(dbio,data->nbio); | 572 | BIO_set_nbio(dbio,data->nbio); |
| 600 | BIO_set_info_callback(dbio,data->info_callback); | 573 | (void)BIO_set_info_callback(dbio,data->info_callback); |
| 601 | break; | 574 | break; |
| 602 | case BIO_CTRL_SET_CALLBACK: | 575 | case BIO_CTRL_SET_CALLBACK: |
| 603 | data->info_callback=(int (*)())ptr; | 576 | data->info_callback=(int (*)())ptr; |
| @@ -617,9 +590,7 @@ char *ptr; | |||
| 617 | return(ret); | 590 | return(ret); |
| 618 | } | 591 | } |
| 619 | 592 | ||
| 620 | static int conn_puts(bp,str) | 593 | static int conn_puts(BIO *bp, char *str) |
| 621 | BIO *bp; | ||
| 622 | char *str; | ||
| 623 | { | 594 | { |
| 624 | int n,ret; | 595 | int n,ret; |
| 625 | 596 | ||
| @@ -628,8 +599,7 @@ char *str; | |||
| 628 | return(ret); | 599 | return(ret); |
| 629 | } | 600 | } |
| 630 | 601 | ||
| 631 | BIO *BIO_new_connect(str) | 602 | BIO *BIO_new_connect(char *str) |
| 632 | char *str; | ||
| 633 | { | 603 | { |
| 634 | BIO *ret; | 604 | BIO *ret; |
| 635 | 605 | ||
diff --git a/src/lib/libcrypto/bio/bss_file.c b/src/lib/libcrypto/bio/bss_file.c index 1484cf849e..52c0c39df0 100644 --- a/src/lib/libcrypto/bio/bss_file.c +++ b/src/lib/libcrypto/bio/bss_file.c | |||
| @@ -68,12 +68,11 @@ | |||
| 68 | #include <stdio.h> | 68 | #include <stdio.h> |
| 69 | #include <errno.h> | 69 | #include <errno.h> |
| 70 | #include "cryptlib.h" | 70 | #include "cryptlib.h" |
| 71 | #include "bio.h" | 71 | #include <openssl/bio.h> |
| 72 | #include "err.h" | 72 | #include <openssl/err.h> |
| 73 | 73 | ||
| 74 | #if !defined(NO_STDIO) | 74 | #if !defined(NO_STDIO) |
| 75 | 75 | ||
| 76 | #ifndef NOPROTO | ||
| 77 | static int MS_CALLBACK file_write(BIO *h,char *buf,int num); | 76 | static int MS_CALLBACK file_write(BIO *h,char *buf,int num); |
| 78 | static int MS_CALLBACK file_read(BIO *h,char *buf,int size); | 77 | static int MS_CALLBACK file_read(BIO *h,char *buf,int size); |
| 79 | static int MS_CALLBACK file_puts(BIO *h,char *str); | 78 | static int MS_CALLBACK file_puts(BIO *h,char *str); |
| @@ -81,16 +80,6 @@ static int MS_CALLBACK file_gets(BIO *h,char *str,int size); | |||
| 81 | static long MS_CALLBACK file_ctrl(BIO *h,int cmd,long arg1,char *arg2); | 80 | static long MS_CALLBACK file_ctrl(BIO *h,int cmd,long arg1,char *arg2); |
| 82 | static int MS_CALLBACK file_new(BIO *h); | 81 | static int MS_CALLBACK file_new(BIO *h); |
| 83 | static int MS_CALLBACK file_free(BIO *data); | 82 | static int MS_CALLBACK file_free(BIO *data); |
| 84 | #else | ||
| 85 | static int MS_CALLBACK file_write(); | ||
| 86 | static int MS_CALLBACK file_read(); | ||
| 87 | static int MS_CALLBACK file_puts(); | ||
| 88 | static int MS_CALLBACK file_gets(); | ||
| 89 | static long MS_CALLBACK file_ctrl(); | ||
| 90 | static int MS_CALLBACK file_new(); | ||
| 91 | static int MS_CALLBACK file_free(); | ||
| 92 | #endif | ||
| 93 | |||
| 94 | static BIO_METHOD methods_filep= | 83 | static BIO_METHOD methods_filep= |
| 95 | { | 84 | { |
| 96 | BIO_TYPE_FILE, | 85 | BIO_TYPE_FILE, |
| @@ -104,9 +93,7 @@ static BIO_METHOD methods_filep= | |||
| 104 | file_free, | 93 | file_free, |
| 105 | }; | 94 | }; |
| 106 | 95 | ||
| 107 | BIO *BIO_new_file(filename,mode) | 96 | BIO *BIO_new_file(const char *filename, const char *mode) |
| 108 | char *filename; | ||
| 109 | char *mode; | ||
| 110 | { | 97 | { |
| 111 | BIO *ret; | 98 | BIO *ret; |
| 112 | FILE *file; | 99 | FILE *file; |
| @@ -125,9 +112,7 @@ char *mode; | |||
| 125 | return(ret); | 112 | return(ret); |
| 126 | } | 113 | } |
| 127 | 114 | ||
| 128 | BIO *BIO_new_fp(stream,close_flag) | 115 | BIO *BIO_new_fp(FILE *stream, int close_flag) |
| 129 | FILE *stream; | ||
| 130 | int close_flag; | ||
| 131 | { | 116 | { |
| 132 | BIO *ret; | 117 | BIO *ret; |
| 133 | 118 | ||
| @@ -138,13 +123,12 @@ int close_flag; | |||
| 138 | return(ret); | 123 | return(ret); |
| 139 | } | 124 | } |
| 140 | 125 | ||
| 141 | BIO_METHOD *BIO_s_file() | 126 | BIO_METHOD *BIO_s_file(void) |
| 142 | { | 127 | { |
| 143 | return(&methods_filep); | 128 | return(&methods_filep); |
| 144 | } | 129 | } |
| 145 | 130 | ||
| 146 | static int MS_CALLBACK file_new(bi) | 131 | static int MS_CALLBACK file_new(BIO *bi) |
| 147 | BIO *bi; | ||
| 148 | { | 132 | { |
| 149 | bi->init=0; | 133 | bi->init=0; |
| 150 | bi->num=0; | 134 | bi->num=0; |
| @@ -152,8 +136,7 @@ BIO *bi; | |||
| 152 | return(1); | 136 | return(1); |
| 153 | } | 137 | } |
| 154 | 138 | ||
| 155 | static int MS_CALLBACK file_free(a) | 139 | static int MS_CALLBACK file_free(BIO *a) |
| 156 | BIO *a; | ||
| 157 | { | 140 | { |
| 158 | if (a == NULL) return(0); | 141 | if (a == NULL) return(0); |
| 159 | if (a->shutdown) | 142 | if (a->shutdown) |
| @@ -168,10 +151,7 @@ BIO *a; | |||
| 168 | return(1); | 151 | return(1); |
| 169 | } | 152 | } |
| 170 | 153 | ||
| 171 | static int MS_CALLBACK file_read(b,out,outl) | 154 | static int MS_CALLBACK file_read(BIO *b, char *out, int outl) |
| 172 | BIO *b; | ||
| 173 | char *out; | ||
| 174 | int outl; | ||
| 175 | { | 155 | { |
| 176 | int ret=0; | 156 | int ret=0; |
| 177 | 157 | ||
| @@ -182,10 +162,7 @@ int outl; | |||
| 182 | return(ret); | 162 | return(ret); |
| 183 | } | 163 | } |
| 184 | 164 | ||
| 185 | static int MS_CALLBACK file_write(b,in,inl) | 165 | static int MS_CALLBACK file_write(BIO *b, char *in, int inl) |
| 186 | BIO *b; | ||
| 187 | char *in; | ||
| 188 | int inl; | ||
| 189 | { | 166 | { |
| 190 | int ret=0; | 167 | int ret=0; |
| 191 | 168 | ||
| @@ -201,11 +178,7 @@ int inl; | |||
| 201 | return(ret); | 178 | return(ret); |
| 202 | } | 179 | } |
| 203 | 180 | ||
| 204 | static long MS_CALLBACK file_ctrl(b,cmd,num,ptr) | 181 | static long MS_CALLBACK file_ctrl(BIO *b, int cmd, long num, char *ptr) |
| 205 | BIO *b; | ||
| 206 | int cmd; | ||
| 207 | long num; | ||
| 208 | char *ptr; | ||
| 209 | { | 182 | { |
| 210 | long ret=1; | 183 | long ret=1; |
| 211 | FILE *fp=(FILE *)b->ptr; | 184 | FILE *fp=(FILE *)b->ptr; |
| @@ -214,18 +187,20 @@ char *ptr; | |||
| 214 | 187 | ||
| 215 | switch (cmd) | 188 | switch (cmd) |
| 216 | { | 189 | { |
| 190 | case BIO_C_FILE_SEEK: | ||
| 217 | case BIO_CTRL_RESET: | 191 | case BIO_CTRL_RESET: |
| 218 | ret=(long)fseek(fp,num,0); | 192 | ret=(long)fseek(fp,num,0); |
| 219 | break; | 193 | break; |
| 220 | case BIO_CTRL_EOF: | 194 | case BIO_CTRL_EOF: |
| 221 | ret=(long)feof(fp); | 195 | ret=(long)feof(fp); |
| 222 | break; | 196 | break; |
| 197 | case BIO_C_FILE_TELL: | ||
| 223 | case BIO_CTRL_INFO: | 198 | case BIO_CTRL_INFO: |
| 224 | ret=ftell(fp); | 199 | ret=ftell(fp); |
| 225 | break; | 200 | break; |
| 226 | case BIO_C_SET_FILE_PTR: | 201 | case BIO_C_SET_FILE_PTR: |
| 227 | file_free(b); | 202 | file_free(b); |
| 228 | b->shutdown=(int)num; | 203 | b->shutdown=(int)num&BIO_CLOSE; |
| 229 | b->ptr=(char *)ptr; | 204 | b->ptr=(char *)ptr; |
| 230 | b->init=1; | 205 | b->init=1; |
| 231 | #if defined(MSDOS) || defined(WINDOWS) | 206 | #if defined(MSDOS) || defined(WINDOWS) |
| @@ -307,10 +282,7 @@ char *ptr; | |||
| 307 | return(ret); | 282 | return(ret); |
| 308 | } | 283 | } |
| 309 | 284 | ||
| 310 | static int MS_CALLBACK file_gets(bp,buf,size) | 285 | static int MS_CALLBACK file_gets(BIO *bp, char *buf, int size) |
| 311 | BIO *bp; | ||
| 312 | char *buf; | ||
| 313 | int size; | ||
| 314 | { | 286 | { |
| 315 | int ret=0; | 287 | int ret=0; |
| 316 | 288 | ||
| @@ -321,9 +293,7 @@ int size; | |||
| 321 | return(ret); | 293 | return(ret); |
| 322 | } | 294 | } |
| 323 | 295 | ||
| 324 | static int MS_CALLBACK file_puts(bp,str) | 296 | static int MS_CALLBACK file_puts(BIO *bp, char *str) |
| 325 | BIO *bp; | ||
| 326 | char *str; | ||
| 327 | { | 297 | { |
| 328 | int n,ret; | 298 | int n,ret; |
| 329 | 299 | ||
diff --git a/src/lib/libcrypto/bio/bss_log.c b/src/lib/libcrypto/bio/bss_log.c new file mode 100644 index 0000000000..db82e757e7 --- /dev/null +++ b/src/lib/libcrypto/bio/bss_log.c | |||
| @@ -0,0 +1,232 @@ | |||
| 1 | /* crypto/bio/bss_log.c */ | ||
| 2 | /* ==================================================================== | ||
| 3 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | ||
| 4 | * | ||
| 5 | * Redistribution and use in source and binary forms, with or without | ||
| 6 | * modification, are permitted provided that the following conditions | ||
| 7 | * are met: | ||
| 8 | * | ||
| 9 | * 1. Redistributions of source code must retain the above copyright | ||
| 10 | * notice, this list of conditions and the following disclaimer. | ||
| 11 | * | ||
| 12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 13 | * notice, this list of conditions and the following disclaimer in | ||
| 14 | * the documentation and/or other materials provided with the | ||
| 15 | * distribution. | ||
| 16 | * | ||
| 17 | * 3. All advertising materials mentioning features or use of this | ||
| 18 | * software must display the following acknowledgment: | ||
| 19 | * "This product includes software developed by the OpenSSL Project | ||
| 20 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
| 21 | * | ||
| 22 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 23 | * endorse or promote products derived from this software without | ||
| 24 | * prior written permission. For written permission, please contact | ||
| 25 | * licensing@OpenSSL.org. | ||
| 26 | * | ||
| 27 | * 5. Products derived from this software may not be called "OpenSSL" | ||
| 28 | * nor may "OpenSSL" appear in their names without prior written | ||
| 29 | * permission of the OpenSSL Project. | ||
| 30 | * | ||
| 31 | * 6. Redistributions of any form whatsoever must retain the following | ||
| 32 | * acknowledgment: | ||
| 33 | * "This product includes software developed by the OpenSSL Project | ||
| 34 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
| 35 | * | ||
| 36 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 37 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 38 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 39 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 40 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 41 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 42 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 43 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 44 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 45 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 46 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 47 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 48 | * ==================================================================== | ||
| 49 | * | ||
| 50 | * This product includes cryptographic software written by Eric Young | ||
| 51 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
| 52 | * Hudson (tjh@cryptsoft.com). | ||
| 53 | * | ||
| 54 | */ | ||
| 55 | |||
| 56 | /* | ||
| 57 | Why BIO_s_log? | ||
| 58 | |||
| 59 | BIO_s_log is useful for system daemons (or services under NT). | ||
| 60 | It is one-way BIO, it sends all stuff to syslogd (or event log | ||
| 61 | under NT). | ||
| 62 | |||
| 63 | */ | ||
| 64 | |||
| 65 | |||
| 66 | #include <stdio.h> | ||
| 67 | #include <errno.h> | ||
| 68 | |||
| 69 | #ifndef WIN32 | ||
| 70 | #ifdef __ultrix | ||
| 71 | #include <sys/syslog.h> | ||
| 72 | #else | ||
| 73 | #include <syslog.h> | ||
| 74 | #endif | ||
| 75 | #endif | ||
| 76 | |||
| 77 | #include "cryptlib.h" | ||
| 78 | #include <openssl/buffer.h> | ||
| 79 | #include <openssl/err.h> | ||
| 80 | #ifndef NO_SYSLOG | ||
| 81 | |||
| 82 | |||
| 83 | static int MS_CALLBACK slg_write(BIO *h,char *buf,int num); | ||
| 84 | static int MS_CALLBACK slg_puts(BIO *h,char *str); | ||
| 85 | static long MS_CALLBACK slg_ctrl(BIO *h,int cmd,long arg1,char *arg2); | ||
| 86 | static int MS_CALLBACK slg_new(BIO *h); | ||
| 87 | static int MS_CALLBACK slg_free(BIO *data); | ||
| 88 | static int xopenlog(BIO* bp, const char* name, int level); | ||
| 89 | static int xcloselog(BIO* bp); | ||
| 90 | |||
| 91 | static BIO_METHOD methods_slg= | ||
| 92 | { | ||
| 93 | BIO_TYPE_MEM,"syslog", | ||
| 94 | slg_write, | ||
| 95 | NULL, | ||
| 96 | slg_puts, | ||
| 97 | NULL, | ||
| 98 | slg_ctrl, | ||
| 99 | slg_new, | ||
| 100 | slg_free, | ||
| 101 | }; | ||
| 102 | |||
| 103 | BIO_METHOD *BIO_s_log(void) | ||
| 104 | { | ||
| 105 | return(&methods_slg); | ||
| 106 | } | ||
| 107 | |||
| 108 | static int MS_CALLBACK slg_new(BIO *bi) | ||
| 109 | { | ||
| 110 | bi->init=1; | ||
| 111 | bi->num=0; | ||
| 112 | bi->ptr=NULL; | ||
| 113 | #ifndef WIN32 | ||
| 114 | xopenlog(bi, "application", LOG_DAEMON); | ||
| 115 | #else | ||
| 116 | xopenlog(bi, "application", 0); | ||
| 117 | #endif | ||
| 118 | return(1); | ||
| 119 | } | ||
| 120 | |||
| 121 | static int MS_CALLBACK slg_free(BIO *a) | ||
| 122 | { | ||
| 123 | if (a == NULL) return(0); | ||
| 124 | xcloselog(a); | ||
| 125 | return(1); | ||
| 126 | } | ||
| 127 | |||
| 128 | static int MS_CALLBACK slg_write(BIO *b, char *in, int inl) | ||
| 129 | { | ||
| 130 | int ret= inl; | ||
| 131 | char* buf= in; | ||
| 132 | char* pp; | ||
| 133 | #if defined(WIN32) | ||
| 134 | LPTSTR lpszStrings[1]; | ||
| 135 | WORD evtype= EVENTLOG_ERROR_TYPE; | ||
| 136 | #else | ||
| 137 | int priority; | ||
| 138 | #endif | ||
| 139 | |||
| 140 | if((buf= (char *)Malloc(inl+ 1)) == NULL){ | ||
| 141 | return(0); | ||
| 142 | } | ||
| 143 | strncpy(buf, in, inl); | ||
| 144 | buf[inl]= '\0'; | ||
| 145 | #if defined(WIN32) | ||
| 146 | if(strncmp(buf, "ERR ", 4) == 0){ | ||
| 147 | evtype= EVENTLOG_ERROR_TYPE; | ||
| 148 | pp= buf+ 4; | ||
| 149 | }else if(strncmp(buf, "WAR ", 4) == 0){ | ||
| 150 | evtype= EVENTLOG_WARNING_TYPE; | ||
| 151 | pp= buf+ 4; | ||
| 152 | }else if(strncmp(buf, "INF ", 4) == 0){ | ||
| 153 | evtype= EVENTLOG_INFORMATION_TYPE; | ||
| 154 | pp= buf+ 4; | ||
| 155 | }else{ | ||
| 156 | evtype= EVENTLOG_ERROR_TYPE; | ||
| 157 | pp= buf; | ||
| 158 | } | ||
| 159 | lpszStrings[0]= pp; | ||
| 160 | |||
| 161 | if(b->ptr) | ||
| 162 | ReportEvent(b->ptr, evtype, 0, 1024, NULL, 1, 0, | ||
| 163 | lpszStrings, NULL); | ||
| 164 | #else | ||
| 165 | if(strncmp(buf, "ERR ", 4) == 0){ | ||
| 166 | priority= LOG_ERR; | ||
| 167 | pp= buf+ 4; | ||
| 168 | }else if(strncmp(buf, "WAR ", 4) == 0){ | ||
| 169 | priority= LOG_WARNING; | ||
| 170 | pp= buf+ 4; | ||
| 171 | }else if(strncmp(buf, "INF ", 4) == 0){ | ||
| 172 | priority= LOG_INFO; | ||
| 173 | pp= buf+ 4; | ||
| 174 | }else{ | ||
| 175 | priority= LOG_ERR; | ||
| 176 | pp= buf; | ||
| 177 | } | ||
| 178 | |||
| 179 | syslog(priority, "%s", pp); | ||
| 180 | #endif | ||
| 181 | Free(buf); | ||
| 182 | return(ret); | ||
| 183 | } | ||
| 184 | |||
| 185 | static long MS_CALLBACK slg_ctrl(BIO *b, int cmd, long num, char *ptr) | ||
| 186 | { | ||
| 187 | switch (cmd) | ||
| 188 | { | ||
| 189 | case BIO_CTRL_SET: | ||
| 190 | xcloselog(b); | ||
| 191 | xopenlog(b, ptr, num); | ||
| 192 | break; | ||
| 193 | default: | ||
| 194 | break; | ||
| 195 | } | ||
| 196 | return(0); | ||
| 197 | } | ||
| 198 | |||
| 199 | static int MS_CALLBACK slg_puts(BIO *bp, char *str) | ||
| 200 | { | ||
| 201 | int n,ret; | ||
| 202 | |||
| 203 | n=strlen(str); | ||
| 204 | ret=slg_write(bp,str,n); | ||
| 205 | return(ret); | ||
| 206 | } | ||
| 207 | |||
| 208 | static int xopenlog(BIO* bp, const char* name, int level) | ||
| 209 | { | ||
| 210 | #if defined(WIN32) | ||
| 211 | if((bp->ptr= (char *)RegisterEventSource(NULL, name)) == NULL){ | ||
| 212 | return(0); | ||
| 213 | } | ||
| 214 | #else | ||
| 215 | openlog(name, LOG_PID|LOG_CONS, level); | ||
| 216 | #endif | ||
| 217 | return(1); | ||
| 218 | } | ||
| 219 | |||
| 220 | static int xcloselog(BIO* bp) | ||
| 221 | { | ||
| 222 | #if defined(WIN32) | ||
| 223 | if(bp->ptr) | ||
| 224 | DeregisterEventSource((HANDLE)(bp->ptr)); | ||
| 225 | bp->ptr= NULL; | ||
| 226 | #else | ||
| 227 | closelog(); | ||
| 228 | #endif | ||
| 229 | return(1); | ||
| 230 | } | ||
| 231 | |||
| 232 | #endif | ||
diff --git a/src/lib/libcrypto/bio/bss_mem.c b/src/lib/libcrypto/bio/bss_mem.c index 40c4e39f02..7e749a503e 100644 --- a/src/lib/libcrypto/bio/bss_mem.c +++ b/src/lib/libcrypto/bio/bss_mem.c | |||
| @@ -59,9 +59,8 @@ | |||
| 59 | #include <stdio.h> | 59 | #include <stdio.h> |
| 60 | #include <errno.h> | 60 | #include <errno.h> |
| 61 | #include "cryptlib.h" | 61 | #include "cryptlib.h" |
| 62 | #include "bio.h" | 62 | #include <openssl/bio.h> |
| 63 | 63 | ||
| 64 | #ifndef NOPROTO | ||
| 65 | static int mem_write(BIO *h,char *buf,int num); | 64 | static int mem_write(BIO *h,char *buf,int num); |
| 66 | static int mem_read(BIO *h,char *buf,int size); | 65 | static int mem_read(BIO *h,char *buf,int size); |
| 67 | static int mem_puts(BIO *h,char *str); | 66 | static int mem_puts(BIO *h,char *str); |
| @@ -69,16 +68,6 @@ static int mem_gets(BIO *h,char *str,int size); | |||
| 69 | static long mem_ctrl(BIO *h,int cmd,long arg1,char *arg2); | 68 | static long mem_ctrl(BIO *h,int cmd,long arg1,char *arg2); |
| 70 | static int mem_new(BIO *h); | 69 | static int mem_new(BIO *h); |
| 71 | static int mem_free(BIO *data); | 70 | static int mem_free(BIO *data); |
| 72 | #else | ||
| 73 | static int mem_write(); | ||
| 74 | static int mem_read(); | ||
| 75 | static int mem_puts(); | ||
| 76 | static int mem_gets(); | ||
| 77 | static long mem_ctrl(); | ||
| 78 | static int mem_new(); | ||
| 79 | static int mem_free(); | ||
| 80 | #endif | ||
| 81 | |||
| 82 | static BIO_METHOD mem_method= | 71 | static BIO_METHOD mem_method= |
| 83 | { | 72 | { |
| 84 | BIO_TYPE_MEM, | 73 | BIO_TYPE_MEM, |
| @@ -92,13 +81,15 @@ static BIO_METHOD mem_method= | |||
| 92 | mem_free, | 81 | mem_free, |
| 93 | }; | 82 | }; |
| 94 | 83 | ||
| 95 | BIO_METHOD *BIO_s_mem() | 84 | /* bio->num is used to hold the value to return on 'empty', if it is |
| 85 | * 0, should_retry is not set */ | ||
| 86 | |||
| 87 | BIO_METHOD *BIO_s_mem(void) | ||
| 96 | { | 88 | { |
| 97 | return(&mem_method); | 89 | return(&mem_method); |
| 98 | } | 90 | } |
| 99 | 91 | ||
| 100 | static int mem_new(bi) | 92 | static int mem_new(BIO *bi) |
| 101 | BIO *bi; | ||
| 102 | { | 93 | { |
| 103 | BUF_MEM *b; | 94 | BUF_MEM *b; |
| 104 | 95 | ||
| @@ -106,13 +97,12 @@ BIO *bi; | |||
| 106 | return(0); | 97 | return(0); |
| 107 | bi->shutdown=1; | 98 | bi->shutdown=1; |
| 108 | bi->init=1; | 99 | bi->init=1; |
| 109 | bi->num=0; | 100 | bi->num= -1; |
| 110 | bi->ptr=(char *)b; | 101 | bi->ptr=(char *)b; |
| 111 | return(1); | 102 | return(1); |
| 112 | } | 103 | } |
| 113 | 104 | ||
| 114 | static int mem_free(a) | 105 | static int mem_free(BIO *a) |
| 115 | BIO *a; | ||
| 116 | { | 106 | { |
| 117 | if (a == NULL) return(0); | 107 | if (a == NULL) return(0); |
| 118 | if (a->shutdown) | 108 | if (a->shutdown) |
| @@ -126,10 +116,7 @@ BIO *a; | |||
| 126 | return(1); | 116 | return(1); |
| 127 | } | 117 | } |
| 128 | 118 | ||
| 129 | static int mem_read(b,out,outl) | 119 | static int mem_read(BIO *b, char *out, int outl) |
| 130 | BIO *b; | ||
| 131 | char *out; | ||
| 132 | int outl; | ||
| 133 | { | 120 | { |
| 134 | int ret= -1; | 121 | int ret= -1; |
| 135 | BUF_MEM *bm; | 122 | BUF_MEM *bm; |
| @@ -151,16 +138,14 @@ int outl; | |||
| 151 | } | 138 | } |
| 152 | else if (bm->length == 0) | 139 | else if (bm->length == 0) |
| 153 | { | 140 | { |
| 154 | BIO_set_retry_read(b); | 141 | if (b->num != 0) |
| 155 | ret= -1; | 142 | BIO_set_retry_read(b); |
| 143 | ret= b->num; | ||
| 156 | } | 144 | } |
| 157 | return(ret); | 145 | return(ret); |
| 158 | } | 146 | } |
| 159 | 147 | ||
| 160 | static int mem_write(b,in,inl) | 148 | static int mem_write(BIO *b, char *in, int inl) |
| 161 | BIO *b; | ||
| 162 | char *in; | ||
| 163 | int inl; | ||
| 164 | { | 149 | { |
| 165 | int ret= -1; | 150 | int ret= -1; |
| 166 | int blen; | 151 | int blen; |
| @@ -183,11 +168,7 @@ end: | |||
| 183 | return(ret); | 168 | return(ret); |
| 184 | } | 169 | } |
| 185 | 170 | ||
| 186 | static long mem_ctrl(b,cmd,num,ptr) | 171 | static long mem_ctrl(BIO *b, int cmd, long num, char *ptr) |
| 187 | BIO *b; | ||
| 188 | int cmd; | ||
| 189 | long num; | ||
| 190 | char *ptr; | ||
| 191 | { | 172 | { |
| 192 | long ret=1; | 173 | long ret=1; |
| 193 | char **pptr; | 174 | char **pptr; |
| @@ -204,6 +185,9 @@ char *ptr; | |||
| 204 | case BIO_CTRL_EOF: | 185 | case BIO_CTRL_EOF: |
| 205 | ret=(long)(bm->length == 0); | 186 | ret=(long)(bm->length == 0); |
| 206 | break; | 187 | break; |
| 188 | case BIO_C_SET_BUF_MEM_EOF_RETURN: | ||
| 189 | b->num=(int)num; | ||
| 190 | break; | ||
| 207 | case BIO_CTRL_INFO: | 191 | case BIO_CTRL_INFO: |
| 208 | ret=(long)bm->length; | 192 | ret=(long)bm->length; |
| 209 | if (ptr != NULL) | 193 | if (ptr != NULL) |
| @@ -250,10 +234,7 @@ char *ptr; | |||
| 250 | return(ret); | 234 | return(ret); |
| 251 | } | 235 | } |
| 252 | 236 | ||
| 253 | static int mem_gets(bp,buf,size) | 237 | static int mem_gets(BIO *bp, char *buf, int size) |
| 254 | BIO *bp; | ||
| 255 | char *buf; | ||
| 256 | int size; | ||
| 257 | { | 238 | { |
| 258 | int i,j; | 239 | int i,j; |
| 259 | int ret= -1; | 240 | int ret= -1; |
| @@ -283,9 +264,7 @@ int size; | |||
| 283 | return(ret); | 264 | return(ret); |
| 284 | } | 265 | } |
| 285 | 266 | ||
| 286 | static int mem_puts(bp,str) | 267 | static int mem_puts(BIO *bp, char *str) |
| 287 | BIO *bp; | ||
| 288 | char *str; | ||
| 289 | { | 268 | { |
| 290 | int n,ret; | 269 | int n,ret; |
| 291 | 270 | ||
diff --git a/src/lib/libcrypto/bio/bss_null.c b/src/lib/libcrypto/bio/bss_null.c index 0791a2471a..d04be888e5 100644 --- a/src/lib/libcrypto/bio/bss_null.c +++ b/src/lib/libcrypto/bio/bss_null.c | |||
| @@ -59,9 +59,8 @@ | |||
| 59 | #include <stdio.h> | 59 | #include <stdio.h> |
| 60 | #include <errno.h> | 60 | #include <errno.h> |
| 61 | #include "cryptlib.h" | 61 | #include "cryptlib.h" |
| 62 | #include "bio.h" | 62 | #include <openssl/bio.h> |
| 63 | 63 | ||
| 64 | #ifndef NOPROTO | ||
| 65 | static int null_write(BIO *h,char *buf,int num); | 64 | static int null_write(BIO *h,char *buf,int num); |
| 66 | static int null_read(BIO *h,char *buf,int size); | 65 | static int null_read(BIO *h,char *buf,int size); |
| 67 | static int null_puts(BIO *h,char *str); | 66 | static int null_puts(BIO *h,char *str); |
| @@ -69,16 +68,6 @@ static int null_gets(BIO *h,char *str,int size); | |||
| 69 | static long null_ctrl(BIO *h,int cmd,long arg1,char *arg2); | 68 | static long null_ctrl(BIO *h,int cmd,long arg1,char *arg2); |
| 70 | static int null_new(BIO *h); | 69 | static int null_new(BIO *h); |
| 71 | static int null_free(BIO *data); | 70 | static int null_free(BIO *data); |
| 72 | #else | ||
| 73 | static int null_write(); | ||
| 74 | static int null_read(); | ||
| 75 | static int null_puts(); | ||
| 76 | static int null_gets(); | ||
| 77 | static long null_ctrl(); | ||
| 78 | static int null_new(); | ||
| 79 | static int null_free(); | ||
| 80 | #endif | ||
| 81 | |||
| 82 | static BIO_METHOD null_method= | 71 | static BIO_METHOD null_method= |
| 83 | { | 72 | { |
| 84 | BIO_TYPE_NULL, | 73 | BIO_TYPE_NULL, |
| @@ -92,13 +81,12 @@ static BIO_METHOD null_method= | |||
| 92 | null_free, | 81 | null_free, |
| 93 | }; | 82 | }; |
| 94 | 83 | ||
| 95 | BIO_METHOD *BIO_s_null() | 84 | BIO_METHOD *BIO_s_null(void) |
| 96 | { | 85 | { |
| 97 | return(&null_method); | 86 | return(&null_method); |
| 98 | } | 87 | } |
| 99 | 88 | ||
| 100 | static int null_new(bi) | 89 | static int null_new(BIO *bi) |
| 101 | BIO *bi; | ||
| 102 | { | 90 | { |
| 103 | bi->init=1; | 91 | bi->init=1; |
| 104 | bi->num=0; | 92 | bi->num=0; |
| @@ -106,34 +94,23 @@ BIO *bi; | |||
| 106 | return(1); | 94 | return(1); |
| 107 | } | 95 | } |
| 108 | 96 | ||
| 109 | static int null_free(a) | 97 | static int null_free(BIO *a) |
| 110 | BIO *a; | ||
| 111 | { | 98 | { |
| 112 | if (a == NULL) return(0); | 99 | if (a == NULL) return(0); |
| 113 | return(1); | 100 | return(1); |
| 114 | } | 101 | } |
| 115 | 102 | ||
| 116 | static int null_read(b,out,outl) | 103 | static int null_read(BIO *b, char *out, int outl) |
| 117 | BIO *b; | ||
| 118 | char *out; | ||
| 119 | int outl; | ||
| 120 | { | 104 | { |
| 121 | return(0); | 105 | return(0); |
| 122 | } | 106 | } |
| 123 | 107 | ||
| 124 | static int null_write(b,in,inl) | 108 | static int null_write(BIO *b, char *in, int inl) |
| 125 | BIO *b; | ||
| 126 | char *in; | ||
| 127 | int inl; | ||
| 128 | { | 109 | { |
| 129 | return(inl); | 110 | return(inl); |
| 130 | } | 111 | } |
| 131 | 112 | ||
| 132 | static long null_ctrl(b,cmd,num,ptr) | 113 | static long null_ctrl(BIO *b, int cmd, long num, char *ptr) |
| 133 | BIO *b; | ||
| 134 | int cmd; | ||
| 135 | long num; | ||
| 136 | char *ptr; | ||
| 137 | { | 114 | { |
| 138 | long ret=1; | 115 | long ret=1; |
| 139 | 116 | ||
| @@ -159,17 +136,12 @@ char *ptr; | |||
| 159 | return(ret); | 136 | return(ret); |
| 160 | } | 137 | } |
| 161 | 138 | ||
| 162 | static int null_gets(bp,buf,size) | 139 | static int null_gets(BIO *bp, char *buf, int size) |
| 163 | BIO *bp; | ||
| 164 | char *buf; | ||
| 165 | int size; | ||
| 166 | { | 140 | { |
| 167 | return(0); | 141 | return(0); |
| 168 | } | 142 | } |
| 169 | 143 | ||
| 170 | static int null_puts(bp,str) | 144 | static int null_puts(BIO *bp, char *str) |
| 171 | BIO *bp; | ||
| 172 | char *str; | ||
| 173 | { | 145 | { |
| 174 | if (str == NULL) return(0); | 146 | if (str == NULL) return(0); |
| 175 | return(strlen(str)); | 147 | return(strlen(str)); |
diff --git a/src/lib/libcrypto/bio/bss_rtcp.c b/src/lib/libcrypto/bio/bss_rtcp.c index 6eb434dee8..2ef040057e 100644 --- a/src/lib/libcrypto/bio/bss_rtcp.c +++ b/src/lib/libcrypto/bio/bss_rtcp.c | |||
| @@ -58,6 +58,7 @@ | |||
| 58 | 58 | ||
| 59 | /* Written by David L. Jones <jonesd@kcgl1.eng.ohio-state.edu> | 59 | /* Written by David L. Jones <jonesd@kcgl1.eng.ohio-state.edu> |
| 60 | * Date: 22-JUL-1996 | 60 | * Date: 22-JUL-1996 |
| 61 | * Revised: 25-SEP-1997 Update for 0.8.1, BIO_CTRL_SET -> BIO_C_SET_FD | ||
| 61 | */ | 62 | */ |
| 62 | /* VMS */ | 63 | /* VMS */ |
| 63 | #include <stdio.h> | 64 | #include <stdio.h> |
| @@ -65,10 +66,11 @@ | |||
| 65 | #include <string.h> | 66 | #include <string.h> |
| 66 | #include <errno.h> | 67 | #include <errno.h> |
| 67 | #include "cryptlib.h" | 68 | #include "cryptlib.h" |
| 68 | #include "bio.h" | 69 | #include <openssl/bio.h> |
| 69 | 70 | ||
| 70 | #include <iodef.h> /* VMS IO$_ definitions */ | 71 | #include <iodef.h> /* VMS IO$_ definitions */ |
| 71 | extern int SYS$QIOW(); | 72 | #include <starlet.h> |
| 73 | |||
| 72 | typedef unsigned short io_channel; | 74 | typedef unsigned short io_channel; |
| 73 | /*************************************************************************/ | 75 | /*************************************************************************/ |
| 74 | struct io_status { short status, count; long flags; }; | 76 | struct io_status { short status, count; long flags; }; |
| @@ -107,18 +109,24 @@ static BIO_METHOD rtcp_method= | |||
| 107 | rtcp_free, | 109 | rtcp_free, |
| 108 | }; | 110 | }; |
| 109 | 111 | ||
| 110 | BIO_METHOD *BIO_s_rtcp() | 112 | BIO_METHOD *BIO_s_rtcp(void) |
| 111 | { | 113 | { |
| 112 | return(&rtcp_method); | 114 | return(&rtcp_method); |
| 113 | } | 115 | } |
| 114 | /*****************************************************************************/ | 116 | /*****************************************************************************/ |
| 115 | /* Decnet I/O routines. | 117 | /* Decnet I/O routines. |
| 116 | */ | 118 | */ |
| 119 | |||
| 120 | #ifdef __DECC | ||
| 121 | #pragma message save | ||
| 122 | #pragma message disable DOLLARID | ||
| 123 | #endif | ||
| 124 | |||
| 117 | static int get ( io_channel chan, char *buffer, int maxlen, int *length ) | 125 | static int get ( io_channel chan, char *buffer, int maxlen, int *length ) |
| 118 | { | 126 | { |
| 119 | int status; | 127 | int status; |
| 120 | struct io_status iosb; | 128 | struct io_status iosb; |
| 121 | status = SYS$QIOW ( 0, chan, IO$_READVBLK, &iosb, 0, 0, | 129 | status = sys$qiow ( 0, chan, IO$_READVBLK, &iosb, 0, 0, |
| 122 | buffer, maxlen, 0, 0, 0, 0 ); | 130 | buffer, maxlen, 0, 0, 0, 0 ); |
| 123 | if ( (status&1) == 1 ) status = iosb.status; | 131 | if ( (status&1) == 1 ) status = iosb.status; |
| 124 | if ( (status&1) == 1 ) *length = iosb.count; | 132 | if ( (status&1) == 1 ) *length = iosb.count; |
| @@ -129,15 +137,19 @@ static int put ( io_channel chan, char *buffer, int length ) | |||
| 129 | { | 137 | { |
| 130 | int status; | 138 | int status; |
| 131 | struct io_status iosb; | 139 | struct io_status iosb; |
| 132 | status = SYS$QIOW ( 0, chan, IO$_WRITEVBLK, &iosb, 0, 0, | 140 | status = sys$qiow ( 0, chan, IO$_WRITEVBLK, &iosb, 0, 0, |
| 133 | buffer, length, 0, 0, 0, 0 ); | 141 | buffer, length, 0, 0, 0, 0 ); |
| 134 | if ( (status&1) == 1 ) status = iosb.status; | 142 | if ( (status&1) == 1 ) status = iosb.status; |
| 135 | return status; | 143 | return status; |
| 136 | } | 144 | } |
| 145 | |||
| 146 | #ifdef __DECC | ||
| 147 | #pragma message restore | ||
| 148 | #endif | ||
| 149 | |||
| 137 | /***************************************************************************/ | 150 | /***************************************************************************/ |
| 138 | 151 | ||
| 139 | static int rtcp_new(bi) | 152 | static int rtcp_new(BIO *bi) |
| 140 | BIO *bi; | ||
| 141 | { | 153 | { |
| 142 | struct rpc_ctx *ctx; | 154 | struct rpc_ctx *ctx; |
| 143 | bi->init=1; | 155 | bi->init=1; |
| @@ -150,8 +162,7 @@ BIO *bi; | |||
| 150 | return(1); | 162 | return(1); |
| 151 | } | 163 | } |
| 152 | 164 | ||
| 153 | static int rtcp_free(a) | 165 | static int rtcp_free(BIO *a) |
| 154 | BIO *a; | ||
| 155 | { | 166 | { |
| 156 | if (a == NULL) return(0); | 167 | if (a == NULL) return(0); |
| 157 | if ( a->ptr ) Free ( a->ptr ); | 168 | if ( a->ptr ) Free ( a->ptr ); |
| @@ -159,10 +170,7 @@ BIO *a; | |||
| 159 | return(1); | 170 | return(1); |
| 160 | } | 171 | } |
| 161 | 172 | ||
| 162 | static int rtcp_read(b,out,outl) | 173 | static int rtcp_read(BIO *b, char *out, int outl) |
| 163 | BIO *b; | ||
| 164 | char *out; | ||
| 165 | int outl; | ||
| 166 | { | 174 | { |
| 167 | int status, length; | 175 | int status, length; |
| 168 | struct rpc_ctx *ctx; | 176 | struct rpc_ctx *ctx; |
| @@ -209,10 +217,7 @@ int outl; | |||
| 209 | return length; | 217 | return length; |
| 210 | } | 218 | } |
| 211 | 219 | ||
| 212 | static int rtcp_write(b,in,inl) | 220 | static int rtcp_write(BIO *b, char *in, int inl) |
| 213 | BIO *b; | ||
| 214 | char *in; | ||
| 215 | int inl; | ||
| 216 | { | 221 | { |
| 217 | int status, i, segment, length; | 222 | int status, i, segment, length; |
| 218 | struct rpc_ctx *ctx; | 223 | struct rpc_ctx *ctx; |
| @@ -241,11 +246,7 @@ int inl; | |||
| 241 | return(i); | 246 | return(i); |
| 242 | } | 247 | } |
| 243 | 248 | ||
| 244 | static long rtcp_ctrl(b,cmd,num,ptr) | 249 | static long rtcp_ctrl(BIO *b, int cmd, long num, char *ptr) |
| 245 | BIO *b; | ||
| 246 | int cmd; | ||
| 247 | long num; | ||
| 248 | char *ptr; | ||
| 249 | { | 250 | { |
| 250 | long ret=1; | 251 | long ret=1; |
| 251 | 252 | ||
| @@ -255,7 +256,7 @@ char *ptr; | |||
| 255 | case BIO_CTRL_EOF: | 256 | case BIO_CTRL_EOF: |
| 256 | ret = 1; | 257 | ret = 1; |
| 257 | break; | 258 | break; |
| 258 | case BIO_CTRL_SET: | 259 | case BIO_C_SET_FD: |
| 259 | b->num = num; | 260 | b->num = num; |
| 260 | ret = 1; | 261 | ret = 1; |
| 261 | break; | 262 | break; |
| @@ -276,17 +277,12 @@ char *ptr; | |||
| 276 | return(ret); | 277 | return(ret); |
| 277 | } | 278 | } |
| 278 | 279 | ||
| 279 | static int rtcp_gets(bp,buf,size) | 280 | static int rtcp_gets(BIO *bp, char *buf, int size) |
| 280 | BIO *bp; | ||
| 281 | char *buf; | ||
| 282 | int size; | ||
| 283 | { | 281 | { |
| 284 | return(0); | 282 | return(0); |
| 285 | } | 283 | } |
| 286 | 284 | ||
| 287 | static int rtcp_puts(bp,str) | 285 | static int rtcp_puts(BIO *bp, char *str) |
| 288 | BIO *bp; | ||
| 289 | char *str; | ||
| 290 | { | 286 | { |
| 291 | int length; | 287 | int length; |
| 292 | if (str == NULL) return(0); | 288 | if (str == NULL) return(0); |
diff --git a/src/lib/libcrypto/bio/bss_sock.c b/src/lib/libcrypto/bio/bss_sock.c index d907a2867b..d336b99fe8 100644 --- a/src/lib/libcrypto/bio/bss_sock.c +++ b/src/lib/libcrypto/bio/bss_sock.c | |||
| @@ -62,10 +62,9 @@ | |||
| 62 | #include <errno.h> | 62 | #include <errno.h> |
| 63 | #define USE_SOCKETS | 63 | #define USE_SOCKETS |
| 64 | #include "cryptlib.h" | 64 | #include "cryptlib.h" |
| 65 | #include "bio.h" | 65 | #include <openssl/bio.h> |
| 66 | 66 | ||
| 67 | #ifndef BIO_FD | 67 | #ifndef BIO_FD |
| 68 | #ifndef NOPROTO | ||
| 69 | static int sock_write(BIO *h,char *buf,int num); | 68 | static int sock_write(BIO *h,char *buf,int num); |
| 70 | static int sock_read(BIO *h,char *buf,int size); | 69 | static int sock_read(BIO *h,char *buf,int size); |
| 71 | static int sock_puts(BIO *h,char *str); | 70 | static int sock_puts(BIO *h,char *str); |
| @@ -74,18 +73,7 @@ static int sock_new(BIO *h); | |||
| 74 | static int sock_free(BIO *data); | 73 | static int sock_free(BIO *data); |
| 75 | int BIO_sock_should_retry(int s); | 74 | int BIO_sock_should_retry(int s); |
| 76 | #else | 75 | #else |
| 77 | static int sock_write(); | ||
| 78 | static int sock_read(); | ||
| 79 | static int sock_puts(); | ||
| 80 | static long sock_ctrl(); | ||
| 81 | static int sock_new(); | ||
| 82 | static int sock_free(); | ||
| 83 | int BIO_sock_should_retry(); | ||
| 84 | #endif | ||
| 85 | |||
| 86 | #else | ||
| 87 | 76 | ||
| 88 | #ifndef NOPROTO | ||
| 89 | static int fd_write(BIO *h,char *buf,int num); | 77 | static int fd_write(BIO *h,char *buf,int num); |
| 90 | static int fd_read(BIO *h,char *buf,int size); | 78 | static int fd_read(BIO *h,char *buf,int size); |
| 91 | static int fd_puts(BIO *h,char *str); | 79 | static int fd_puts(BIO *h,char *str); |
| @@ -93,15 +81,6 @@ static long fd_ctrl(BIO *h,int cmd,long arg1,char *arg2); | |||
| 93 | static int fd_new(BIO *h); | 81 | static int fd_new(BIO *h); |
| 94 | static int fd_free(BIO *data); | 82 | static int fd_free(BIO *data); |
| 95 | int BIO_fd_should_retry(int s); | 83 | int BIO_fd_should_retry(int s); |
| 96 | #else | ||
| 97 | static int fd_write(); | ||
| 98 | static int fd_read(); | ||
| 99 | static int fd_puts(); | ||
| 100 | static long fd_ctrl(); | ||
| 101 | static int fd_new(); | ||
| 102 | static int fd_free(); | ||
| 103 | int BIO_fd_should_retry(); | ||
| 104 | #endif | ||
| 105 | #endif | 84 | #endif |
| 106 | 85 | ||
| 107 | #ifndef BIO_FD | 86 | #ifndef BIO_FD |
| @@ -118,7 +97,7 @@ static BIO_METHOD methods_sockp= | |||
| 118 | sock_free, | 97 | sock_free, |
| 119 | }; | 98 | }; |
| 120 | 99 | ||
| 121 | BIO_METHOD *BIO_s_socket() | 100 | BIO_METHOD *BIO_s_socket(void) |
| 122 | { | 101 | { |
| 123 | return(&methods_sockp); | 102 | return(&methods_sockp); |
| 124 | } | 103 | } |
| @@ -135,19 +114,17 @@ static BIO_METHOD methods_fdp= | |||
| 135 | fd_free, | 114 | fd_free, |
| 136 | }; | 115 | }; |
| 137 | 116 | ||
| 138 | BIO_METHOD *BIO_s_fd() | 117 | BIO_METHOD *BIO_s_fd(void) |
| 139 | { | 118 | { |
| 140 | return(&methods_fdp); | 119 | return(&methods_fdp); |
| 141 | } | 120 | } |
| 142 | #endif | 121 | #endif |
| 143 | 122 | ||
| 144 | #ifndef BIO_FD | 123 | #ifndef BIO_FD |
| 145 | BIO *BIO_new_socket(fd,close_flag) | 124 | BIO *BIO_new_socket(int fd, int close_flag) |
| 146 | #else | 125 | #else |
| 147 | BIO *BIO_new_fd(fd,close_flag) | 126 | BIO *BIO_new_fd(int fd,int close_flag) |
| 148 | #endif | 127 | #endif |
| 149 | int fd; | ||
| 150 | int close_flag; | ||
| 151 | { | 128 | { |
| 152 | BIO *ret; | 129 | BIO *ret; |
| 153 | 130 | ||
| @@ -162,11 +139,10 @@ int close_flag; | |||
| 162 | } | 139 | } |
| 163 | 140 | ||
| 164 | #ifndef BIO_FD | 141 | #ifndef BIO_FD |
| 165 | static int sock_new(bi) | 142 | static int sock_new(BIO *bi) |
| 166 | #else | 143 | #else |
| 167 | static int fd_new(bi) | 144 | static int fd_new(BIO *bi) |
| 168 | #endif | 145 | #endif |
| 169 | BIO *bi; | ||
| 170 | { | 146 | { |
| 171 | bi->init=0; | 147 | bi->init=0; |
| 172 | bi->num=0; | 148 | bi->num=0; |
| @@ -176,11 +152,10 @@ BIO *bi; | |||
| 176 | } | 152 | } |
| 177 | 153 | ||
| 178 | #ifndef BIO_FD | 154 | #ifndef BIO_FD |
| 179 | static int sock_free(a) | 155 | static int sock_free(BIO *a) |
| 180 | #else | 156 | #else |
| 181 | static int fd_free(a) | 157 | static int fd_free(BIO *a) |
| 182 | #endif | 158 | #endif |
| 183 | BIO *a; | ||
| 184 | { | 159 | { |
| 185 | if (a == NULL) return(0); | 160 | if (a == NULL) return(0); |
| 186 | if (a->shutdown) | 161 | if (a->shutdown) |
| @@ -189,11 +164,7 @@ BIO *a; | |||
| 189 | { | 164 | { |
| 190 | #ifndef BIO_FD | 165 | #ifndef BIO_FD |
| 191 | shutdown(a->num,2); | 166 | shutdown(a->num,2); |
| 192 | # ifdef WINDOWS | ||
| 193 | closesocket(a->num); | 167 | closesocket(a->num); |
| 194 | # else | ||
| 195 | close(a->num); | ||
| 196 | # endif | ||
| 197 | #else /* BIO_FD */ | 168 | #else /* BIO_FD */ |
| 198 | close(a->num); | 169 | close(a->num); |
| 199 | #endif | 170 | #endif |
| @@ -206,21 +177,18 @@ BIO *a; | |||
| 206 | } | 177 | } |
| 207 | 178 | ||
| 208 | #ifndef BIO_FD | 179 | #ifndef BIO_FD |
| 209 | static int sock_read(b,out,outl) | 180 | static int sock_read(BIO *b, char *out, int outl) |
| 210 | #else | 181 | #else |
| 211 | static int fd_read(b,out,outl) | 182 | static int fd_read(BIO *b, char *out,int outl) |
| 212 | #endif | 183 | #endif |
| 213 | BIO *b; | ||
| 214 | char *out; | ||
| 215 | int outl; | ||
| 216 | { | 184 | { |
| 217 | int ret=0; | 185 | int ret=0; |
| 218 | 186 | ||
| 219 | if (out != NULL) | 187 | if (out != NULL) |
| 220 | { | 188 | { |
| 221 | #if defined(WINDOWS) && !defined(BIO_FD) | 189 | #ifndef BIO_FD |
| 222 | clear_socket_error(); | 190 | clear_socket_error(); |
| 223 | ret=recv(b->num,out,outl,0); | 191 | ret=readsocket(b->num,out,outl); |
| 224 | #else | 192 | #else |
| 225 | clear_sys_error(); | 193 | clear_sys_error(); |
| 226 | ret=read(b->num,out,outl); | 194 | ret=read(b->num,out,outl); |
| @@ -240,19 +208,16 @@ int outl; | |||
| 240 | } | 208 | } |
| 241 | 209 | ||
| 242 | #ifndef BIO_FD | 210 | #ifndef BIO_FD |
| 243 | static int sock_write(b,in,inl) | 211 | static int sock_write(BIO *b, char *in, int inl) |
| 244 | #else | 212 | #else |
| 245 | static int fd_write(b,in,inl) | 213 | static int fd_write(BIO *b, char *in, int inl) |
| 246 | #endif | 214 | #endif |
| 247 | BIO *b; | ||
| 248 | char *in; | ||
| 249 | int inl; | ||
| 250 | { | 215 | { |
| 251 | int ret; | 216 | int ret; |
| 252 | 217 | ||
| 253 | #if defined(WINDOWS) && !defined(BIO_FD) | 218 | #ifndef BIO_FD |
| 254 | clear_socket_error(); | 219 | clear_socket_error(); |
| 255 | ret=send(b->num,in,inl,0); | 220 | ret=writesocket(b->num,in,inl); |
| 256 | #else | 221 | #else |
| 257 | clear_sys_error(); | 222 | clear_sys_error(); |
| 258 | ret=write(b->num,in,inl); | 223 | ret=write(b->num,in,inl); |
| @@ -271,14 +236,10 @@ int inl; | |||
| 271 | } | 236 | } |
| 272 | 237 | ||
| 273 | #ifndef BIO_FD | 238 | #ifndef BIO_FD |
| 274 | static long sock_ctrl(b,cmd,num,ptr) | 239 | static long sock_ctrl(BIO *b, int cmd, long num, char *ptr) |
| 275 | #else | 240 | #else |
| 276 | static long fd_ctrl(b,cmd,num,ptr) | 241 | static long fd_ctrl(BIO *b, int cmd, long num, char *ptr) |
| 277 | #endif | 242 | #endif |
| 278 | BIO *b; | ||
| 279 | int cmd; | ||
| 280 | long num; | ||
| 281 | char *ptr; | ||
| 282 | { | 243 | { |
| 283 | long ret=1; | 244 | long ret=1; |
| 284 | int *ip; | 245 | int *ip; |
| @@ -286,14 +247,21 @@ char *ptr; | |||
| 286 | switch (cmd) | 247 | switch (cmd) |
| 287 | { | 248 | { |
| 288 | case BIO_CTRL_RESET: | 249 | case BIO_CTRL_RESET: |
| 250 | num=0; | ||
| 251 | case BIO_C_FILE_SEEK: | ||
| 289 | #ifdef BIO_FD | 252 | #ifdef BIO_FD |
| 290 | ret=(long)lseek(b->num,0,0); | 253 | ret=(long)lseek(b->num,num,0); |
| 291 | #else | 254 | #else |
| 292 | ret=0; | 255 | ret=0; |
| 293 | #endif | 256 | #endif |
| 294 | break; | 257 | break; |
| 258 | case BIO_C_FILE_TELL: | ||
| 295 | case BIO_CTRL_INFO: | 259 | case BIO_CTRL_INFO: |
| 260 | #ifdef BIO_FD | ||
| 261 | ret=(long)lseek(b->num,0,1); | ||
| 262 | #else | ||
| 296 | ret=0; | 263 | ret=0; |
| 264 | #endif | ||
| 297 | break; | 265 | break; |
| 298 | case BIO_C_SET_FD: | 266 | case BIO_C_SET_FD: |
| 299 | #ifndef BIO_FD | 267 | #ifndef BIO_FD |
| @@ -329,7 +297,6 @@ char *ptr; | |||
| 329 | case BIO_CTRL_FLUSH: | 297 | case BIO_CTRL_FLUSH: |
| 330 | ret=1; | 298 | ret=1; |
| 331 | break; | 299 | break; |
| 332 | break; | ||
| 333 | default: | 300 | default: |
| 334 | ret=0; | 301 | ret=0; |
| 335 | break; | 302 | break; |
| @@ -338,22 +305,17 @@ char *ptr; | |||
| 338 | } | 305 | } |
| 339 | 306 | ||
| 340 | #ifdef undef | 307 | #ifdef undef |
| 341 | static int sock_gets(bp,buf,size) | 308 | static int sock_gets(BIO *bp, char *buf,int size) |
| 342 | BIO *bp; | ||
| 343 | char *buf; | ||
| 344 | int size; | ||
| 345 | { | 309 | { |
| 346 | return(-1); | 310 | return(-1); |
| 347 | } | 311 | } |
| 348 | #endif | 312 | #endif |
| 349 | 313 | ||
| 350 | #ifndef BIO_FD | 314 | #ifndef BIO_FD |
| 351 | static int sock_puts(bp,str) | 315 | static int sock_puts(BIO *bp, char *str) |
| 352 | #else | 316 | #else |
| 353 | static int fd_puts(bp,str) | 317 | static int fd_puts(BIO *bp, char *str) |
| 354 | #endif | 318 | #endif |
| 355 | BIO *bp; | ||
| 356 | char *str; | ||
| 357 | { | 319 | { |
| 358 | int n,ret; | 320 | int n,ret; |
| 359 | 321 | ||
| @@ -367,23 +329,22 @@ char *str; | |||
| 367 | } | 329 | } |
| 368 | 330 | ||
| 369 | #ifndef BIO_FD | 331 | #ifndef BIO_FD |
| 370 | int BIO_sock_should_retry(i) | 332 | int BIO_sock_should_retry(int i) |
| 371 | #else | 333 | #else |
| 372 | int BIO_fd_should_retry(i) | 334 | int BIO_fd_should_retry(int i) |
| 373 | #endif | 335 | #endif |
| 374 | int i; | ||
| 375 | { | 336 | { |
| 376 | int err; | 337 | int err; |
| 377 | 338 | ||
| 378 | if ((i == 0) || (i == -1)) | 339 | if ((i == 0) || (i == -1)) |
| 379 | { | 340 | { |
| 380 | #if !defined(BIO_FD) && defined(WINDOWS) | 341 | #ifndef BIO_FD |
| 381 | err=get_last_socket_error(); | 342 | err=get_last_socket_error(); |
| 382 | #else | 343 | #else |
| 383 | err=get_last_sys_error(); | 344 | err=get_last_sys_error(); |
| 384 | #endif | 345 | #endif |
| 385 | 346 | ||
| 386 | #if defined(WINDOWS) /* more microsoft stupidity */ | 347 | #if defined(WINDOWS) && 0 /* more microsoft stupidity? perhaps not? Ben 4/1/99 */ |
| 387 | if ((i == -1) && (err == 0)) | 348 | if ((i == -1) && (err == 0)) |
| 388 | return(1); | 349 | return(1); |
| 389 | #endif | 350 | #endif |
| @@ -398,11 +359,10 @@ int i; | |||
| 398 | } | 359 | } |
| 399 | 360 | ||
| 400 | #ifndef BIO_FD | 361 | #ifndef BIO_FD |
| 401 | int BIO_sock_non_fatal_error(err) | 362 | int BIO_sock_non_fatal_error(int err) |
| 402 | #else | 363 | #else |
| 403 | int BIO_fd_non_fatal_error(err) | 364 | int BIO_fd_non_fatal_error(int err) |
| 404 | #endif | 365 | #endif |
| 405 | int err; | ||
| 406 | { | 366 | { |
| 407 | switch (err) | 367 | switch (err) |
| 408 | { | 368 | { |
| @@ -411,8 +371,10 @@ int err; | |||
| 411 | case WSAEWOULDBLOCK: | 371 | case WSAEWOULDBLOCK: |
| 412 | # endif | 372 | # endif |
| 413 | 373 | ||
| 414 | # if defined(WSAENOTCONN) | 374 | # if 0 /* This appears to always be an error */ |
| 375 | # if defined(WSAENOTCONN) | ||
| 415 | case WSAENOTCONN: | 376 | case WSAENOTCONN: |
| 377 | # endif | ||
| 416 | # endif | 378 | # endif |
| 417 | #endif | 379 | #endif |
| 418 | 380 | ||
| @@ -452,7 +414,7 @@ int err; | |||
| 452 | case EALREADY: | 414 | case EALREADY: |
| 453 | #endif | 415 | #endif |
| 454 | return(1); | 416 | return(1); |
| 455 | break; | 417 | /* break; */ |
| 456 | default: | 418 | default: |
| 457 | break; | 419 | break; |
| 458 | } | 420 | } |
