diff options
author | kris <kris@FreeBSD.org> | 2000-04-13 06:33:22 +0000 |
---|---|---|
committer | kris <kris@FreeBSD.org> | 2000-04-13 06:33:22 +0000 |
commit | 54c77f990d8a5f46f1d18b67cddb279f49176146 (patch) | |
tree | 85b9c007d5ac1d91a3895eef3fd18d6114b62cc4 /crypto/openssl/crypto/bio | |
parent | 7e4e44947b1aa16034c99654c268dc92300be719 (diff) | |
download | FreeBSD-src-54c77f990d8a5f46f1d18b67cddb279f49176146.zip FreeBSD-src-54c77f990d8a5f46f1d18b67cddb279f49176146.tar.gz |
Initial import of OpenSSL 0.9.5a
Diffstat (limited to 'crypto/openssl/crypto/bio')
-rw-r--r-- | crypto/openssl/crypto/bio/Makefile.save | 220 | ||||
-rw-r--r-- | crypto/openssl/crypto/bio/Makefile.ssl | 50 | ||||
-rw-r--r-- | crypto/openssl/crypto/bio/b_dump.c | 4 | ||||
-rw-r--r-- | crypto/openssl/crypto/bio/b_print.c | 765 | ||||
-rw-r--r-- | crypto/openssl/crypto/bio/b_sock.c | 24 | ||||
-rw-r--r-- | crypto/openssl/crypto/bio/bf_buff.c | 26 | ||||
-rw-r--r-- | crypto/openssl/crypto/bio/bf_nbio.c | 20 | ||||
-rw-r--r-- | crypto/openssl/crypto/bio/bf_null.c | 16 | ||||
-rw-r--r-- | crypto/openssl/crypto/bio/bio.h | 56 | ||||
-rw-r--r-- | crypto/openssl/crypto/bio/bio_err.c | 10 | ||||
-rw-r--r-- | crypto/openssl/crypto/bio/bio_lib.c | 58 | ||||
-rw-r--r-- | crypto/openssl/crypto/bio/bss_acpt.c | 1 | ||||
-rw-r--r-- | crypto/openssl/crypto/bio/bss_bio.c | 277 | ||||
-rw-r--r-- | crypto/openssl/crypto/bio/bss_conn.c | 42 | ||||
-rw-r--r-- | crypto/openssl/crypto/bio/bss_file.c | 3 | ||||
-rw-r--r-- | crypto/openssl/crypto/bio/bss_log.c | 214 | ||||
-rw-r--r-- | crypto/openssl/crypto/bio/bss_mem.c | 58 | ||||
-rw-r--r-- | crypto/openssl/crypto/bio/bss_null.c | 1 | ||||
-rw-r--r-- | crypto/openssl/crypto/bio/bss_rtcp.c | 1 | ||||
-rw-r--r-- | crypto/openssl/crypto/bio/bss_sock.c | 5 |
20 files changed, 1713 insertions, 138 deletions
diff --git a/crypto/openssl/crypto/bio/Makefile.save b/crypto/openssl/crypto/bio/Makefile.save new file mode 100644 index 0000000..0ce9391 --- /dev/null +++ b/crypto/openssl/crypto/bio/Makefile.save @@ -0,0 +1,220 @@ +# +# SSLeay/crypto/bio/Makefile +# + +DIR= bio +TOP= ../.. +CC= cc +INCLUDES= -I.. -I../../include +CFLAG=-g +INSTALL_PREFIX= +OPENSSLDIR= /usr/local/ssl +INSTALLTOP=/usr/local/ssl +MAKE= make -f Makefile.ssl +MAKEDEPEND= $(TOP)/util/domd $(TOP) +MAKEFILE= Makefile.ssl +AR= ar r + +CFLAGS= $(INCLUDES) $(CFLAG) + +GENERAL=Makefile +TEST= +APPS= + +LIB=$(TOP)/libcrypto.a +LIBSRC= bio_lib.c bio_cb.c bio_err.c \ + bss_mem.c bss_null.c bss_fd.c \ + bss_file.c bss_sock.c bss_conn.c \ + bf_null.c bf_buff.c b_print.c b_dump.c \ + b_sock.c bss_acpt.c bf_nbio.c bss_log.c bss_bio.c +LIBOBJ= bio_lib.o bio_cb.o bio_err.o \ + bss_mem.o bss_null.o bss_fd.o \ + bss_file.o bss_sock.o bss_conn.o \ + bf_null.o bf_buff.o b_print.o b_dump.o \ + b_sock.o bss_acpt.o bf_nbio.o bss_log.o bss_bio.o + +SRC= $(LIBSRC) + +EXHEADER= bio.h +HEADER= bss_file.c $(EXHEADER) + +ALL= $(GENERAL) $(SRC) $(HEADER) + +top: + (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all) + +all: lib + +lib: $(LIBOBJ) + $(AR) $(LIB) $(LIBOBJ) + $(RANLIB) $(LIB) + @touch lib + +files: + $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO + +links: + @$(TOP)/util/point.sh Makefile.ssl Makefile + @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER) + @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST) + @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS) + +install: + @for i in $(EXHEADER); \ + do \ + (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \ + chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \ + done; + +tags: + ctags $(SRC) + +tests: + +lint: + lint -DLINT $(INCLUDES) $(SRC)>fluff + +depend: + $(MAKEDEPEND) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC) + +dclean: + $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new + mv -f Makefile.new $(MAKEFILE) + +clean: + rm -f *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff + +# DO NOT DELETE THIS LINE -- make depend depends on it. + +b_dump.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h +b_dump.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h +b_dump.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h +b_dump.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h +b_dump.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h +b_dump.o: ../cryptlib.h +b_print.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h +b_print.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h +b_print.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h +b_print.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h +b_print.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h +b_print.o: ../cryptlib.h +b_sock.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h +b_sock.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h +b_sock.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h +b_sock.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h +b_sock.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h +b_sock.o: ../cryptlib.h +bf_buff.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h +bf_buff.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h +bf_buff.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h +bf_buff.o: ../../include/openssl/crypto.h ../../include/openssl/des.h +bf_buff.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h +bf_buff.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h +bf_buff.o: ../../include/openssl/err.h ../../include/openssl/evp.h +bf_buff.o: ../../include/openssl/idea.h ../../include/openssl/md2.h +bf_buff.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h +bf_buff.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h +bf_buff.o: ../../include/openssl/opensslv.h ../../include/openssl/rc2.h +bf_buff.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h +bf_buff.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h +bf_buff.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h +bf_buff.o: ../../include/openssl/stack.h ../cryptlib.h +bf_nbio.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h +bf_nbio.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h +bf_nbio.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h +bf_nbio.o: ../../include/openssl/crypto.h ../../include/openssl/des.h +bf_nbio.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h +bf_nbio.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h +bf_nbio.o: ../../include/openssl/err.h ../../include/openssl/evp.h +bf_nbio.o: ../../include/openssl/idea.h ../../include/openssl/md2.h +bf_nbio.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h +bf_nbio.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h +bf_nbio.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h +bf_nbio.o: ../../include/openssl/rc2.h ../../include/openssl/rc4.h +bf_nbio.o: ../../include/openssl/rc5.h ../../include/openssl/ripemd.h +bf_nbio.o: ../../include/openssl/rsa.h ../../include/openssl/safestack.h +bf_nbio.o: ../../include/openssl/sha.h ../../include/openssl/stack.h +bf_nbio.o: ../cryptlib.h +bf_null.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h +bf_null.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h +bf_null.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h +bf_null.o: ../../include/openssl/crypto.h ../../include/openssl/des.h +bf_null.o: ../../include/openssl/dh.h ../../include/openssl/dsa.h +bf_null.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h +bf_null.o: ../../include/openssl/err.h ../../include/openssl/evp.h +bf_null.o: ../../include/openssl/idea.h ../../include/openssl/md2.h +bf_null.o: ../../include/openssl/md5.h ../../include/openssl/mdc2.h +bf_null.o: ../../include/openssl/objects.h ../../include/openssl/opensslconf.h +bf_null.o: ../../include/openssl/opensslv.h ../../include/openssl/rc2.h +bf_null.o: ../../include/openssl/rc4.h ../../include/openssl/rc5.h +bf_null.o: ../../include/openssl/ripemd.h ../../include/openssl/rsa.h +bf_null.o: ../../include/openssl/safestack.h ../../include/openssl/sha.h +bf_null.o: ../../include/openssl/stack.h ../cryptlib.h +bio_cb.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h +bio_cb.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h +bio_cb.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h +bio_cb.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h +bio_cb.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h +bio_cb.o: ../cryptlib.h +bio_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h +bio_err.o: ../../include/openssl/err.h ../../include/openssl/opensslv.h +bio_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h +bio_lib.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h +bio_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h +bio_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h +bio_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h +bio_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h +bio_lib.o: ../cryptlib.h +bss_acpt.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h +bss_acpt.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h +bss_acpt.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h +bss_acpt.o: ../../include/openssl/opensslconf.h +bss_acpt.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h +bss_acpt.o: ../../include/openssl/stack.h ../cryptlib.h +bss_bio.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h +bss_bio.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h +bss_bio.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h +bss_bio.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h +bss_bio.o: ../../include/openssl/stack.h +bss_conn.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h +bss_conn.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h +bss_conn.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h +bss_conn.o: ../../include/openssl/opensslconf.h +bss_conn.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h +bss_conn.o: ../../include/openssl/stack.h ../cryptlib.h +bss_fd.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h +bss_fd.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h +bss_fd.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h +bss_fd.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h +bss_fd.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h +bss_fd.o: ../cryptlib.h bss_sock.c +bss_file.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h +bss_file.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h +bss_file.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h +bss_file.o: ../../include/openssl/opensslconf.h +bss_file.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h +bss_file.o: ../../include/openssl/stack.h ../cryptlib.h +bss_log.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h +bss_log.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h +bss_log.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h +bss_log.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h +bss_log.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h +bss_log.o: ../cryptlib.h +bss_mem.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h +bss_mem.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h +bss_mem.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h +bss_mem.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h +bss_mem.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h +bss_mem.o: ../cryptlib.h +bss_null.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h +bss_null.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h +bss_null.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h +bss_null.o: ../../include/openssl/opensslconf.h +bss_null.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h +bss_null.o: ../../include/openssl/stack.h ../cryptlib.h +bss_sock.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h +bss_sock.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h +bss_sock.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h +bss_sock.o: ../../include/openssl/opensslconf.h +bss_sock.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h +bss_sock.o: ../../include/openssl/stack.h ../cryptlib.h diff --git a/crypto/openssl/crypto/bio/Makefile.ssl b/crypto/openssl/crypto/bio/Makefile.ssl index f54c7ee..0ce9391 100644 --- a/crypto/openssl/crypto/bio/Makefile.ssl +++ b/crypto/openssl/crypto/bio/Makefile.ssl @@ -90,17 +90,20 @@ b_dump.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h b_dump.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h b_dump.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h b_dump.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h -b_dump.o: ../../include/openssl/stack.h ../cryptlib.h +b_dump.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h +b_dump.o: ../cryptlib.h b_print.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h b_print.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h b_print.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h b_print.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h -b_print.o: ../../include/openssl/stack.h ../cryptlib.h +b_print.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h +b_print.o: ../cryptlib.h b_sock.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h b_sock.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h b_sock.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h b_sock.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h -b_sock.o: ../../include/openssl/stack.h ../cryptlib.h +b_sock.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h +b_sock.o: ../cryptlib.h bf_buff.o: ../../include/openssl/asn1.h ../../include/openssl/bio.h bf_buff.o: ../../include/openssl/blowfish.h ../../include/openssl/bn.h bf_buff.o: ../../include/openssl/buffer.h ../../include/openssl/cast.h @@ -151,60 +154,67 @@ bio_cb.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h bio_cb.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h bio_cb.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h bio_cb.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h -bio_cb.o: ../../include/openssl/stack.h ../cryptlib.h +bio_cb.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h +bio_cb.o: ../cryptlib.h bio_err.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h bio_err.o: ../../include/openssl/err.h ../../include/openssl/opensslv.h -bio_err.o: ../../include/openssl/stack.h +bio_err.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h bio_lib.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h bio_lib.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h bio_lib.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h bio_lib.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h -bio_lib.o: ../../include/openssl/stack.h ../cryptlib.h +bio_lib.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h +bio_lib.o: ../cryptlib.h bss_acpt.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h bss_acpt.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h bss_acpt.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h bss_acpt.o: ../../include/openssl/opensslconf.h -bss_acpt.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h -bss_acpt.o: ../cryptlib.h +bss_acpt.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h +bss_acpt.o: ../../include/openssl/stack.h ../cryptlib.h bss_bio.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h -bss_bio.o: ../../include/openssl/err.h ../../include/openssl/opensslv.h +bss_bio.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h +bss_bio.o: ../../include/openssl/err.h ../../include/openssl/opensslconf.h +bss_bio.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h bss_bio.o: ../../include/openssl/stack.h bss_conn.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h bss_conn.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h bss_conn.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h bss_conn.o: ../../include/openssl/opensslconf.h -bss_conn.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h -bss_conn.o: ../cryptlib.h +bss_conn.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h +bss_conn.o: ../../include/openssl/stack.h ../cryptlib.h bss_fd.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h bss_fd.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h bss_fd.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h bss_fd.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h -bss_fd.o: ../../include/openssl/stack.h ../cryptlib.h bss_sock.c +bss_fd.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h +bss_fd.o: ../cryptlib.h bss_sock.c bss_file.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h bss_file.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h bss_file.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h bss_file.o: ../../include/openssl/opensslconf.h -bss_file.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h -bss_file.o: ../cryptlib.h +bss_file.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h +bss_file.o: ../../include/openssl/stack.h ../cryptlib.h bss_log.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h bss_log.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h bss_log.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h bss_log.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h -bss_log.o: ../../include/openssl/stack.h ../cryptlib.h +bss_log.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h +bss_log.o: ../cryptlib.h bss_mem.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h bss_mem.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h bss_mem.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h bss_mem.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h -bss_mem.o: ../../include/openssl/stack.h ../cryptlib.h +bss_mem.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h +bss_mem.o: ../cryptlib.h bss_null.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h bss_null.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h bss_null.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h bss_null.o: ../../include/openssl/opensslconf.h -bss_null.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h -bss_null.o: ../cryptlib.h +bss_null.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h +bss_null.o: ../../include/openssl/stack.h ../cryptlib.h bss_sock.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h bss_sock.o: ../../include/openssl/crypto.h ../../include/openssl/e_os.h bss_sock.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h bss_sock.o: ../../include/openssl/opensslconf.h -bss_sock.o: ../../include/openssl/opensslv.h ../../include/openssl/stack.h -bss_sock.o: ../cryptlib.h +bss_sock.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h +bss_sock.o: ../../include/openssl/stack.h ../cryptlib.h diff --git a/crypto/openssl/crypto/bio/b_dump.c b/crypto/openssl/crypto/bio/b_dump.c index a7cd828..f5aeb23 100644 --- a/crypto/openssl/crypto/bio/b_dump.c +++ b/crypto/openssl/crypto/bio/b_dump.c @@ -92,7 +92,7 @@ int BIO_dump(BIO *bio, const char *s, int len) if (((i*DUMP_WIDTH)+j)>=len) { strcat(buf," "); } else { - ch=((unsigned char)*((char *)(s)+i*DUMP_WIDTH+j)) & 0xff; + ch=((unsigned char)*(s+i*DUMP_WIDTH+j)) & 0xff; sprintf(tmp,"%02x%c",ch,j==7?'-':' '); strcat(buf,tmp); } @@ -101,7 +101,7 @@ int BIO_dump(BIO *bio, const char *s, int len) for(j=0;j<DUMP_WIDTH;j++) { if (((i*DUMP_WIDTH)+j)>=len) break; - ch=((unsigned char)*((char *)(s)+i*DUMP_WIDTH+j)) & 0xff; + ch=((unsigned char)*(s+i*DUMP_WIDTH+j)) & 0xff; #ifndef CHARSET_EBCDIC sprintf(tmp,"%c",((ch>=' ')&&(ch<='~'))?ch:'.'); #else diff --git a/crypto/openssl/crypto/bio/b_print.c b/crypto/openssl/crypto/bio/b_print.c index f448004..b11b501 100644 --- a/crypto/openssl/crypto/bio/b_print.c +++ b/crypto/openssl/crypto/bio/b_print.c @@ -62,26 +62,783 @@ #include <stdio.h> #include <stdarg.h> +#include <string.h> +#include <ctype.h> +#include <assert.h> +#include <limits.h> #include "cryptlib.h" +#ifndef NO_SYS_TYPES_H +#include <sys/types.h> +#endif #include <openssl/bio.h> +#ifdef BN_LLONG +# ifndef HAVE_LONG_LONG +# define HAVE_LONG_LONG 1 +# endif +#endif + +static void dopr (char *buffer, size_t maxlen, size_t *retlen, + const char *format, va_list args); +#ifdef USE_ALLOCATING_PRINT +static void doapr (char **buffer, size_t *retlen, + const char *format, va_list args); +#endif + int BIO_printf (BIO *bio, ...) { va_list args; char *format; int ret; + size_t retlen; +#ifdef USE_ALLOCATING_PRINT + char *hugebuf; +#else MS_STATIC char hugebuf[1024*2]; /* 10k in one chunk is the limit */ +#endif va_start(args, bio); format=va_arg(args, char *); +#ifndef USE_ALLOCATING_PRINT hugebuf[0]='\0'; + dopr(hugebuf, sizeof(hugebuf), &retlen, format, args); +#else + hugebuf = NULL; + CRYPTO_push_info("doapr()"); + doapr(&hugebuf, &retlen, format, args); + if (hugebuf) + { +#endif + ret=BIO_write(bio, hugebuf, (int)retlen); - vsprintf(hugebuf,format,args); - - ret=BIO_write(bio,hugebuf,strlen(hugebuf)); - +#ifdef USE_ALLOCATING_PRINT + Free(hugebuf); + } + CRYPTO_pop_info(); +#endif va_end(args); return(ret); } +/* + * Copyright Patrick Powell 1995 + * This code is based on code written by Patrick Powell <papowell@astart.com> + * It may be used for any purpose as long as this notice remains intact + * on all source code distributions. + */ + +/* + * This code contains numerious changes and enhancements which were + * made by lots of contributors over the last years to Patrick Powell's + * original code: + * + * o Patrick Powell <papowell@astart.com> (1995) + * o Brandon Long <blong@fiction.net> (1996, for Mutt) + * o Thomas Roessler <roessler@guug.de> (1998, for Mutt) + * o Michael Elkins <me@cs.hmc.edu> (1998, for Mutt) + * o Andrew Tridgell <tridge@samba.org> (1998, for Samba) + * o Luke Mewburn <lukem@netbsd.org> (1999, for LukemFTP) + * o Ralf S. Engelschall <rse@engelschall.com> (1999, for Pth) + */ + +#if HAVE_LONG_DOUBLE +#define LDOUBLE long double +#else +#define LDOUBLE double +#endif + +#if HAVE_LONG_LONG +#define LLONG long long +#else +#define LLONG long +#endif + +static void fmtstr (void (*)(char **, size_t *, size_t *, int), + char **, size_t *, size_t *, const char *, int, int, + int); +static void fmtint (void (*)(char **, size_t *, size_t *, int), + char **, size_t *, size_t *, LLONG, int, int, int, int); +static void fmtfp (void (*)(char **, size_t *, size_t *, int), + char **, size_t *, size_t *, LDOUBLE, int, int, int); +#ifndef USE_ALLOCATING_PRINT +static int dopr_isbig (size_t, size_t); +static int dopr_copy (size_t); +static void dopr_outch (char **, size_t *, size_t *, int); +#else +static int doapr_isbig (size_t, size_t); +static int doapr_copy (size_t); +static void doapr_outch (char **, size_t *, size_t *, int); +#endif +static void _dopr(void (*)(char **, size_t *, size_t *, int), + int (*)(size_t, size_t), int (*)(size_t), + char **buffer, size_t *maxlen, size_t *retlen, + const char *format, va_list args); + +/* format read states */ +#define DP_S_DEFAULT 0 +#define DP_S_FLAGS 1 +#define DP_S_MIN 2 +#define DP_S_DOT 3 +#define DP_S_MAX 4 +#define DP_S_MOD 5 +#define DP_S_CONV 6 +#define DP_S_DONE 7 + +/* format flags - Bits */ +#define DP_F_MINUS (1 << 0) +#define DP_F_PLUS (1 << 1) +#define DP_F_SPACE (1 << 2) +#define DP_F_NUM (1 << 3) +#define DP_F_ZERO (1 << 4) +#define DP_F_UP (1 << 5) +#define DP_F_UNSIGNED (1 << 6) + +/* conversion flags */ +#define DP_C_SHORT 1 +#define DP_C_LONG 2 +#define DP_C_LDOUBLE 3 +#define DP_C_LLONG 4 + +/* some handy macros */ +#define char_to_int(p) (p - '0') +#define MAX(p,q) ((p >= q) ? p : q) + +#ifndef USE_ALLOCATING_PRINT +static void +dopr( + char *buffer, + size_t maxlen, + size_t *retlen, + const char *format, + va_list args) +{ + _dopr(dopr_outch, dopr_isbig, dopr_copy, + &buffer, &maxlen, retlen, format, args); +} + +#else +static void +doapr( + char **buffer, + size_t *retlen, + const char *format, + va_list args) +{ + size_t dummy_maxlen = 0; + _dopr(doapr_outch, doapr_isbig, doapr_copy, + buffer, &dummy_maxlen, retlen, format, args); +} +#endif + +static void +_dopr( + void (*outch_fn)(char **, size_t *, size_t *, int), + int (*isbig_fn)(size_t, size_t), + int (*copy_fn)(size_t), + char **buffer, + size_t *maxlen, + size_t *retlen, + const char *format, + va_list args) +{ + char ch; + LLONG value; + LDOUBLE fvalue; + char *strvalue; + int min; + int max; + int state; + int flags; + int cflags; + size_t currlen; + + state = DP_S_DEFAULT; + flags = currlen = cflags = min = 0; + max = -1; + ch = *format++; + + while (state != DP_S_DONE) { + if ((ch == '\0') || (*isbig_fn)(currlen, *maxlen)) + state = DP_S_DONE; + + switch (state) { + case DP_S_DEFAULT: + if (ch == '%') + state = DP_S_FLAGS; + else + (*outch_fn)(buffer, &currlen, maxlen, ch); + ch = *format++; + break; + case DP_S_FLAGS: + switch (ch) { + case '-': + flags |= DP_F_MINUS; + ch = *format++; + break; + case '+': + flags |= DP_F_PLUS; + ch = *format++; + break; + case ' ': + flags |= DP_F_SPACE; + ch = *format++; + break; + case '#': + flags |= DP_F_NUM; + ch = *format++; + break; + case '0': + flags |= DP_F_ZERO; + ch = *format++; + break; + default: + state = DP_S_MIN; + break; + } + break; + case DP_S_MIN: + if (isdigit((unsigned char)ch)) { + min = 10 * min + char_to_int(ch); + ch = *format++; + } else if (ch == '*') { + min = va_arg(args, int); + ch = *format++; + state = DP_S_DOT; + } else + state = DP_S_DOT; + break; + case DP_S_DOT: + if (ch == '.') { + state = DP_S_MAX; + ch = *format++; + } else + state = DP_S_MOD; + break; + case DP_S_MAX: + if (isdigit((unsigned char)ch)) { + if (max < 0) + max = 0; + max = 10 * max + char_to_int(ch); + ch = *format++; + } else if (ch == '*') { + max = va_arg(args, int); + ch = *format++; + state = DP_S_MOD; + } else + state = DP_S_MOD; + break; + case DP_S_MOD: + switch (ch) { + case 'h': + cflags = DP_C_SHORT; + ch = *format++; + break; + case 'l': + if (*format == 'l') { + cflags = DP_C_LLONG; + format++; + } else + cflags = DP_C_LONG; + ch = *format++; + break; + case 'q': + cflags = DP_C_LLONG; + ch = *format++; + break; + case 'L': + cflags = DP_C_LDOUBLE; + ch = *format++; + break; + default: + break; + } + state = DP_S_CONV; + break; + case DP_S_CONV: + switch (ch) { + case 'd': + case 'i': + switch (cflags) { + case DP_C_SHORT: + value = (short int)va_arg(args, int); + break; + case DP_C_LONG: + value = va_arg(args, long int); + break; + case DP_C_LLONG: + value = va_arg(args, LLONG); + break; + default: + value = va_arg(args, int); + break; + } + fmtint(outch_fn, buffer, &currlen, maxlen, + value, 10, min, max, flags); + break; + case 'X': + flags |= DP_F_UP; + /* FALLTHROUGH */ + case 'x': + case 'o': + case 'u': + flags |= DP_F_UNSIGNED; + switch (cflags) { + case DP_C_SHORT: + value = (unsigned short int)va_arg(args, unsigned int); + break; + case DP_C_LONG: + value = (LLONG) va_arg(args, + unsigned long int); + break; + case DP_C_LLONG: + value = va_arg(args, unsigned LLONG); + break; + default: + value = (LLONG) va_arg(args, + unsigned int); + break; + } + fmtint(outch_fn, buffer, &currlen, maxlen, value, + ch == 'o' ? 8 : (ch == 'u' ? 10 : 16), + min, max, flags); + break; + case 'f': + if (cflags == DP_C_LDOUBLE) + fvalue = va_arg(args, LDOUBLE); + else + fvalue = va_arg(args, double); + fmtfp(outch_fn, buffer, &currlen, maxlen, + fvalue, min, max, flags); + break; + case 'E': + flags |= DP_F_UP; + case 'e': + if (cflags == DP_C_LDOUBLE) + fvalue = va_arg(args, LDOUBLE); + else + fvalue = va_arg(args, double); + break; + case 'G': + flags |= DP_F_UP; + case 'g': + if (cflags == DP_C_LDOUBLE) + fvalue = va_arg(args, LDOUBLE); + else + fvalue = va_arg(args, double); + break; + case 'c': + (*outch_fn)(buffer, &currlen, maxlen, + va_arg(args, int)); + break; + case 's': + strvalue = va_arg(args, char *); + if (max < 0) + max = (*copy_fn)(*maxlen); + fmtstr(outch_fn, buffer, &currlen, maxlen, strvalue, + flags, min, max); + break; + case 'p': + value = (long)va_arg(args, void *); + fmtint(outch_fn, buffer, &currlen, maxlen, + value, 16, min, max, flags); + break; + case 'n': /* XXX */ + if (cflags == DP_C_SHORT) { + short int *num; + num = va_arg(args, short int *); + *num = currlen; + } else if (cflags == DP_C_LONG) { /* XXX */ + long int *num; + num = va_arg(args, long int *); + *num = (long int) currlen; + } else if (cflags == DP_C_LLONG) { /* XXX */ + LLONG *num; + num = va_arg(args, LLONG *); + *num = (LLONG) currlen; + } else { + int *num; + num = va_arg(args, int *); + *num = currlen; + } + break; + case '%': + (*outch_fn)(buffer, &currlen, maxlen, ch); + break; + case 'w': + /* not supported yet, treat as next char */ + ch = *format++; + break; + default: + /* unknown, skip */ + break; + } + ch = *format++; + state = DP_S_DEFAULT; + flags = cflags = min = 0; + max = -1; + break; + case DP_S_DONE: + break; + default: + break; + } + } + if (currlen >= *maxlen - 1) + currlen = *maxlen - 1; + (*buffer)[currlen] = '\0'; + *retlen = currlen; + return; +} + +static void +fmtstr( + void (*outch_fn)(char **, size_t *, size_t *, int), + char **buffer, + size_t *currlen, + size_t *maxlen, + const char *value, + int flags, + int min, + int max) +{ + int padlen, strln; + int cnt = 0; + + if (value == 0) + value = "<NULL>"; + for (strln = 0; value[strln]; ++strln) + ; + padlen = min - strln; + if (padlen < 0) + padlen = 0; + if (flags & DP_F_MINUS) + padlen = -padlen; + + while ((padlen > 0) && (cnt < max)) { + (*outch_fn)(buffer, currlen, maxlen, ' '); + --padlen; + ++cnt; + } + while (*value && (cnt < max)) { + (*outch_fn)(buffer, currlen, maxlen, *value++); + ++cnt; + } + while ((padlen < 0) && (cnt < max)) { + (*outch_fn)(buffer, currlen, maxlen, ' '); + ++padlen; + ++cnt; + } +} + +static void +fmtint( + void (*outch_fn)(char **, size_t *, size_t *, int), + char **buffer, + size_t *currlen, + size_t *maxlen, + LLONG value, + int base, + int min, + int max, + int flags) +{ + int signvalue = 0; + unsigned LLONG uvalue; + char convert[20]; + int place = 0; + int spadlen = 0; + int zpadlen = 0; + int caps = 0; + + if (max < 0) + max = 0; + uvalue = value; + if (!(flags & DP_F_UNSIGNED)) { + if (value < 0) { + signvalue = '-'; + uvalue = -value; + } else if (flags & DP_F_PLUS) + signvalue = '+'; + else if (flags & DP_F_SPACE) + signvalue = ' '; + } + if (flags & DP_F_UP) + caps = 1; + do { + convert[place++] = + (caps ? "0123456789ABCDEF" : "0123456789abcdef") + [uvalue % (unsigned) base]; + uvalue = (uvalue / (unsigned) base); + } while (uvalue && (place < 20)); + if (place == 20) + place--; + convert[place] = 0; + + zpadlen = max - place; + spadlen = min - MAX(max, place) - (signvalue ? 1 : 0); + if (zpadlen < 0) + zpadlen = 0; + if (spadlen < 0) + spadlen = 0; + if (flags & DP_F_ZERO) { + zpadlen = MAX(zpadlen, spadlen); + spadlen = 0; + } + if (flags & DP_F_MINUS) + spadlen = -spadlen; + + /* spaces */ + while (spadlen > 0) { + (*outch_fn)(buffer, currlen, maxlen, ' '); + --spadlen; + } + + /* sign */ + if (signvalue) + (*outch_fn)(buffer, currlen, maxlen, signvalue); + + /* zeros */ + if (zpadlen > 0) { + while (zpadlen > 0) { + (*outch_fn)(buffer, currlen, maxlen, '0'); + --zpadlen; + } + } + /* digits */ + while (place > 0) + (*outch_fn)(buffer, currlen, maxlen, convert[--place]); + + /* left justified spaces */ + while (spadlen < 0) { + (*outch_fn)(buffer, currlen, maxlen, ' '); + ++spadlen; + } + return; +} + +static LDOUBLE +abs_val(LDOUBLE value) +{ + LDOUBLE result = value; + if (value < 0) + result = -value; + return result; +} + +static LDOUBLE +pow10(int exp) +{ + LDOUBLE result = 1; + while (exp) { + result *= 10; + exp--; + } + return result; +} + +static long +round(LDOUBLE value) +{ + long intpart; + intpart = (long) value; + value = value - intpart; + if (value >= 0.5) + intpart++; + return intpart; +} + +static void +fmtfp( + void (*outch_fn)(char **, size_t *, size_t *, int), + char **buffer, + size_t *currlen, + size_t *maxlen, + LDOUBLE fvalue, + int min, + int max, + int flags) +{ + int signvalue = 0; + LDOUBLE ufvalue; + char iconvert[20]; + char fconvert[20]; + int iplace = 0; + int fplace = 0; + int padlen = 0; + int zpadlen = 0; + int caps = 0; + long intpart; + long fracpart; + + if (max < 0) + max = 6; + ufvalue = abs_val(fvalue); + if (fvalue < 0) + signvalue = '-'; + else if (flags & DP_F_PLUS) + signvalue = '+'; + else if (flags & DP_F_SPACE) + signvalue = ' '; + + intpart = (long)ufvalue; + + /* sorry, we only support 9 digits past the decimal because of our + conversion method */ + if (max > 9) + max = 9; + + /* we "cheat" by converting the fractional part to integer by + multiplying by a factor of 10 */ + fracpart = round((pow10(max)) * (ufvalue - intpart)); + + if (fracpart >= pow10(max)) { + intpart++; + fracpart -= (long)pow10(max); + } + + /* convert integer part */ + do { + iconvert[iplace++] = + (caps ? "0123456789ABCDEF" + : "0123456789abcdef")[intpart % 10]; + intpart = (intpart / 10); + } while (intpart && (iplace < 20)); + if (iplace == 20) + iplace--; + iconvert[iplace] = 0; + + /* convert fractional part */ + do { + fconvert[fplace++] = + (caps ? "0123456789ABCDEF" + : "0123456789abcdef")[fracpart % 10]; + fracpart = (fracpart / 10); + } while (fracpart && (fplace < 20)); + if (fplace == 20) + fplace--; + fconvert[fplace] = 0; + + /* -1 for decimal point, another -1 if we are printing a sign */ + padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0); + zpadlen = max - fplace; + if (zpadlen < 0) + zpadlen = 0; + if (padlen < 0) + padlen = 0; + if (flags & DP_F_MINUS) + padlen = -padlen; + + if ((flags & DP_F_ZERO) && (padlen > 0)) { + if (signvalue) { + (*outch_fn)(buffer, currlen, maxlen, signvalue); + --padlen; + signvalue = 0; + } + while (padlen > 0) { + (*outch_fn)(buffer, currlen, maxlen, '0'); + --padlen; + } + } + while (padlen > 0) { + (*outch_fn)(buffer, currlen, maxlen, ' '); + --padlen; + } + if (signvalue) + (*outch_fn)(buffer, currlen, maxlen, signvalue); + + while (iplace > 0) + (*outch_fn)(buffer, currlen, maxlen, iconvert[--iplace]); + + /* + * Decimal point. This should probably use locale to find the correct + * char to print out. + */ + if (max > 0) { + (*outch_fn)(buffer, currlen, maxlen, '.'); + + while (fplace > 0) + (*outch_fn)(buffer, currlen, maxlen, fconvert[--fplace]); + } + while (zpadlen > 0) { + (*outch_fn)(buffer, currlen, maxlen, '0'); + --zpadlen; + } + + while (padlen < 0) { + (*outch_fn)(buffer, currlen, maxlen, ' '); + ++padlen; + } +} + +static int +dopr_copy( + size_t len) +{ + return len; +} + +#ifdef USE_ALLOCATING_PRINT +static int +doapr_copy( + size_t len) +{ + /* Return as high an integer as possible */ + return INT_MAX; +} +#endif + +static int +dopr_isbig( + size_t currlen, + size_t maxlen) +{ + return currlen > maxlen; +} + +#ifdef USE_ALLOCATING_PRINT +static int +doapr_isbig( + size_t currlen, + size_t maxlen) +{ + return 0; +} +#endif + +static void +dopr_outch( + char **buffer, + size_t *currlen, + size_t *maxlen, + int c) +{ + if (*currlen < *maxlen) + (*buffer)[(*currlen)++] = (char)c; + return; +} + +#ifdef USE_ALLOCATING_PRINT +static void +doapr_outch( + char **buffer, + size_t *currlen, + size_t *maxlen, + int c) +{ + if (*buffer == NULL) { + if (*maxlen == 0) + *maxlen = 1024; + *buffer = Malloc(*maxlen); + } + while (*currlen >= *maxlen) { + *maxlen += 1024; + *buffer = Realloc(*buffer, *maxlen); + } + /* What to do if *buffer is NULL? */ + assert(*buffer != NULL); + + (*buffer)[(*currlen)++] = (char)c; + return; +} +#endif diff --git a/crypto/openssl/crypto/bio/b_sock.c b/crypto/openssl/crypto/bio/b_sock.c index d29b29f..6409f98 100644 --- a/crypto/openssl/crypto/bio/b_sock.c +++ b/crypto/openssl/crypto/bio/b_sock.c @@ -163,7 +163,14 @@ int BIO_get_port(const char *str, unsigned short *port_ptr) else { CRYPTO_w_lock(CRYPTO_LOCK_GETSERVBYNAME); - s=getservbyname(str,"tcp"); + /* Note: under VMS with SOCKETSHR, it seems like the first + * parameter is 'char *', instead of 'const char *' + */ + s=getservbyname( +#ifndef CONST_STRICT + (char *) +#endif + str,"tcp"); if(s != NULL) *port_ptr=ntohs((unsigned short)s->s_port); CRYPTO_w_unlock(CRYPTO_LOCK_GETSERVBYNAME); @@ -282,12 +289,12 @@ static struct hostent *ghbn_dup(struct hostent *a) j=strlen(a->h_name)+1; if ((ret->h_name=Malloc(j)) == NULL) goto err; - memcpy((char *)ret->h_name,a->h_name,j+1); + memcpy((char *)ret->h_name,a->h_name,j); for (i=0; a->h_aliases[i] != NULL; i++) { j=strlen(a->h_aliases[i])+1; if ((ret->h_aliases[i]=Malloc(j)) == NULL) goto err; - memcpy(ret->h_aliases[i],a->h_aliases[i],j+1); + memcpy(ret->h_aliases[i],a->h_aliases[i],j); } ret->h_length=a->h_length; ret->h_addrtype=a->h_addrtype; @@ -327,7 +334,7 @@ static void ghbn_free(struct hostent *a) Free(a->h_addr_list[i]); Free(a->h_addr_list); } - if (a->h_name != NULL) Free((char *)a->h_name); + if (a->h_name != NULL) Free(a->h_name); Free(a); } @@ -368,7 +375,14 @@ struct hostent *BIO_gethostbyname(const char *name) if (i == GHBN_NUM) /* no hit*/ { BIO_ghbn_miss++; - ret=gethostbyname(name); + /* Note: under VMS with SOCKETSHR, it seems like the first + * parameter is 'char *', instead of 'const char *' + */ + ret=gethostbyname( +#ifndef CONST_STRICT + (char *) +#endif + name); if (ret == NULL) goto end; diff --git a/crypto/openssl/crypto/bio/bf_buff.c b/crypto/openssl/crypto/bio/bf_buff.c index acd8148..ff0c907 100644 --- a/crypto/openssl/crypto/bio/bf_buff.c +++ b/crypto/openssl/crypto/bio/bf_buff.c @@ -69,6 +69,7 @@ static int buffer_gets(BIO *h,char *str,int size); static long buffer_ctrl(BIO *h,int cmd,long arg1,char *arg2); static int buffer_new(BIO *h); static int buffer_free(BIO *data); +static long buffer_callback_ctrl(BIO *h,int cmd, void (*fp)()); #define DEFAULT_BUFFER_SIZE 1024 static BIO_METHOD methods_buffer= @@ -82,6 +83,7 @@ static BIO_METHOD methods_buffer= buffer_ctrl, buffer_new, buffer_free, + buffer_callback_ctrl, }; BIO_METHOD *BIO_f_buffer(void) @@ -284,6 +286,7 @@ static long buffer_ctrl(BIO *b, int cmd, long num, char *ptr) ctx->ibuf_len=0; ctx->obuf_off=0; ctx->obuf_len=0; + if (b->next_bio == NULL) return(0); ret=BIO_ctrl(b->next_bio,cmd,num,ptr); break; case BIO_CTRL_INFO: @@ -300,12 +303,18 @@ static long buffer_ctrl(BIO *b, int cmd, long num, char *ptr) case BIO_CTRL_WPENDING: ret=(long)ctx->obuf_len; if (ret == 0) + { + if (b->next_bio == NULL) return(0); ret=BIO_ctrl(b->next_bio,cmd,num,ptr); + } break; case BIO_CTRL_PENDING: ret=(long)ctx->ibuf_len; if (ret == 0) + { + if (b->next_bio == NULL) return(0); ret=BIO_ctrl(b->next_bio,cmd,num,ptr); + } break; case BIO_C_SET_BUFF_READ_DATA: if (num > ctx->ibuf_size) @@ -374,12 +383,14 @@ static long buffer_ctrl(BIO *b, int cmd, long num, char *ptr) } break; case BIO_C_DO_STATE_MACHINE: + if (b->next_bio == NULL) return(0); BIO_clear_retry_flags(b); ret=BIO_ctrl(b->next_bio,cmd,num,ptr); BIO_copy_next_retry(b); break; case BIO_CTRL_FLUSH: + if (b->next_bio == NULL) return(0); if (ctx->obuf_len <= 0) { ret=BIO_ctrl(b->next_bio,cmd,num,ptr); @@ -418,6 +429,7 @@ fprintf(stderr,"FLUSH [%3d] %3d -> %3d\n",ctx->obuf_off,ctx->obuf_len-ctx->obuf_ ret=0; break; default: + if (b->next_bio == NULL) return(0); ret=BIO_ctrl(b->next_bio,cmd,num,ptr); break; } @@ -427,6 +439,20 @@ malloc_error: return(0); } +static long buffer_callback_ctrl(BIO *b, int cmd, void (*fp)()) + { + long ret=1; + + if (b->next_bio == NULL) return(0); + switch (cmd) + { + default: + ret=BIO_callback_ctrl(b->next_bio,cmd,fp); + break; + } + return(ret); + } + static int buffer_gets(BIO *b, char *buf, int size) { BIO_F_BUFFER_CTX *ctx; diff --git a/crypto/openssl/crypto/bio/bf_nbio.c b/crypto/openssl/crypto/bio/bf_nbio.c index cbec2ba..5e574b7 100644 --- a/crypto/openssl/crypto/bio/bf_nbio.c +++ b/crypto/openssl/crypto/bio/bf_nbio.c @@ -73,6 +73,7 @@ static int nbiof_gets(BIO *h,char *str,int size); static long nbiof_ctrl(BIO *h,int cmd,long arg1,char *arg2); static int nbiof_new(BIO *h); static int nbiof_free(BIO *data); +static long nbiof_callback_ctrl(BIO *h,int cmd,void (*fp)()); typedef struct nbio_test_st { /* only set if we sent a 'should retry' error */ @@ -91,6 +92,7 @@ static BIO_METHOD methods_nbiof= nbiof_ctrl, nbiof_new, nbiof_free, + nbiof_callback_ctrl, }; BIO_METHOD *BIO_f_nbio_test(void) @@ -137,7 +139,7 @@ static int nbiof_read(BIO *b, char *out, int outl) BIO_clear_retry_flags(b); #if 0 - RAND_bytes(&n,1); + RAND_pseudo_bytes(&n,1); num=(n&0x07); if (outl > num) outl=num; @@ -178,7 +180,7 @@ static int nbiof_write(BIO *b, char *in, int inl) } else { - RAND_bytes(&n,1); + RAND_pseudo_bytes(&n,1); num=(n&7); } @@ -224,6 +226,20 @@ static long nbiof_ctrl(BIO *b, int cmd, long num, char *ptr) return(ret); } +static long nbiof_callback_ctrl(BIO *b, int cmd, void (*fp)()) + { + long ret=1; + + if (b->next_bio == NULL) return(0); + switch (cmd) + { + default: + ret=BIO_callback_ctrl(b->next_bio,cmd,fp); + break; + } + return(ret); + } + static int nbiof_gets(BIO *bp, char *buf, int size) { if (bp->next_bio == NULL) return(0); diff --git a/crypto/openssl/crypto/bio/bf_null.c b/crypto/openssl/crypto/bio/bf_null.c index 3254a55..0d183a6 100644 --- a/crypto/openssl/crypto/bio/bf_null.c +++ b/crypto/openssl/crypto/bio/bf_null.c @@ -72,6 +72,7 @@ static int nullf_gets(BIO *h,char *str,int size); static long nullf_ctrl(BIO *h,int cmd,long arg1,char *arg2); static int nullf_new(BIO *h); static int nullf_free(BIO *data); +static long nullf_callback_ctrl(BIO *h,int cmd,void (*fp)()); static BIO_METHOD methods_nullf= { BIO_TYPE_NULL_FILTER, @@ -83,6 +84,7 @@ static BIO_METHOD methods_nullf= nullf_ctrl, nullf_new, nullf_free, + nullf_callback_ctrl, }; BIO_METHOD *BIO_f_null(void) @@ -152,6 +154,20 @@ static long nullf_ctrl(BIO *b, int cmd, long num, char *ptr) return(ret); } +static long nullf_callback_ctrl(BIO *b, int cmd, void (*fp)()) + { + long ret=1; + + if (b->next_bio == NULL) return(0); + switch (cmd) + { + default: + ret=BIO_callback_ctrl(b->next_bio,cmd,fp); + break; + } + return(ret); + } + static int nullf_gets(BIO *bp, char *buf, int size) { if (bp->next_bio == NULL) return(0); diff --git a/crypto/openssl/crypto/bio/bio.h b/crypto/openssl/crypto/bio/bio.h index 54bf622..ebdb181 100644 --- a/crypto/openssl/crypto/bio/bio.h +++ b/crypto/openssl/crypto/bio/bio.h @@ -76,7 +76,7 @@ extern "C" { #define BIO_TYPE_SOCKET (5|0x0400|0x0100) #define BIO_TYPE_NULL (6|0x0400) #define BIO_TYPE_SSL (7|0x0200) -#define BIO_TYPE_MD (8|0x0200) /* pasive filter */ +#define BIO_TYPE_MD (8|0x0200) /* passive filter */ #define BIO_TYPE_BUFFER (9|0x0200) /* filter */ #define BIO_TYPE_CIPHER (10|0x0200) /* filter */ #define BIO_TYPE_BASE64 (11|0x0200) /* filter */ @@ -147,6 +147,11 @@ extern "C" { #define BIO_FLAGS_BASE64_NO_NL 0x100 +/* This is used with memory BIOs: it means we shouldn't free up or change the + * data in any way. + */ +#define BIO_FLAGS_MEM_RDONLY 0x200 + #define BIO_set_flags(b,f) ((b)->flags|=(f)) #define BIO_get_flags(b) ((b)->flags) #define BIO_set_retry_special(b) \ @@ -163,7 +168,7 @@ extern "C" { #define BIO_get_retry_flags(b) \ ((b)->flags&(BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY)) -/* These shouldbe used by the application to tell why we should retry */ +/* These should be used by the application to tell why we should retry */ #define BIO_should_read(a) ((a)->flags & BIO_FLAGS_READ) #define BIO_should_write(a) ((a)->flags & BIO_FLAGS_WRITE) #define BIO_should_io_special(a) ((a)->flags & BIO_FLAGS_IO_SPECIAL) @@ -214,6 +219,7 @@ typedef struct bio_method_st long (*ctrl)(); int (*create)(); int (*destroy)(); + long (*callback_ctrl)(); } BIO_METHOD; #else typedef struct bio_method_st @@ -227,6 +233,7 @@ typedef struct bio_method_st long (_far *ctrl)(); int (_far *create)(); int (_far *destroy)(); + long (_fat *callback_ctrl)(); } BIO_METHOD; #endif @@ -278,9 +285,6 @@ typedef struct bio_f_buffer_ctx_struct #define BIO_CONN_S_NBIO 8 /*#define BIO_CONN_get_param_hostname BIO_ctrl */ -#define BIO_number_read(b) ((b)->num_read) -#define BIO_number_written(b) ((b)->num_write) - #define BIO_C_SET_CONNECT 100 #define BIO_C_DO_STATE_MACHINE 101 #define BIO_C_SET_NBIO 102 @@ -325,9 +329,14 @@ typedef struct bio_f_buffer_ctx_struct #define BIO_C_GET_WRITE_GUARANTEE 140 #define BIO_C_GET_READ_REQUEST 141 #define BIO_C_SHUTDOWN_WR 142 +#define BIO_C_NREAD0 143 +#define BIO_C_NREAD 144 +#define BIO_C_NWRITE0 145 +#define BIO_C_NWRITE 146 +#define BIO_C_RESET_READ_REQUEST 147 -#define BIO_set_app_data(s,arg) BIO_set_ex_data(s,0,(char *)arg) +#define BIO_set_app_data(s,arg) BIO_set_ex_data(s,0,arg) #define BIO_get_app_data(s) BIO_get_ex_data(s,0) /* BIO_s_connect() and BIO_s_socks4a_connect() */ @@ -366,7 +375,7 @@ typedef struct bio_f_buffer_ctx_struct /* BIO_set_nbio(b,n) */ #define BIO_set_filter_bio(b,s) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,2,(char *)(s)) /* BIO *BIO_get_filter_bio(BIO *bio); */ -#define BIO_set_proxy_cb(b,cb) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,3,(char *)(cb)) +#define BIO_set_proxy_cb(b,cb) BIO_callback_ctrl(b,BIO_C_SET_PROXY_PARAM,3,(void *(*cb)())) #define BIO_set_proxy_header(b,sk) BIO_ctrl(b,BIO_C_SET_PROXY_PARAM,4,(char *)sk) #define BIO_set_no_connect_return(b,bool) BIO_int_ctrl(b,BIO_C_SET_PROXY_PARAM,5,bool) @@ -445,8 +454,8 @@ int BIO_read_filename(BIO *b,const char *name); size_t BIO_ctrl_pending(BIO *b); size_t BIO_ctrl_wpending(BIO *b); #define BIO_flush(b) (int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL) -#define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0,(char *)cbp) -#define BIO_set_info_callback(b,cb) (int)BIO_ctrl(b,BIO_CTRL_SET_CALLBACK,0,(char *)cb) +#define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0,(void (**)())(cbp)) +#define BIO_set_info_callback(b,cb) (int)BIO_callback_ctrl(b,BIO_CTRL_SET_CALLBACK,(void (*)())(cb)) /* For the BIO_f_buffer() type */ #define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL) @@ -461,8 +470,7 @@ size_t BIO_ctrl_wpending(BIO *b); #define BIO_get_read_request(b) (int)BIO_ctrl(b,BIO_C_GET_READ_REQUEST,0,NULL) size_t BIO_ctrl_get_write_guarantee(BIO *b); size_t BIO_ctrl_get_read_request(BIO *b); - - +int BIO_ctrl_reset_read_request(BIO *b); #ifdef NO_STDIO #define NO_FP_API @@ -472,10 +480,12 @@ size_t BIO_ctrl_get_read_request(BIO *b); /* These two aren't currently implemented */ /* int BIO_get_ex_num(BIO *bio); */ /* void BIO_set_ex_free_func(BIO *bio,int idx,void (*cb)()); */ -int BIO_set_ex_data(BIO *bio,int idx,char *data); -char *BIO_get_ex_data(BIO *bio,int idx); -int BIO_get_ex_new_index(long argl, char *argp, int (*new_func)(), - int (*dup_func)(), void (*free_func)()); +int BIO_set_ex_data(BIO *bio,int idx,void *data); +void *BIO_get_ex_data(BIO *bio,int idx); +int BIO_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); +unsigned long BIO_number_read(BIO *bio); +unsigned long BIO_number_written(BIO *bio); # if defined(WIN16) && defined(_WINDLL) BIO_METHOD *BIO_s_file_internal(void); @@ -497,9 +507,10 @@ int BIO_set(BIO *a,BIO_METHOD *type); int BIO_free(BIO *a); int BIO_read(BIO *b, void *data, int len); int BIO_gets(BIO *bp,char *buf, int size); -int BIO_write(BIO *b, const char *data, int len); +int BIO_write(BIO *b, const void *data, int len); int BIO_puts(BIO *bp,const char *buf); long BIO_ctrl(BIO *bp,int cmd,long larg,void *parg); +long BIO_callback_ctrl(BIO *bp,int cmd,void (*fp)()); char * BIO_ptr_ctrl(BIO *bp,int cmd,long larg); long BIO_int_ctrl(BIO *bp,int cmd,long larg,int iarg); BIO * BIO_push(BIO *b,BIO *append); @@ -510,6 +521,11 @@ BIO * BIO_get_retry_BIO(BIO *bio, int *reason); int BIO_get_retry_reason(BIO *bio); BIO * BIO_dup_chain(BIO *in); +int BIO_nread0(BIO *bio, char **buf); +int BIO_nread(BIO *bio, char **buf, int num); +int BIO_nwrite0(BIO *bio, char **buf); +int BIO_nwrite(BIO *bio, char **buf, int num); + #ifndef WIN16 long BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi, long argl,long ret); @@ -519,6 +535,7 @@ long _far _loadds BIO_debug_callback(BIO *bio,int cmd,const char *argp,int argi, #endif BIO_METHOD *BIO_s_mem(void); +BIO *BIO_new_mem_buf(void *buf, int len); BIO_METHOD *BIO_s_socket(void); BIO_METHOD *BIO_s_connect(void); BIO_METHOD *BIO_s_accept(void); @@ -597,11 +614,17 @@ int BIO_printf(BIO *bio, ...); #define BIO_F_BIO_MAKE_PAIR 121 #define BIO_F_BIO_NEW 108 #define BIO_F_BIO_NEW_FILE 109 +#define BIO_F_BIO_NEW_MEM_BUF 126 +#define BIO_F_BIO_NREAD 123 +#define BIO_F_BIO_NREAD0 124 +#define BIO_F_BIO_NWRITE 125 +#define BIO_F_BIO_NWRITE0 122 #define BIO_F_BIO_PUTS 110 #define BIO_F_BIO_READ 111 #define BIO_F_BIO_SOCK_INIT 112 #define BIO_F_BIO_WRITE 113 #define BIO_F_BUFFER_CTRL 114 +#define BIO_F_CONN_CTRL 127 #define BIO_F_CONN_STATE 115 #define BIO_F_FILE_CTRL 116 #define BIO_F_MEM_WRITE 117 @@ -634,6 +657,7 @@ int BIO_printf(BIO *bio, ...); #define BIO_R_UNABLE_TO_LISTEN_SOCKET 119 #define BIO_R_UNINITIALIZED 120 #define BIO_R_UNSUPPORTED_METHOD 121 +#define BIO_R_WRITE_TO_READ_ONLY_BIO 126 #define BIO_R_WSASTARTUP 122 #ifdef __cplusplus diff --git a/crypto/openssl/crypto/bio/bio_err.c b/crypto/openssl/crypto/bio/bio_err.c index 712d98a..f38e7b9 100644 --- a/crypto/openssl/crypto/bio/bio_err.c +++ b/crypto/openssl/crypto/bio/bio_err.c @@ -54,7 +54,8 @@ */ /* NOTE: this file was auto generated by the mkerr.pl script: any changes - * made to it will be overwritten when the script next updates this file. + * made to it will be overwritten when the script next updates this file, + * only reason strings will be preserved. */ #include <stdio.h> @@ -77,11 +78,17 @@ static ERR_STRING_DATA BIO_str_functs[]= {ERR_PACK(0,BIO_F_BIO_MAKE_PAIR,0), "BIO_MAKE_PAIR"}, {ERR_PACK(0,BIO_F_BIO_NEW,0), "BIO_new"}, {ERR_PACK(0,BIO_F_BIO_NEW_FILE,0), "BIO_new_file"}, +{ERR_PACK(0,BIO_F_BIO_NEW_MEM_BUF,0), "BIO_new_mem_buf"}, +{ERR_PACK(0,BIO_F_BIO_NREAD,0), "BIO_nread"}, +{ERR_PACK(0,BIO_F_BIO_NREAD0,0), "BIO_nread0"}, +{ERR_PACK(0,BIO_F_BIO_NWRITE,0), "BIO_nwrite"}, +{ERR_PACK(0,BIO_F_BIO_NWRITE0,0), "BIO_nwrite0"}, {ERR_PACK(0,BIO_F_BIO_PUTS,0), "BIO_puts"}, {ERR_PACK(0,BIO_F_BIO_READ,0), "BIO_read"}, {ERR_PACK(0,BIO_F_BIO_SOCK_INIT,0), "BIO_sock_init"}, {ERR_PACK(0,BIO_F_BIO_WRITE,0), "BIO_write"}, {ERR_PACK(0,BIO_F_BUFFER_CTRL,0), "BUFFER_CTRL"}, +{ERR_PACK(0,BIO_F_CONN_CTRL,0), "CONN_CTRL"}, {ERR_PACK(0,BIO_F_CONN_STATE,0), "CONN_STATE"}, {ERR_PACK(0,BIO_F_FILE_CTRL,0), "FILE_CTRL"}, {ERR_PACK(0,BIO_F_MEM_WRITE,0), "MEM_WRITE"}, @@ -117,6 +124,7 @@ static ERR_STRING_DATA BIO_str_reasons[]= {BIO_R_UNABLE_TO_LISTEN_SOCKET ,"unable to listen socket"}, {BIO_R_UNINITIALIZED ,"uninitialized"}, {BIO_R_UNSUPPORTED_METHOD ,"unsupported method"}, +{BIO_R_WRITE_TO_READ_ONLY_BIO ,"write to read only bio"}, {BIO_R_WSASTARTUP ,"wsastartup"}, {0,NULL} }; diff --git a/crypto/openssl/crypto/bio/bio_lib.c b/crypto/openssl/crypto/bio/bio_lib.c index b72688e..e88dcc8 100644 --- a/crypto/openssl/crypto/bio/bio_lib.c +++ b/crypto/openssl/crypto/bio/bio_lib.c @@ -63,7 +63,7 @@ #include <openssl/bio.h> #include <openssl/stack.h> -static STACK *bio_meth=NULL; +static STACK_OF(CRYPTO_EX_DATA_FUNCS) *bio_meth=NULL; static int bio_meth_num=0; BIO *BIO_new(BIO_METHOD *method) @@ -100,7 +100,7 @@ int BIO_set(BIO *bio, BIO_METHOD *method) bio->references=1; bio->num_read=0L; bio->num_write=0L; - CRYPTO_new_ex_data(bio_meth,(char *)bio,&bio->ex_data); + CRYPTO_new_ex_data(bio_meth,bio,&bio->ex_data); if (method->create != NULL) if (!method->create(bio)) return(0); @@ -129,7 +129,7 @@ int BIO_free(BIO *a) ((i=(int)a->callback(a,BIO_CB_FREE,NULL,0,0L,1L)) <= 0)) return(i); - CRYPTO_free_ex_data(bio_meth,(char *)a,&a->ex_data); + CRYPTO_free_ex_data(bio_meth,a,&a->ex_data); if ((a->method == NULL) || (a->method->destroy == NULL)) return(1); ret=a->method->destroy(a); @@ -169,7 +169,7 @@ int BIO_read(BIO *b, void *out, int outl) return(i); } -int BIO_write(BIO *b, const char *in, int inl) +int BIO_write(BIO *b, const void *in, int inl) { int i; long (*cb)(); @@ -317,16 +317,43 @@ long BIO_ctrl(BIO *b, int cmd, long larg, void *parg) return(ret); } +long BIO_callback_ctrl(BIO *b, int cmd, void (*fp)()) + { + long ret; + long (*cb)(); + + if (b == NULL) return(0); + + if ((b->method == NULL) || (b->method->callback_ctrl == NULL)) + { + BIOerr(BIO_F_BIO_CTRL,BIO_R_UNSUPPORTED_METHOD); + return(-2); + } + + cb=b->callback; + + if ((cb != NULL) && + ((ret=cb(b,BIO_CB_CTRL,(void *)&fp,cmd,0,1L)) <= 0)) + return(ret); + + ret=b->method->callback_ctrl(b,cmd,fp); + + if (cb != NULL) + ret=cb(b,BIO_CB_CTRL|BIO_CB_RETURN,(void *)&fp,cmd, + 0,ret); + return(ret); + } + /* It is unfortunate to duplicate in functions what the BIO_(w)pending macros * do; but those macros have inappropriate return type, and for interfacing * from other programming languages, C macros aren't much of a help anyway. */ size_t BIO_ctrl_pending(BIO *bio) - { + { return BIO_ctrl(bio, BIO_CTRL_PENDING, 0, NULL); } size_t BIO_ctrl_wpending(BIO *bio) - { + { return BIO_ctrl(bio, BIO_CTRL_WPENDING, 0, NULL); } @@ -476,21 +503,32 @@ void BIO_copy_next_retry(BIO *b) b->retry_reason=b->next_bio->retry_reason; } -int BIO_get_ex_new_index(long argl, char *argp, int (*new_func)(), - int (*dup_func)(), void (*free_func)()) +int BIO_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, + CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) { bio_meth_num++; return(CRYPTO_get_ex_new_index(bio_meth_num-1,&bio_meth, argl,argp,new_func,dup_func,free_func)); } -int BIO_set_ex_data(BIO *bio, int idx, char *data) +int BIO_set_ex_data(BIO *bio, int idx, void *data) { return(CRYPTO_set_ex_data(&(bio->ex_data),idx,data)); } -char *BIO_get_ex_data(BIO *bio, int idx) +void *BIO_get_ex_data(BIO *bio, int idx) { return(CRYPTO_get_ex_data(&(bio->ex_data),idx)); } +unsigned long BIO_number_read(BIO *bio) +{ + if(bio) return bio->num_read; + return 0; +} + +unsigned long BIO_number_written(BIO *bio) +{ + if(bio) return bio->num_write; + return 0; +} diff --git a/crypto/openssl/crypto/bio/bss_acpt.c b/crypto/openssl/crypto/bio/bss_acpt.c index 47af80f..9afa636 100644 --- a/crypto/openssl/crypto/bio/bss_acpt.c +++ b/crypto/openssl/crypto/bio/bss_acpt.c @@ -118,6 +118,7 @@ static BIO_METHOD methods_acceptp= acpt_ctrl, acpt_new, acpt_free, + NULL, }; BIO_METHOD *BIO_s_accept(void) diff --git a/crypto/openssl/crypto/bio/bss_bio.c b/crypto/openssl/crypto/bio/bss_bio.c index 562e9d8..1e2d749 100644 --- a/crypto/openssl/crypto/bio/bss_bio.c +++ b/crypto/openssl/crypto/bio/bss_bio.c @@ -13,13 +13,20 @@ #endif #include <assert.h> +#include <limits.h> #include <stdlib.h> #include <string.h> #include <openssl/bio.h> #include <openssl/err.h> +#include <openssl/err.h> #include <openssl/crypto.h> +#include "openssl/e_os.h" +#ifndef SSIZE_MAX +# define SSIZE_MAX INT_MAX +#endif + static int bio_new(BIO *bio); static int bio_free(BIO *bio); static int bio_read(BIO *bio, char *buf, int size); @@ -40,7 +47,8 @@ static BIO_METHOD methods_biop = NULL /* no bio_gets */, bio_ctrl, bio_new, - bio_free + bio_free, + NULL /* no bio_callback_ctrl */ }; BIO_METHOD *BIO_s_bio(void) @@ -64,7 +72,7 @@ struct bio_bio_st size_t request; /* valid iff peer != NULL; 0 if len != 0, * otherwise set by peer to number of bytes - * it (unsuccesfully) tried to read, + * it (unsuccessfully) tried to read, * never more than buffer space (size-len) warrants. */ }; @@ -195,6 +203,86 @@ static int bio_read(BIO *bio, char *buf, int size_) return size; } +/* non-copying interface: provide pointer to available data in buffer + * bio_nread0: return number of available bytes + * bio_nread: also advance index + * (example usage: bio_nread0(), read from buffer, bio_nread() + * or just bio_nread(), read from buffer) + */ +/* WARNING: The non-copying interface is largely untested as of yet + * and may contain bugs. */ +static ssize_t bio_nread0(BIO *bio, char **buf) + { + struct bio_bio_st *b, *peer_b; + ssize_t num; + + BIO_clear_retry_flags(bio); + + if (!bio->init) + return 0; + + b = bio->ptr; + assert(b != NULL); + assert(b->peer != NULL); + peer_b = b->peer->ptr; + assert(peer_b != NULL); + assert(peer_b->buf != NULL); + + peer_b->request = 0; + + if (peer_b->len == 0) + { + char dummy; + + /* avoid code duplication -- nothing available for reading */ + return bio_read(bio, &dummy, 1); /* returns 0 or -1 */ + } + + num = peer_b->len; + if (peer_b->size < peer_b->offset + num) + /* no ring buffer wrap-around for non-copying interface */ + num = peer_b->size - peer_b->offset; + assert(num > 0); + + if (buf != NULL) + *buf = peer_b->buf + peer_b->offset; + return num; + } + +static ssize_t bio_nread(BIO *bio, char **buf, size_t num_) + { + struct bio_bio_st *b, *peer_b; + ssize_t num, available; + + if (num_ > SSIZE_MAX) + num = SSIZE_MAX; + else + num = (ssize_t)num_; + + available = bio_nread0(bio, buf); + if (num > available) + num = available; + if (num <= 0) + return num; + + b = bio->ptr; + peer_b = b->peer->ptr; + + peer_b->len -= num; + if (peer_b->len) + { + peer_b->offset += num; + assert(peer_b->offset <= peer_b->size); + if (peer_b->offset == peer_b->size) + peer_b->offset = 0; + } + else + peer_b->offset = 0; + + return num; + } + + static int bio_write(BIO *bio, char *buf, int num_) { size_t num = num_; @@ -268,6 +356,83 @@ static int bio_write(BIO *bio, char *buf, int num_) return num; } +/* non-copying interface: provide pointer to region to write to + * bio_nwrite0: check how much space is available + * bio_nwrite: also increase length + * (example usage: bio_nwrite0(), write to buffer, bio_nwrite() + * or just bio_nwrite(), write to buffer) + */ +static ssize_t bio_nwrite0(BIO *bio, char **buf) + { + struct bio_bio_st *b; + size_t num; + size_t write_offset; + + BIO_clear_retry_flags(bio); + + if (!bio->init) + return 0; + + b = bio->ptr; + assert(b != NULL); + assert(b->peer != NULL); + assert(b->buf != NULL); + + b->request = 0; + if (b->closed) + { + BIOerr(BIO_F_BIO_NWRITE0, BIO_R_BROKEN_PIPE); + return -1; + } + + assert(b->len <= b->size); + + if (b->len == b->size) + { + BIO_set_retry_write(bio); + return -1; + } + + num = b->size - b->len; + write_offset = b->offset + b->len; + if (write_offset >= b->size) + write_offset -= b->size; + if (write_offset + num > b->size) + /* no ring buffer wrap-around for non-copying interface + * (to fulfil the promise by BIO_ctrl_get_write_guarantee, + * BIO_nwrite may have to be called twice) */ + num = b->size - write_offset; + + if (buf != NULL) + *buf = b->buf + write_offset; + assert(write_offset + num <= b->size); + + return num; + } + +static ssize_t bio_nwrite(BIO *bio, char **buf, size_t num_) + { + struct bio_bio_st *b; + ssize_t num, space; + + if (num_ > SSIZE_MAX) + num = SSIZE_MAX; + else + num = (ssize_t)num_; + + space = bio_nwrite0(bio, buf); + if (num > space) + num = space; + if (num <= 0) + return num; + b = bio->ptr; + assert(b != NULL); + b->len += num; + assert(b->len <= b->size); + + return num; + } + static long bio_ctrl(BIO *bio, int cmd, long num, void *ptr) { @@ -331,7 +496,7 @@ static long bio_ctrl(BIO *bio, int cmd, long num, void *ptr) case BIO_C_GET_WRITE_GUARANTEE: /* How many bytes can the caller feed to the next write - * withouth having to keep any? */ + * without having to keep any? */ if (b->peer == NULL || b->closed) ret = 0; else @@ -339,18 +504,47 @@ static long bio_ctrl(BIO *bio, int cmd, long num, void *ptr) break; case BIO_C_GET_READ_REQUEST: - /* If the peer unsuccesfully tried to read, how many bytes + /* If the peer unsuccessfully tried to read, how many bytes * were requested? (As with BIO_CTRL_PENDING, that number * can usually be treated as boolean.) */ ret = (long) b->request; break; + case BIO_C_RESET_READ_REQUEST: + /* Reset request. (Can be useful after read attempts + * at the other side that are meant to be non-blocking, + * e.g. when probing SSL_read to see if any data is + * available.) */ + b->request = 0; + ret = 1; + break; + case BIO_C_SHUTDOWN_WR: /* similar to shutdown(..., SHUT_WR) */ b->closed = 1; ret = 1; break; + case BIO_C_NREAD0: + /* prepare for non-copying read */ + ret = (long) bio_nread0(bio, ptr); + break; + + case BIO_C_NREAD: + /* non-copying read */ + ret = (long) bio_nread(bio, ptr, (size_t) num); + break; + + case BIO_C_NWRITE0: + /* prepare for non-copying write */ + ret = (long) bio_nwrite0(bio, ptr); + break; + + case BIO_C_NWRITE: + /* non-copying write */ + ret = (long) bio_nwrite(bio, ptr, (size_t) num); + break; + /* standard CTRL codes follow */ @@ -586,3 +780,78 @@ size_t BIO_ctrl_get_read_request(BIO *bio) { return BIO_ctrl(bio, BIO_C_GET_READ_REQUEST, 0, NULL); } + +int BIO_ctrl_reset_read_request(BIO *bio) + { + return (BIO_ctrl(bio, BIO_C_RESET_READ_REQUEST, 0, NULL) != 0); + } + + +/* BIO_nread0/nread/nwrite0/nwrite are available only for BIO pairs for now + * (conceivably some other BIOs could allow non-copying reads and writes too.) + */ +int BIO_nread0(BIO *bio, char **buf) + { + long ret; + + if (!bio->init) + { + BIOerr(BIO_F_BIO_NREAD0, BIO_R_UNINITIALIZED); + return -2; + } + + ret = BIO_ctrl(bio, BIO_C_NREAD0, 0, buf); + if (ret > INT_MAX) + return INT_MAX; + else + return (int) ret; + } + +int BIO_nread(BIO *bio, char **buf, int num) + { + int ret; + + if (!bio->init) + { + BIOerr(BIO_F_BIO_NREAD, BIO_R_UNINITIALIZED); + return -2; + } + + ret = (int) BIO_ctrl(bio, BIO_C_NREAD, num, buf); + if (ret > 0) + bio->num_read += ret; + return ret; + } + +int BIO_nwrite0(BIO *bio, char **buf) + { + long ret; + + if (!bio->init) + { + BIOerr(BIO_F_BIO_NWRITE0, BIO_R_UNINITIALIZED); + return -2; + } + + ret = BIO_ctrl(bio, BIO_C_NWRITE0, 0, buf); + if (ret > INT_MAX) + return INT_MAX; + else + return (int) ret; + } + +int BIO_nwrite(BIO *bio, char **buf, int num) + { + int ret; + + if (!bio->init) + { + BIOerr(BIO_F_BIO_NWRITE, BIO_R_UNINITIALIZED); + return -2; + } + + ret = BIO_ctrl(bio, BIO_C_NWRITE, num, buf); + if (ret > 0) + bio->num_read += ret; + return ret; + } diff --git a/crypto/openssl/crypto/bio/bss_conn.c b/crypto/openssl/crypto/bio/bss_conn.c index 68c46e3..22d00b3 100644 --- a/crypto/openssl/crypto/bio/bss_conn.c +++ b/crypto/openssl/crypto/bio/bss_conn.c @@ -90,11 +90,11 @@ typedef struct bio_connect_st struct sockaddr_in them; /* int socket; this will be kept in bio->num so that it is - * compatable with the bss_sock bio */ + * compatible with the bss_sock bio */ /* called when the connection is initially made * callback(BIO,state,ret); The callback should return - * 'ret'. state is for compatablity with the ssl info_callback */ + * 'ret'. state is for compatibility with the ssl info_callback */ int (*info_callback)(); } BIO_CONNECT; @@ -104,6 +104,7 @@ static int conn_puts(BIO *h,char *str); static long conn_ctrl(BIO *h,int cmd,long arg1,char *arg2); static int conn_new(BIO *h); static int conn_free(BIO *data); +static long conn_callback_ctrl(BIO *h,int cmd,void *(*fp)()); static int conn_state(BIO *b, BIO_CONNECT *c); static void conn_close_socket(BIO *data); @@ -121,6 +122,7 @@ static BIO_METHOD methods_connectp= conn_ctrl, conn_new, conn_free, + conn_callback_ctrl, }; static int conn_state(BIO *b, BIO_CONNECT *c) @@ -494,7 +496,7 @@ static long conn_ctrl(BIO *b, int cmd, long num, char *ptr) *((int *)ptr)=data->port; } if ((!b->init) || (ptr == NULL)) - *pptr="not initalised"; + *pptr="not initialized"; ret=1; } break; @@ -564,16 +566,25 @@ static long conn_ctrl(BIO *b, int cmd, long num, char *ptr) case BIO_CTRL_FLUSH: break; case BIO_CTRL_DUP: + { dbio=(BIO *)ptr; if (data->param_port) BIO_set_conn_port(dbio,data->param_port); if (data->param_hostname) BIO_set_conn_hostname(dbio,data->param_hostname); BIO_set_nbio(dbio,data->nbio); - (void)BIO_set_info_callback(dbio,data->info_callback); + (void)BIO_set_info_callback(dbio,(void *(*)())(data->info_callback)); + } break; case BIO_CTRL_SET_CALLBACK: - data->info_callback=(int (*)())ptr; + { +#if 0 /* FIXME: Should this be used? -- Richard Levitte */ + BIOerr(BIO_F_CONN_CTRL, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + ret = -1; +#else + ret=0; +#endif + } break; case BIO_CTRL_GET_CALLBACK: { @@ -590,6 +601,27 @@ static long conn_ctrl(BIO *b, int cmd, long num, char *ptr) return(ret); } +static long conn_callback_ctrl(BIO *b, int cmd, void *(*fp)()) + { + long ret=1; + BIO_CONNECT *data; + + data=(BIO_CONNECT *)b->ptr; + + switch (cmd) + { + case BIO_CTRL_SET_CALLBACK: + { + data->info_callback=(int (*)())fp; + } + break; + default: + ret=0; + break; + } + return(ret); + } + static int conn_puts(BIO *bp, char *str) { int n,ret; diff --git a/crypto/openssl/crypto/bio/bss_file.c b/crypto/openssl/crypto/bio/bss_file.c index 52c0c39..0d44dc3 100644 --- a/crypto/openssl/crypto/bio/bss_file.c +++ b/crypto/openssl/crypto/bio/bss_file.c @@ -91,6 +91,7 @@ static BIO_METHOD methods_filep= file_ctrl, file_new, file_free, + NULL, }; BIO *BIO_new_file(const char *filename, const char *mode) @@ -171,7 +172,7 @@ static int MS_CALLBACK file_write(BIO *b, char *in, int inl) if (fwrite(in,(int)inl,1,(FILE *)b->ptr)) ret=inl; /* ret=fwrite(in,1,(int)inl,(FILE *)b->ptr); */ - /* acording to Tim Hudson <tjh@cryptsoft.com>, the commented + /* according to Tim Hudson <tjh@cryptsoft.com>, the commented * out version above can cause 'inl' write calls under * some stupid stdio implementations (VMS) */ } diff --git a/crypto/openssl/crypto/bio/bss_log.c b/crypto/openssl/crypto/bio/bss_log.c index db82e75..497eb1a 100644 --- a/crypto/openssl/crypto/bio/bss_log.c +++ b/crypto/openssl/crypto/bio/bss_log.c @@ -57,8 +57,8 @@ Why BIO_s_log? BIO_s_log is useful for system daemons (or services under NT). - It is one-way BIO, it sends all stuff to syslogd (or event log - under NT). + It is one-way BIO, it sends all stuff to syslogd (on system that + commonly use that), or event log (on NT), or OPCOM (on OpenVMS). */ @@ -66,27 +66,58 @@ #include <stdio.h> #include <errno.h> -#ifndef WIN32 -#ifdef __ultrix -#include <sys/syslog.h> -#else -#include <syslog.h> -#endif +#if defined(WIN32) +# include <process.h> +#elif defined(VMS) || defined(__VMS) +# include <opcdef.h> +# include <descrip.h> +# include <lib$routines.h> +# include <starlet.h> +#elif defined(__ultrix) +# include <sys/syslog.h> +#elif !defined(MSDOS) /* Unix */ +# include <syslog.h> #endif #include "cryptlib.h" #include <openssl/buffer.h> #include <openssl/err.h> + #ifndef NO_SYSLOG +#if defined(WIN32) +#define LOG_EMERG 0 +#define LOG_ALERT 1 +#define LOG_CRIT 2 +#define LOG_ERR 3 +#define LOG_WARNING 4 +#define LOG_NOTICE 5 +#define LOG_INFO 6 +#define LOG_DEBUG 7 + +#define LOG_DAEMON (3<<3) +#elif defined(VMS) +/* On VMS, we don't really care about these, but we need them to compile */ +#define LOG_EMERG 0 +#define LOG_ALERT 1 +#define LOG_CRIT 2 +#define LOG_ERR 3 +#define LOG_WARNING 4 +#define LOG_NOTICE 5 +#define LOG_INFO 6 +#define LOG_DEBUG 7 + +#define LOG_DAEMON OPC$M_NM_NTWORK +#endif static int MS_CALLBACK slg_write(BIO *h,char *buf,int num); static int MS_CALLBACK slg_puts(BIO *h,char *str); static long MS_CALLBACK slg_ctrl(BIO *h,int cmd,long arg1,char *arg2); static int MS_CALLBACK slg_new(BIO *h); static int MS_CALLBACK slg_free(BIO *data); -static int xopenlog(BIO* bp, const char* name, int level); -static int xcloselog(BIO* bp); +static void xopenlog(BIO* bp, const char* name, int level); +static void xsyslog(BIO* bp, int priority, const char* string); +static void xcloselog(BIO* bp); static BIO_METHOD methods_slg= { @@ -98,6 +129,7 @@ static BIO_METHOD methods_slg= slg_ctrl, slg_new, slg_free, + NULL, }; BIO_METHOD *BIO_s_log(void) @@ -110,11 +142,7 @@ static int MS_CALLBACK slg_new(BIO *bi) bi->init=1; bi->num=0; bi->ptr=NULL; -#ifndef WIN32 xopenlog(bi, "application", LOG_DAEMON); -#else - xopenlog(bi, "application", 0); -#endif return(1); } @@ -130,38 +158,14 @@ static int MS_CALLBACK slg_write(BIO *b, char *in, int inl) int ret= inl; char* buf= in; char* pp; -#if defined(WIN32) - LPTSTR lpszStrings[1]; - WORD evtype= EVENTLOG_ERROR_TYPE; -#else int priority; -#endif if((buf= (char *)Malloc(inl+ 1)) == NULL){ return(0); } strncpy(buf, in, inl); buf[inl]= '\0'; -#if defined(WIN32) - if(strncmp(buf, "ERR ", 4) == 0){ - evtype= EVENTLOG_ERROR_TYPE; - pp= buf+ 4; - }else if(strncmp(buf, "WAR ", 4) == 0){ - evtype= EVENTLOG_WARNING_TYPE; - pp= buf+ 4; - }else if(strncmp(buf, "INF ", 4) == 0){ - evtype= EVENTLOG_INFORMATION_TYPE; - pp= buf+ 4; - }else{ - evtype= EVENTLOG_ERROR_TYPE; - pp= buf; - } - lpszStrings[0]= pp; - if(b->ptr) - ReportEvent(b->ptr, evtype, 0, 1024, NULL, 1, 0, - lpszStrings, NULL); -#else if(strncmp(buf, "ERR ", 4) == 0){ priority= LOG_ERR; pp= buf+ 4; @@ -176,8 +180,8 @@ static int MS_CALLBACK slg_write(BIO *b, char *in, int inl) pp= buf; } - syslog(priority, "%s", pp); -#endif + xsyslog(b, priority, pp); + Free(buf); return(ret); } @@ -205,28 +209,128 @@ static int MS_CALLBACK slg_puts(BIO *bp, char *str) return(ret); } -static int xopenlog(BIO* bp, const char* name, int level) -{ #if defined(WIN32) - if((bp->ptr= (char *)RegisterEventSource(NULL, name)) == NULL){ - return(0); - } -#else - openlog(name, LOG_PID|LOG_CONS, level); -#endif - return(1); + +static void xopenlog(BIO* bp, const char* name, int level) +{ + bp->ptr= (char *)RegisterEventSource(NULL, name); } -static int xcloselog(BIO* bp) +static void xsyslog(BIO *bp, int priority, const char *string) +{ + LPCSTR lpszStrings[2]; + WORD evtype= EVENTLOG_ERROR_TYPE; + int pid = _getpid(); + char pidbuf[20]; + + switch (priority) + { + case LOG_ERR: + evtype = EVENTLOG_ERROR_TYPE; + break; + case LOG_WARNING: + evtype = EVENTLOG_WARNING_TYPE; + break; + case LOG_INFO: + evtype = EVENTLOG_INFORMATION_TYPE; + break; + default: + evtype = EVENTLOG_ERROR_TYPE; + break; + } + + sprintf(pidbuf, "[%d] ", pid); + lpszStrings[0] = pidbuf; + lpszStrings[1] = string; + + if(bp->ptr) + ReportEvent(bp->ptr, evtype, 0, 1024, NULL, 2, 0, + lpszStrings, NULL); +} + +static void xcloselog(BIO* bp) { -#if defined(WIN32) if(bp->ptr) DeregisterEventSource((HANDLE)(bp->ptr)); bp->ptr= NULL; -#else +} + +#elif defined(VMS) + +static int VMS_OPC_target = LOG_DAEMON; + +static void xopenlog(BIO* bp, const char* name, int level) +{ + VMS_OPC_target = level; +} + +static void xsyslog(BIO *bp, int priority, const char *string) +{ + struct dsc$descriptor_s opc_dsc; + struct opcdef *opcdef_p; + char buf[10240]; + unsigned int len; + struct dsc$descriptor_s buf_dsc; + $DESCRIPTOR(fao_cmd, "!AZ: !AZ"); + char *priority_tag; + + switch (priority) + { + case LOG_EMERG: priority_tag = "Emergency"; break; + case LOG_ALERT: priority_tag = "Alert"; break; + case LOG_CRIT: priority_tag = "Critical"; break; + case LOG_ERR: priority_tag = "Error"; break; + case LOG_WARNING: priority_tag = "Warning"; break; + case LOG_NOTICE: priority_tag = "Notice"; break; + case LOG_INFO: priority_tag = "Info"; break; + case LOG_DEBUG: priority_tag = "DEBUG"; break; + } + + buf_dsc.dsc$b_dtype = DSC$K_DTYPE_T; + buf_dsc.dsc$b_class = DSC$K_CLASS_S; + buf_dsc.dsc$a_pointer = buf; + buf_dsc.dsc$w_length = sizeof(buf) - 1; + + lib$sys_fao(&fao_cmd, &len, &buf_dsc, priority_tag, string); + + /* we know there's an 8 byte header. That's documented */ + opcdef_p = (struct opcdef *) Malloc(8 + len); + opcdef_p->opc$b_ms_type = OPC$_RQ_RQST; + memcpy(opcdef_p->opc$z_ms_target_classes, &VMS_OPC_target, 3); + opcdef_p->opc$l_ms_rqstid = 0; + memcpy(&opcdef_p->opc$l_ms_text, buf, len); + + opc_dsc.dsc$b_dtype = DSC$K_DTYPE_T; + opc_dsc.dsc$b_class = DSC$K_CLASS_S; + opc_dsc.dsc$a_pointer = (char *)opcdef_p; + opc_dsc.dsc$w_length = len + 8; + + sys$sndopr(opc_dsc, 0); + + Free(opcdef_p); +} + +static void xcloselog(BIO* bp) +{ +} + +#else /* Unix */ + +static void xopenlog(BIO* bp, const char* name, int level) +{ + openlog(name, LOG_PID|LOG_CONS, level); +} + +static void xsyslog(BIO *bp, int priority, const char *string) +{ + syslog(priority, "%s", string); +} + +static void xcloselog(BIO* bp) +{ closelog(); -#endif - return(1); } -#endif +#endif /* Unix */ + +#endif /* NO_SYSLOG */ diff --git a/crypto/openssl/crypto/bio/bss_mem.c b/crypto/openssl/crypto/bio/bss_mem.c index 7e749a5..41eab92 100644 --- a/crypto/openssl/crypto/bio/bss_mem.c +++ b/crypto/openssl/crypto/bio/bss_mem.c @@ -79,6 +79,7 @@ static BIO_METHOD mem_method= mem_ctrl, mem_new, mem_free, + NULL, }; /* bio->num is used to hold the value to return on 'empty', if it is @@ -89,6 +90,26 @@ BIO_METHOD *BIO_s_mem(void) return(&mem_method); } +BIO *BIO_new_mem_buf(void *buf, int len) +{ + BIO *ret; + BUF_MEM *b; + if (!buf) { + BIOerr(BIO_F_BIO_NEW_MEM_BUF,BIO_R_NULL_PARAMETER); + return NULL; + } + if(len == -1) len = strlen(buf); + if(!(ret = BIO_new(BIO_s_mem())) ) return NULL; + b = (BUF_MEM *)ret->ptr; + b->data = buf; + b->length = len; + b->max = len; + ret->flags |= BIO_FLAGS_MEM_RDONLY; + /* Since this is static data retrying wont help */ + ret->num = 0; + return ret; +} + static int mem_new(BIO *bi) { BUF_MEM *b; @@ -109,7 +130,10 @@ static int mem_free(BIO *a) { if ((a->init) && (a->ptr != NULL)) { - BUF_MEM_free((BUF_MEM *)a->ptr); + BUF_MEM *b; + b = (BUF_MEM *)a->ptr; + if(a->flags & BIO_FLAGS_MEM_RDONLY) b->data = NULL; + BUF_MEM_free(b); a->ptr=NULL; } } @@ -126,17 +150,18 @@ static int mem_read(BIO *b, char *out, int outl) bm=(BUF_MEM *)b->ptr; BIO_clear_retry_flags(b); ret=(outl > bm->length)?bm->length:outl; - if ((out != NULL) && (ret > 0)) - { + if ((out != NULL) && (ret > 0)) { memcpy(out,bm->data,ret); bm->length-=ret; /* memmove(&(bm->data[0]),&(bm->data[ret]), bm->length); */ - from=(char *)&(bm->data[ret]); - to=(char *)&(bm->data[0]); - for (i=0; i<bm->length; i++) - to[i]=from[i]; + if(b->flags & BIO_FLAGS_MEM_RDONLY) bm->data += ret; + else { + from=(char *)&(bm->data[ret]); + to=(char *)&(bm->data[0]); + for (i=0; i<bm->length; i++) + to[i]=from[i]; } - else if (bm->length == 0) + } else if (bm->length == 0) { if (b->num != 0) BIO_set_retry_read(b); @@ -158,6 +183,11 @@ static int mem_write(BIO *b, char *in, int inl) goto end; } + if(b->flags & BIO_FLAGS_MEM_RDONLY) { + BIOerr(BIO_F_MEM_WRITE,BIO_R_WRITE_TO_READ_ONLY_BIO); + goto end; + } + BIO_clear_retry_flags(b); blen=bm->length; if (BUF_MEM_grow(bm,blen+inl) != (blen+inl)) @@ -178,9 +208,15 @@ static long mem_ctrl(BIO *b, int cmd, long num, char *ptr) switch (cmd) { case BIO_CTRL_RESET: - if (bm->data != NULL) - memset(bm->data,0,bm->max); - bm->length=0; + if (bm->data != NULL) { + /* For read only case reset to the start again */ + if(b->flags & BIO_FLAGS_MEM_RDONLY) + bm->data -= bm->max - bm->length; + else { + memset(bm->data,0,bm->max); + bm->length=0; + } + } break; case BIO_CTRL_EOF: ret=(long)(bm->length == 0); diff --git a/crypto/openssl/crypto/bio/bss_null.c b/crypto/openssl/crypto/bio/bss_null.c index d04be88..aee18e3 100644 --- a/crypto/openssl/crypto/bio/bss_null.c +++ b/crypto/openssl/crypto/bio/bss_null.c @@ -79,6 +79,7 @@ static BIO_METHOD null_method= null_ctrl, null_new, null_free, + NULL, }; BIO_METHOD *BIO_s_null(void) diff --git a/crypto/openssl/crypto/bio/bss_rtcp.c b/crypto/openssl/crypto/bio/bss_rtcp.c index 2ef0400..4ad0739 100644 --- a/crypto/openssl/crypto/bio/bss_rtcp.c +++ b/crypto/openssl/crypto/bio/bss_rtcp.c @@ -107,6 +107,7 @@ static BIO_METHOD rtcp_method= rtcp_ctrl, rtcp_new, rtcp_free, + NULL, }; BIO_METHOD *BIO_s_rtcp(void) diff --git a/crypto/openssl/crypto/bio/bss_sock.c b/crypto/openssl/crypto/bio/bss_sock.c index d336b99..8ce80ef 100644 --- a/crypto/openssl/crypto/bio/bss_sock.c +++ b/crypto/openssl/crypto/bio/bss_sock.c @@ -95,6 +95,7 @@ static BIO_METHOD methods_sockp= sock_ctrl, sock_new, sock_free, + NULL, }; BIO_METHOD *BIO_s_socket(void) @@ -112,6 +113,7 @@ static BIO_METHOD methods_fdp= fd_ctrl, fd_new, fd_free, + NULL, }; BIO_METHOD *BIO_s_fd(void) @@ -163,8 +165,7 @@ static int fd_free(BIO *a) if (a->init) { #ifndef BIO_FD - shutdown(a->num,2); - closesocket(a->num); + SHUTDOWN2(a->num); #else /* BIO_FD */ close(a->num); #endif |