summaryrefslogtreecommitdiffstats
path: root/crypto/bio
diff options
context:
space:
mode:
authorNagendra Modadugu <ngm@google.com>2009-09-30 11:36:48 -0700
committerNagendra Modadugu <ngm@google.com>2009-09-30 12:06:07 -0700
commite45f106cb6b47af1f21efe76e933bdea2f5dd1ca (patch)
tree9abf212990e6e7631ac6b0a07816dfe069912724 /crypto/bio
parent5fe11ead41a8b9709f910786101e818603de6690 (diff)
downloadreplicant_openssl-e45f106cb6b47af1f21efe76e933bdea2f5dd1ca.zip
replicant_openssl-e45f106cb6b47af1f21efe76e933bdea2f5dd1ca.tar.gz
replicant_openssl-e45f106cb6b47af1f21efe76e933bdea2f5dd1ca.tar.bz2
Upgrade to openssl-0.9.8k.
The source tree (and the size of the compiled library) can be reduced further. This will be done in a future commit.
Diffstat (limited to 'crypto/bio')
-rw-r--r--crypto/bio/Makefile2
-rw-r--r--crypto/bio/bss_bio.c2
-rw-r--r--crypto/bio/bss_dgram.c64
-rw-r--r--crypto/bio/bss_file.c2
-rw-r--r--crypto/bio/bss_mem.c22
-rw-r--r--crypto/bio/bss_sock.c5
6 files changed, 82 insertions, 15 deletions
diff --git a/crypto/bio/Makefile b/crypto/bio/Makefile
index 1ef6c2f..1cd76ce 100644
--- a/crypto/bio/Makefile
+++ b/crypto/bio/Makefile
@@ -45,7 +45,7 @@ top:
all: lib
lib: $(LIBOBJ)
- $(AR) $(LIB) $(LIBOBJ)
+ $(ARX) $(LIB) $(LIBOBJ)
$(RANLIB) $(LIB) || echo Never mind.
@touch lib
diff --git a/crypto/bio/bss_bio.c b/crypto/bio/bss_bio.c
index 0f9f095..76bd48e 100644
--- a/crypto/bio/bss_bio.c
+++ b/crypto/bio/bss_bio.c
@@ -919,6 +919,6 @@ int BIO_nwrite(BIO *bio, char **buf, int num)
ret = BIO_ctrl(bio, BIO_C_NWRITE, num, buf);
if (ret > 0)
- bio->num_read += ret;
+ bio->num_write += ret;
return ret;
}
diff --git a/crypto/bio/bss_dgram.c b/crypto/bio/bss_dgram.c
index ea2c3ff..c3da6dc 100644
--- a/crypto/bio/bss_dgram.c
+++ b/crypto/bio/bss_dgram.c
@@ -82,7 +82,7 @@ static int dgram_new(BIO *h);
static int dgram_free(BIO *data);
static int dgram_clear(BIO *bio);
-int BIO_dgram_should_retry(int s);
+static int BIO_dgram_should_retry(int s);
static BIO_METHOD methods_dgramp=
{
@@ -345,30 +345,90 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
memcpy(&(data->peer), to, sizeof(struct sockaddr));
break;
+#if defined(SO_RCVTIMEO)
case BIO_CTRL_DGRAM_SET_RECV_TIMEOUT:
+#ifdef OPENSSL_SYS_WINDOWS
+ {
+ struct timeval *tv = (struct timeval *)ptr;
+ int timeout = tv->tv_sec * 1000 + tv->tv_usec/1000;
+ if (setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO,
+ (void*)&timeout, sizeof(timeout)) < 0)
+ { perror("setsockopt"); ret = -1; }
+ }
+#else
if ( setsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO, ptr,
sizeof(struct timeval)) < 0)
{ perror("setsockopt"); ret = -1; }
+#endif
break;
case BIO_CTRL_DGRAM_GET_RECV_TIMEOUT:
+#ifdef OPENSSL_SYS_WINDOWS
+ {
+ int timeout, sz = sizeof(timeout);
+ struct timeval *tv = (struct timeval *)ptr;
+ if (getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO,
+ (void*)&timeout, &sz) < 0)
+ { perror("getsockopt"); ret = -1; }
+ else
+ {
+ tv->tv_sec = timeout / 1000;
+ tv->tv_usec = (timeout % 1000) * 1000;
+ ret = sizeof(*tv);
+ }
+ }
+#else
if ( getsockopt(b->num, SOL_SOCKET, SO_RCVTIMEO,
ptr, (void *)&ret) < 0)
{ perror("getsockopt"); ret = -1; }
+#endif
break;
+#endif
+#if defined(SO_SNDTIMEO)
case BIO_CTRL_DGRAM_SET_SEND_TIMEOUT:
+#ifdef OPENSSL_SYS_WINDOWS
+ {
+ struct timeval *tv = (struct timeval *)ptr;
+ int timeout = tv->tv_sec * 1000 + tv->tv_usec/1000;
+ if (setsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO,
+ (void*)&timeout, sizeof(timeout)) < 0)
+ { perror("setsockopt"); ret = -1; }
+ }
+#else
if ( setsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO, ptr,
sizeof(struct timeval)) < 0)
{ perror("setsockopt"); ret = -1; }
+#endif
break;
case BIO_CTRL_DGRAM_GET_SEND_TIMEOUT:
+#ifdef OPENSSL_SYS_WINDOWS
+ {
+ int timeout, sz = sizeof(timeout);
+ struct timeval *tv = (struct timeval *)ptr;
+ if (getsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO,
+ (void*)&timeout, &sz) < 0)
+ { perror("getsockopt"); ret = -1; }
+ else
+ {
+ tv->tv_sec = timeout / 1000;
+ tv->tv_usec = (timeout % 1000) * 1000;
+ ret = sizeof(*tv);
+ }
+ }
+#else
if ( getsockopt(b->num, SOL_SOCKET, SO_SNDTIMEO,
ptr, (void *)&ret) < 0)
{ perror("getsockopt"); ret = -1; }
+#endif
break;
+#endif
case BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP:
/* fall-through */
case BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP:
+#ifdef OPENSSL_SYS_WINDOWS
+ if ( data->_errno == WSAETIMEDOUT)
+#else
if ( data->_errno == EAGAIN)
+#endif
{
ret = 1;
data->_errno = 0;
@@ -403,7 +463,7 @@ static int dgram_puts(BIO *bp, const char *str)
return(ret);
}
-int BIO_dgram_should_retry(int i)
+static int BIO_dgram_should_retry(int i)
{
int err;
diff --git a/crypto/bio/bss_file.c b/crypto/bio/bss_file.c
index 4df9927..9ad46fa 100644
--- a/crypto/bio/bss_file.c
+++ b/crypto/bio/bss_file.c
@@ -279,7 +279,7 @@ static long MS_CALLBACK file_ctrl(BIO *b, int cmd, long num, void *ptr)
#endif
{
#if defined(OPENSSL_SYS_WINDOWS)
- int fd = fileno((FILE*)ptr);
+ int fd = _fileno((FILE*)ptr);
if (num & BIO_FP_TEXT)
_setmode(fd,_O_TEXT);
else
diff --git a/crypto/bio/bss_mem.c b/crypto/bio/bss_mem.c
index a4edb71..e7ab9cb 100644
--- a/crypto/bio/bss_mem.c
+++ b/crypto/bio/bss_mem.c
@@ -284,6 +284,7 @@ static int mem_gets(BIO *bp, char *buf, int size)
BIO_clear_retry_flags(bp);
j=bm->length;
+ if ((size-1) < j) j=size-1;
if (j <= 0)
{
*buf='\0';
@@ -292,17 +293,18 @@ static int mem_gets(BIO *bp, char *buf, int size)
p=bm->data;
for (i=0; i<j; i++)
{
- if (p[i] == '\n') break;
- }
- if (i == j)
- {
- BIO_set_retry_read(bp);
- /* return(-1); change the semantics 0.6.6a */
+ if (p[i] == '\n')
+ {
+ i++;
+ break;
+ }
}
- else
- i++;
- /* i is the max to copy */
- if ((size-1) < i) i=size-1;
+
+ /*
+ * i is now the max num of bytes to copy, either j or up to
+ * and including the first newline
+ */
+
i=mem_read(bp,buf,i);
if (i > 0) buf[i]='\0';
ret=i;
diff --git a/crypto/bio/bss_sock.c b/crypto/bio/bss_sock.c
index 472dd75..30c3cea 100644
--- a/crypto/bio/bss_sock.c
+++ b/crypto/bio/bss_sock.c
@@ -60,6 +60,9 @@
#include <errno.h>
#define USE_SOCKETS
#include "cryptlib.h"
+
+#ifndef OPENSSL_NO_SOCK
+
#include <openssl/bio.h>
#ifdef WATT32
@@ -300,3 +303,5 @@ int BIO_sock_non_fatal_error(int err)
}
return(0);
}
+
+#endif /* #ifndef OPENSSL_NO_SOCK */