summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bio
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/bio')
-rw-r--r--src/lib/libcrypto/bio/b_sock.c29
-rw-r--r--src/lib/libcrypto/bio/bf_nbio.c2
-rw-r--r--src/lib/libcrypto/bio/bio_lib.c4
-rw-r--r--src/lib/libcrypto/bio/bss_acpt.c5
-rw-r--r--src/lib/libcrypto/bio/bss_dgram.c20
-rw-r--r--src/lib/libcrypto/bio/bss_file.c12
-rw-r--r--src/lib/libcrypto/bio/bss_log.c32
7 files changed, 83 insertions, 21 deletions
diff --git a/src/lib/libcrypto/bio/b_sock.c b/src/lib/libcrypto/bio/b_sock.c
index 12b0a53a81..d47310d650 100644
--- a/src/lib/libcrypto/bio/b_sock.c
+++ b/src/lib/libcrypto/bio/b_sock.c
@@ -551,7 +551,30 @@ int BIO_socket_ioctl(int fd, long type, void *arg)
551#ifdef __DJGPP__ 551#ifdef __DJGPP__
552 i=ioctlsocket(fd,type,(char *)arg); 552 i=ioctlsocket(fd,type,(char *)arg);
553#else 553#else
554 i=ioctlsocket(fd,type,arg); 554# if defined(OPENSSL_SYS_VMS)
555 /* 2011-02-18 SMS.
556 * VMS ioctl() can't tolerate a 64-bit "void *arg", but we
557 * observe that all the consumers pass in an "unsigned long *",
558 * so we arrange a local copy with a short pointer, and use
559 * that, instead.
560 */
561# if __INITIAL_POINTER_SIZE == 64
562# define ARG arg_32p
563# pragma pointer_size save
564# pragma pointer_size 32
565 unsigned long arg_32;
566 unsigned long *arg_32p;
567# pragma pointer_size restore
568 arg_32p = &arg_32;
569 arg_32 = *((unsigned long *) arg);
570# else /* __INITIAL_POINTER_SIZE == 64 */
571# define ARG arg
572# endif /* __INITIAL_POINTER_SIZE == 64 [else] */
573# else /* defined(OPENSSL_SYS_VMS) */
574# define ARG arg
575# endif /* defined(OPENSSL_SYS_VMS) [else] */
576
577 i=ioctlsocket(fd,type,ARG);
555#endif /* __DJGPP__ */ 578#endif /* __DJGPP__ */
556 if (i < 0) 579 if (i < 0)
557 SYSerr(SYS_F_IOCTLSOCKET,get_last_socket_error()); 580 SYSerr(SYS_F_IOCTLSOCKET,get_last_socket_error());
@@ -660,6 +683,7 @@ int BIO_get_accept_socket(char *host, int bind_mode)
660 * note that commonly IPv6 wildchard socket can service 683 * note that commonly IPv6 wildchard socket can service
661 * IPv4 connections just as well... */ 684 * IPv4 connections just as well... */
662 memset(&hint,0,sizeof(hint)); 685 memset(&hint,0,sizeof(hint));
686 hint.ai_flags = AI_PASSIVE;
663 if (h) 687 if (h)
664 { 688 {
665 if (strchr(h,':')) 689 if (strchr(h,':'))
@@ -672,7 +696,10 @@ int BIO_get_accept_socket(char *host, int bind_mode)
672#endif 696#endif
673 } 697 }
674 else if (h[0]=='*' && h[1]=='\0') 698 else if (h[0]=='*' && h[1]=='\0')
699 {
700 hint.ai_family = AF_INET;
675 h=NULL; 701 h=NULL;
702 }
676 } 703 }
677 704
678 if ((*p_getaddrinfo.f)(h,p,&hint,&res)) break; 705 if ((*p_getaddrinfo.f)(h,p,&hint,&res)) break;
diff --git a/src/lib/libcrypto/bio/bf_nbio.c b/src/lib/libcrypto/bio/bf_nbio.c
index c72a23c2e1..028616c064 100644
--- a/src/lib/libcrypto/bio/bf_nbio.c
+++ b/src/lib/libcrypto/bio/bf_nbio.c
@@ -125,7 +125,6 @@ static int nbiof_free(BIO *a)
125 125
126static int nbiof_read(BIO *b, char *out, int outl) 126static int nbiof_read(BIO *b, char *out, int outl)
127 { 127 {
128 NBIO_TEST *nt;
129 int ret=0; 128 int ret=0;
130#if 1 129#if 1
131 int num; 130 int num;
@@ -134,7 +133,6 @@ static int nbiof_read(BIO *b, char *out, int outl)
134 133
135 if (out == NULL) return(0); 134 if (out == NULL) return(0);
136 if (b->next_bio == NULL) return(0); 135 if (b->next_bio == NULL) return(0);
137 nt=(NBIO_TEST *)b->ptr;
138 136
139 BIO_clear_retry_flags(b); 137 BIO_clear_retry_flags(b);
140#if 1 138#if 1
diff --git a/src/lib/libcrypto/bio/bio_lib.c b/src/lib/libcrypto/bio/bio_lib.c
index 77f4de9c32..e12bc3a2ca 100644
--- a/src/lib/libcrypto/bio/bio_lib.c
+++ b/src/lib/libcrypto/bio/bio_lib.c
@@ -110,7 +110,7 @@ int BIO_set(BIO *bio, BIO_METHOD *method)
110 110
111int BIO_free(BIO *a) 111int BIO_free(BIO *a)
112 { 112 {
113 int ret=0,i; 113 int i;
114 114
115 if (a == NULL) return(0); 115 if (a == NULL) return(0);
116 116
@@ -133,7 +133,7 @@ int BIO_free(BIO *a)
133 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, a, &a->ex_data); 133 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, a, &a->ex_data);
134 134
135 if ((a->method == NULL) || (a->method->destroy == NULL)) return(1); 135 if ((a->method == NULL) || (a->method->destroy == NULL)) return(1);
136 ret=a->method->destroy(a); 136 a->method->destroy(a);
137 OPENSSL_free(a); 137 OPENSSL_free(a);
138 return(1); 138 return(1);
139 } 139 }
diff --git a/src/lib/libcrypto/bio/bss_acpt.c b/src/lib/libcrypto/bio/bss_acpt.c
index 826f761143..5d49e1a72b 100644
--- a/src/lib/libcrypto/bio/bss_acpt.c
+++ b/src/lib/libcrypto/bio/bss_acpt.c
@@ -340,7 +340,6 @@ static int acpt_write(BIO *b, const char *in, int inl)
340 340
341static long acpt_ctrl(BIO *b, int cmd, long num, void *ptr) 341static long acpt_ctrl(BIO *b, int cmd, long num, void *ptr)
342 { 342 {
343 BIO *dbio;
344 int *ip; 343 int *ip;
345 long ret=1; 344 long ret=1;
346 BIO_ACCEPT *data; 345 BIO_ACCEPT *data;
@@ -437,8 +436,8 @@ static long acpt_ctrl(BIO *b, int cmd, long num, void *ptr)
437 ret=(long)data->bind_mode; 436 ret=(long)data->bind_mode;
438 break; 437 break;
439 case BIO_CTRL_DUP: 438 case BIO_CTRL_DUP:
440 dbio=(BIO *)ptr; 439/* dbio=(BIO *)ptr;
441/* if (data->param_port) EAY EAY 440 if (data->param_port) EAY EAY
442 BIO_set_port(dbio,data->param_port); 441 BIO_set_port(dbio,data->param_port);
443 if (data->param_hostname) 442 if (data->param_hostname)
444 BIO_set_hostname(dbio,data->param_hostname); 443 BIO_set_hostname(dbio,data->param_hostname);
diff --git a/src/lib/libcrypto/bio/bss_dgram.c b/src/lib/libcrypto/bio/bss_dgram.c
index eb7e365467..71ebe987b6 100644
--- a/src/lib/libcrypto/bio/bss_dgram.c
+++ b/src/lib/libcrypto/bio/bss_dgram.c
@@ -57,7 +57,6 @@
57 * 57 *
58 */ 58 */
59 59
60#ifndef OPENSSL_NO_DGRAM
61 60
62#include <stdio.h> 61#include <stdio.h>
63#include <errno.h> 62#include <errno.h>
@@ -65,6 +64,7 @@
65#include "cryptlib.h" 64#include "cryptlib.h"
66 65
67#include <openssl/bio.h> 66#include <openssl/bio.h>
67#ifndef OPENSSL_NO_DGRAM
68 68
69#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS) 69#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VMS)
70#include <sys/timeb.h> 70#include <sys/timeb.h>
@@ -308,7 +308,6 @@ static int dgram_read(BIO *b, char *out, int outl)
308 OPENSSL_assert(sa.len.s<=sizeof(sa.peer)); 308 OPENSSL_assert(sa.len.s<=sizeof(sa.peer));
309 sa.len.i = (int)sa.len.s; 309 sa.len.i = (int)sa.len.s;
310 } 310 }
311 dgram_reset_rcv_timeout(b);
312 311
313 if ( ! data->connected && ret >= 0) 312 if ( ! data->connected && ret >= 0)
314 BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, &sa.peer); 313 BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, &sa.peer);
@@ -322,6 +321,8 @@ static int dgram_read(BIO *b, char *out, int outl)
322 data->_errno = get_last_socket_error(); 321 data->_errno = get_last_socket_error();
323 } 322 }
324 } 323 }
324
325 dgram_reset_rcv_timeout(b);
325 } 326 }
326 return(ret); 327 return(ret);
327 } 328 }
@@ -340,7 +341,7 @@ static int dgram_write(BIO *b, const char *in, int inl)
340 341
341 if (data->peer.sa.sa_family == AF_INET) 342 if (data->peer.sa.sa_family == AF_INET)
342 peerlen = sizeof(data->peer.sa_in); 343 peerlen = sizeof(data->peer.sa_in);
343#if OPENSSL_USE_IVP6 344#if OPENSSL_USE_IPV6
344 else if (data->peer.sa.sa_family == AF_INET6) 345 else if (data->peer.sa.sa_family == AF_INET6)
345 peerlen = sizeof(data->peer.sa_in6); 346 peerlen = sizeof(data->peer.sa_in6);
346#endif 347#endif
@@ -745,9 +746,13 @@ static int BIO_dgram_should_retry(int i)
745 { 746 {
746 err=get_last_socket_error(); 747 err=get_last_socket_error();
747 748
748#if defined(OPENSSL_SYS_WINDOWS) && 0 /* more microsoft stupidity? perhaps not? Ben 4/1/99 */ 749#if defined(OPENSSL_SYS_WINDOWS)
749 if ((i == -1) && (err == 0)) 750 /* If the socket return value (i) is -1
750 return(1); 751 * and err is unexpectedly 0 at this point,
752 * the error code was overwritten by
753 * another system call before this error
754 * handling is called.
755 */
751#endif 756#endif
752 757
753 return(BIO_dgram_non_fatal_error(err)); 758 return(BIO_dgram_non_fatal_error(err));
@@ -810,7 +815,6 @@ int BIO_dgram_non_fatal_error(int err)
810 } 815 }
811 return(0); 816 return(0);
812 } 817 }
813#endif
814 818
815static void get_current_time(struct timeval *t) 819static void get_current_time(struct timeval *t)
816 { 820 {
@@ -828,3 +832,5 @@ static void get_current_time(struct timeval *t)
828 gettimeofday(t, NULL); 832 gettimeofday(t, NULL);
829#endif 833#endif
830 } 834 }
835
836#endif
diff --git a/src/lib/libcrypto/bio/bss_file.c b/src/lib/libcrypto/bio/bss_file.c
index 8bfa0bcd97..b954fe7ebc 100644
--- a/src/lib/libcrypto/bio/bss_file.c
+++ b/src/lib/libcrypto/bio/bss_file.c
@@ -123,6 +123,7 @@ BIO *BIO_new_file(const char *filename, const char *mode)
123 123
124#if defined(_WIN32) && defined(CP_UTF8) 124#if defined(_WIN32) && defined(CP_UTF8)
125 int sz, len_0 = (int)strlen(filename)+1; 125 int sz, len_0 = (int)strlen(filename)+1;
126 DWORD flags;
126 127
127 /* 128 /*
128 * Basically there are three cases to cover: a) filename is 129 * Basically there are three cases to cover: a) filename is
@@ -136,17 +137,22 @@ BIO *BIO_new_file(const char *filename, const char *mode)
136 * ERROR_NO_UNICODE_TRANSLATION, in which case we fall 137 * ERROR_NO_UNICODE_TRANSLATION, in which case we fall
137 * back to fopen... 138 * back to fopen...
138 */ 139 */
139 if ((sz=MultiByteToWideChar(CP_UTF8,MB_ERR_INVALID_CHARS, 140 if ((sz=MultiByteToWideChar(CP_UTF8,(flags=MB_ERR_INVALID_CHARS),
141 filename,len_0,NULL,0))>0 ||
142 (GetLastError()==ERROR_INVALID_FLAGS &&
143 (sz=MultiByteToWideChar(CP_UTF8,(flags=0),
140 filename,len_0,NULL,0))>0) 144 filename,len_0,NULL,0))>0)
145 )
141 { 146 {
142 WCHAR wmode[8]; 147 WCHAR wmode[8];
143 WCHAR *wfilename = _alloca(sz*sizeof(WCHAR)); 148 WCHAR *wfilename = _alloca(sz*sizeof(WCHAR));
144 149
145 if (MultiByteToWideChar(CP_UTF8,MB_ERR_INVALID_CHARS, 150 if (MultiByteToWideChar(CP_UTF8,flags,
146 filename,len_0,wfilename,sz) && 151 filename,len_0,wfilename,sz) &&
147 MultiByteToWideChar(CP_UTF8,0,mode,strlen(mode)+1, 152 MultiByteToWideChar(CP_UTF8,0,mode,strlen(mode)+1,
148 wmode,sizeof(wmode)/sizeof(wmode[0])) && 153 wmode,sizeof(wmode)/sizeof(wmode[0])) &&
149 (file=_wfopen(wfilename,wmode))==NULL && errno==ENOENT 154 (file=_wfopen(wfilename,wmode))==NULL &&
155 (errno==ENOENT || errno==EBADF)
150 ) /* UTF-8 decode succeeded, but no file, filename 156 ) /* UTF-8 decode succeeded, but no file, filename
151 * could still have been locale-ized... */ 157 * could still have been locale-ized... */
152 file = fopen(filename,mode); 158 file = fopen(filename,mode);
diff --git a/src/lib/libcrypto/bio/bss_log.c b/src/lib/libcrypto/bio/bss_log.c
index 7ead044b37..b7dce5c1a2 100644
--- a/src/lib/libcrypto/bio/bss_log.c
+++ b/src/lib/libcrypto/bio/bss_log.c
@@ -75,6 +75,15 @@
75# include <descrip.h> 75# include <descrip.h>
76# include <lib$routines.h> 76# include <lib$routines.h>
77# include <starlet.h> 77# include <starlet.h>
78/* Some compiler options may mask the declaration of "_malloc32". */
79# if __INITIAL_POINTER_SIZE && defined _ANSI_C_SOURCE
80# if __INITIAL_POINTER_SIZE == 64
81# pragma pointer_size save
82# pragma pointer_size 32
83 void * _malloc32 (__size_t);
84# pragma pointer_size restore
85# endif /* __INITIAL_POINTER_SIZE == 64 */
86# endif /* __INITIAL_POINTER_SIZE && defined _ANSI_C_SOURCE */
78#elif defined(__ultrix) 87#elif defined(__ultrix)
79# include <sys/syslog.h> 88# include <sys/syslog.h>
80#elif defined(OPENSSL_SYS_NETWARE) 89#elif defined(OPENSSL_SYS_NETWARE)
@@ -300,7 +309,24 @@ static void xopenlog(BIO* bp, char* name, int level)
300static void xsyslog(BIO *bp, int priority, const char *string) 309static void xsyslog(BIO *bp, int priority, const char *string)
301{ 310{
302 struct dsc$descriptor_s opc_dsc; 311 struct dsc$descriptor_s opc_dsc;
312
313/* Arrange 32-bit pointer to opcdef buffer and malloc(), if needed. */
314#if __INITIAL_POINTER_SIZE == 64
315# pragma pointer_size save
316# pragma pointer_size 32
317# define OPCDEF_TYPE __char_ptr32
318# define OPCDEF_MALLOC _malloc32
319#else /* __INITIAL_POINTER_SIZE == 64 */
320# define OPCDEF_TYPE char *
321# define OPCDEF_MALLOC OPENSSL_malloc
322#endif /* __INITIAL_POINTER_SIZE == 64 [else] */
323
303 struct opcdef *opcdef_p; 324 struct opcdef *opcdef_p;
325
326#if __INITIAL_POINTER_SIZE == 64
327# pragma pointer_size restore
328#endif /* __INITIAL_POINTER_SIZE == 64 */
329
304 char buf[10240]; 330 char buf[10240];
305 unsigned int len; 331 unsigned int len;
306 struct dsc$descriptor_s buf_dsc; 332 struct dsc$descriptor_s buf_dsc;
@@ -326,8 +352,8 @@ static void xsyslog(BIO *bp, int priority, const char *string)
326 352
327 lib$sys_fao(&fao_cmd, &len, &buf_dsc, priority_tag, string); 353 lib$sys_fao(&fao_cmd, &len, &buf_dsc, priority_tag, string);
328 354
329 /* we know there's an 8 byte header. That's documented */ 355 /* We know there's an 8-byte header. That's documented. */
330 opcdef_p = (struct opcdef *) OPENSSL_malloc(8 + len); 356 opcdef_p = OPCDEF_MALLOC( 8+ len);
331 opcdef_p->opc$b_ms_type = OPC$_RQ_RQST; 357 opcdef_p->opc$b_ms_type = OPC$_RQ_RQST;
332 memcpy(opcdef_p->opc$z_ms_target_classes, &VMS_OPC_target, 3); 358 memcpy(opcdef_p->opc$z_ms_target_classes, &VMS_OPC_target, 3);
333 opcdef_p->opc$l_ms_rqstid = 0; 359 opcdef_p->opc$l_ms_rqstid = 0;
@@ -335,7 +361,7 @@ static void xsyslog(BIO *bp, int priority, const char *string)
335 361
336 opc_dsc.dsc$b_dtype = DSC$K_DTYPE_T; 362 opc_dsc.dsc$b_dtype = DSC$K_DTYPE_T;
337 opc_dsc.dsc$b_class = DSC$K_CLASS_S; 363 opc_dsc.dsc$b_class = DSC$K_CLASS_S;
338 opc_dsc.dsc$a_pointer = (char *)opcdef_p; 364 opc_dsc.dsc$a_pointer = (OPCDEF_TYPE) opcdef_p;
339 opc_dsc.dsc$w_length = len + 8; 365 opc_dsc.dsc$w_length = len + 8;
340 366
341 sys$sndopr(opc_dsc, 0); 367 sys$sndopr(opc_dsc, 0);