summaryrefslogtreecommitdiff
path: root/deps/openssl/openssl/crypto/bio
diff options
context:
space:
mode:
Diffstat (limited to 'deps/openssl/openssl/crypto/bio')
-rw-r--r--deps/openssl/openssl/crypto/bio/b_addr.c53
-rw-r--r--deps/openssl/openssl/crypto/bio/b_dump.c67
-rw-r--r--deps/openssl/openssl/crypto/bio/b_print.c88
-rw-r--r--deps/openssl/openssl/crypto/bio/b_sock.c37
-rw-r--r--deps/openssl/openssl/crypto/bio/b_sock2.c90
-rw-r--r--deps/openssl/openssl/crypto/bio/bf_buff.c84
-rw-r--r--deps/openssl/openssl/crypto/bio/bf_lbuf.c62
-rw-r--r--deps/openssl/openssl/crypto/bio/bf_nbio.c52
-rw-r--r--deps/openssl/openssl/crypto/bio/bf_null.c34
-rw-r--r--deps/openssl/openssl/crypto/bio/bio_cb.c39
-rw-r--r--deps/openssl/openssl/crypto/bio/bio_err.c211
-rw-r--r--deps/openssl/openssl/crypto/bio/bio_lcl.h10
-rw-r--r--deps/openssl/openssl/crypto/bio/bio_lib.c416
-rw-r--r--deps/openssl/openssl/crypto/bio/bio_meth.c77
-rw-r--r--deps/openssl/openssl/crypto/bio/bss_acpt.c48
-rw-r--r--deps/openssl/openssl/crypto/bio/bss_bio.c9
-rw-r--r--deps/openssl/openssl/crypto/bio/bss_conn.c57
-rw-r--r--deps/openssl/openssl/crypto/bio/bss_dgram.c120
-rw-r--r--deps/openssl/openssl/crypto/bio/bss_fd.c41
-rw-r--r--deps/openssl/openssl/crypto/bio/bss_file.c52
-rw-r--r--deps/openssl/openssl/crypto/bio/bss_log.c24
-rw-r--r--deps/openssl/openssl/crypto/bio/bss_mem.c60
-rw-r--r--deps/openssl/openssl/crypto/bio/bss_null.c18
-rw-r--r--deps/openssl/openssl/crypto/bio/bss_sock.c34
24 files changed, 1084 insertions, 699 deletions
diff --git a/deps/openssl/openssl/crypto/bio/b_addr.c b/deps/openssl/openssl/crypto/bio/b_addr.c
index 6ed1652c8a..abec7bb8db 100644
--- a/deps/openssl/openssl/crypto/bio/b_addr.c
+++ b/deps/openssl/openssl/crypto/bio/b_addr.c
@@ -7,6 +7,7 @@
* https://www.openssl.org/source/license.html
*/
+#include <assert.h>
#include <string.h>
#include "bio_lcl.h"
@@ -15,8 +16,7 @@
#ifndef OPENSSL_NO_SOCK
#include <openssl/err.h>
#include <openssl/buffer.h>
-#include <internal/thread_once.h>
-#include <ctype.h>
+#include "internal/thread_once.h"
CRYPTO_RWLOCK *bio_lookup_lock;
static CRYPTO_ONCE bio_lookup_init = CRYPTO_ONCE_STATIC_INIT;
@@ -565,11 +565,10 @@ static int addrinfo_wrap(int family, int socktype,
unsigned short port,
BIO_ADDRINFO **bai)
{
- OPENSSL_assert(bai != NULL);
-
- *bai = OPENSSL_zalloc(sizeof(**bai));
- if (*bai == NULL)
+ if ((*bai = OPENSSL_zalloc(sizeof(**bai))) == NULL) {
+ BIOerr(BIO_F_ADDRINFO_WRAP, ERR_R_MALLOC_FAILURE);
return 0;
+ }
(*bai)->bai_family = family;
(*bai)->bai_socktype = socktype;
@@ -610,8 +609,15 @@ DEFINE_RUN_ONCE_STATIC(do_bio_lookup_init)
return bio_lookup_lock != NULL;
}
+int BIO_lookup(const char *host, const char *service,
+ enum BIO_lookup_type lookup_type,
+ int family, int socktype, BIO_ADDRINFO **res)
+{
+ return BIO_lookup_ex(host, service, lookup_type, family, socktype, 0, res);
+}
+
/*-
- * BIO_lookup - look up the node and service you want to connect to.
+ * BIO_lookup_ex - look up the node and service you want to connect to.
* @node: the node you want to connect to.
* @service: the service you want to connect to.
* @lookup_type: declare intent with the result, client or server.
@@ -619,6 +625,10 @@ DEFINE_RUN_ONCE_STATIC(do_bio_lookup_init)
* AF_INET, AF_INET6 or AF_UNIX.
* @socktype: The socket type you want to use. Can be SOCK_STREAM, SOCK_DGRAM
* or 0 for all.
+ * @protocol: The protocol to use, e.g. IPPROTO_TCP or IPPROTO_UDP or 0 for all.
+ * Note that some platforms may not return IPPROTO_SCTP without
+ * explicitly requesting it (i.e. IPPROTO_SCTP may not be returned
+ * with 0 for the protocol)
* @res: Storage place for the resulting list of returned addresses
*
* This will do a lookup of the node and service that you want to connect to.
@@ -628,9 +638,8 @@ DEFINE_RUN_ONCE_STATIC(do_bio_lookup_init)
*
* The return value is 1 on success or 0 in case of error.
*/
-int BIO_lookup(const char *host, const char *service,
- enum BIO_lookup_type lookup_type,
- int family, int socktype, BIO_ADDRINFO **res)
+int BIO_lookup_ex(const char *host, const char *service, int lookup_type,
+ int family, int socktype, int protocol, BIO_ADDRINFO **res)
{
int ret = 0; /* Assume failure */
@@ -647,7 +656,7 @@ int BIO_lookup(const char *host, const char *service,
#endif
break;
default:
- BIOerr(BIO_F_BIO_LOOKUP, BIO_R_UNSUPPORTED_PROTOCOL_FAMILY);
+ BIOerr(BIO_F_BIO_LOOKUP_EX, BIO_R_UNSUPPORTED_PROTOCOL_FAMILY);
return 0;
}
@@ -656,7 +665,7 @@ int BIO_lookup(const char *host, const char *service,
if (addrinfo_wrap(family, socktype, host, strlen(host), 0, res))
return 1;
else
- BIOerr(BIO_F_BIO_LOOKUP, ERR_R_MALLOC_FAILURE);
+ BIOerr(BIO_F_BIO_LOOKUP_EX, ERR_R_MALLOC_FAILURE);
return 0;
}
#endif
@@ -673,6 +682,7 @@ int BIO_lookup(const char *host, const char *service,
hints.ai_family = family;
hints.ai_socktype = socktype;
+ hints.ai_protocol = protocol;
if (lookup_type == BIO_LOOKUP_SERVER)
hints.ai_flags |= AI_PASSIVE;
@@ -684,14 +694,14 @@ int BIO_lookup(const char *host, const char *service,
# ifdef EAI_SYSTEM
case EAI_SYSTEM:
SYSerr(SYS_F_GETADDRINFO, get_last_socket_error());
- BIOerr(BIO_F_BIO_LOOKUP, ERR_R_SYS_LIB);
+ BIOerr(BIO_F_BIO_LOOKUP_EX, ERR_R_SYS_LIB);
break;
# endif
case 0:
ret = 1; /* Success */
break;
default:
- BIOerr(BIO_F_BIO_LOOKUP, ERR_R_SYS_LIB);
+ BIOerr(BIO_F_BIO_LOOKUP_EX, ERR_R_SYS_LIB);
ERR_add_error_data(1, gai_strerror(gai_ret));
break;
}
@@ -733,7 +743,7 @@ int BIO_lookup(const char *host, const char *service,
#endif
if (!RUN_ONCE(&bio_lookup_init, do_bio_lookup_init)) {
- BIOerr(BIO_F_BIO_LOOKUP, ERR_R_MALLOC_FAILURE);
+ BIOerr(BIO_F_BIO_LOOKUP_EX, ERR_R_MALLOC_FAILURE);
ret = 0;
goto err;
}
@@ -750,8 +760,11 @@ int BIO_lookup(const char *host, const char *service,
he_fallback_address = INADDR_ANY;
break;
default:
- OPENSSL_assert(("We forgot to handle a lookup type!" == 0));
- break;
+ /* We forgot to handle a lookup type! */
+ assert("We forgot to handle a lookup type!" == NULL);
+ BIOerr(BIO_F_BIO_LOOKUP_EX, ERR_R_INTERNAL_ERROR);
+ ret = 0;
+ goto err;
}
} else {
he = gethostbyname(host);
@@ -810,7 +823,7 @@ int BIO_lookup(const char *host, const char *service,
if (endp != service && *endp == '\0'
&& portnum > 0 && portnum < 65536) {
- se_fallback.s_port = htons(portnum);
+ se_fallback.s_port = htons((unsigned short)portnum);
se_fallback.s_proto = proto;
se = &se_fallback;
} else if (endp == service) {
@@ -825,7 +838,7 @@ int BIO_lookup(const char *host, const char *service,
goto err;
}
} else {
- BIOerr(BIO_F_BIO_LOOKUP, BIO_R_MALFORMED_HOST_OR_SERVICE);
+ BIOerr(BIO_F_BIO_LOOKUP_EX, BIO_R_MALFORMED_HOST_OR_SERVICE);
goto err;
}
}
@@ -867,7 +880,7 @@ int BIO_lookup(const char *host, const char *service,
addrinfo_malloc_err:
BIO_ADDRINFO_free(*res);
*res = NULL;
- BIOerr(BIO_F_BIO_LOOKUP, ERR_R_MALLOC_FAILURE);
+ BIOerr(BIO_F_BIO_LOOKUP_EX, ERR_R_MALLOC_FAILURE);
ret = 0;
goto err;
}
diff --git a/deps/openssl/openssl/crypto/bio/b_dump.c b/deps/openssl/openssl/crypto/bio/b_dump.c
index 424195e16b..0d06414e7d 100644
--- a/deps/openssl/openssl/crypto/bio/b_dump.c
+++ b/deps/openssl/openssl/crypto/bio/b_dump.c
@@ -15,7 +15,9 @@
#include "bio_lcl.h"
#define DUMP_WIDTH 16
-#define DUMP_WIDTH_LESS_INDENT(i) (DUMP_WIDTH-((i-(i>6?6:i)+3)/4))
+#define DUMP_WIDTH_LESS_INDENT(i) (DUMP_WIDTH - ((i - (i > 6 ? 6 : i) + 3) / 4))
+
+#define SPACE(buf, pos, n) (sizeof(buf) - (pos) > (n))
int BIO_dump_cb(int (*cb) (const void *data, size_t len, void *u),
void *u, const char *s, int len)
@@ -27,60 +29,63 @@ int BIO_dump_indent_cb(int (*cb) (const void *data, size_t len, void *u),
void *u, const char *s, int len, int indent)
{
int ret = 0;
- char buf[288 + 1], tmp[20], str[128 + 1];
- int i, j, rows;
+ char buf[288 + 1];
+ int i, j, rows, n;
unsigned char ch;
int dump_width;
if (indent < 0)
indent = 0;
- if (indent) {
- if (indent > 128)
- indent = 128;
- memset(str, ' ', indent);
- }
- str[indent] = '\0';
+ else if (indent > 128)
+ indent = 128;
dump_width = DUMP_WIDTH_LESS_INDENT(indent);
- rows = (len / dump_width);
+ rows = len / dump_width;
if ((rows * dump_width) < len)
rows++;
for (i = 0; i < rows; i++) {
- OPENSSL_strlcpy(buf, str, sizeof(buf));
- BIO_snprintf(tmp, sizeof(tmp), "%04x - ", i * dump_width);
- OPENSSL_strlcat(buf, tmp, sizeof(buf));
+ n = BIO_snprintf(buf, sizeof(buf), "%*s%04x - ", indent, "",
+ i * dump_width);
for (j = 0; j < dump_width; j++) {
- if (((i * dump_width) + j) >= len) {
- OPENSSL_strlcat(buf, " ", sizeof(buf));
- } else {
- ch = ((unsigned char)*(s + i * dump_width + j)) & 0xff;
- BIO_snprintf(tmp, sizeof(tmp), "%02x%c", ch,
- j == 7 ? '-' : ' ');
- OPENSSL_strlcat(buf, tmp, sizeof(buf));
+ if (SPACE(buf, n, 3)) {
+ if (((i * dump_width) + j) >= len) {
+ strcpy(buf + n, " ");
+ } else {
+ ch = ((unsigned char)*(s + i * dump_width + j)) & 0xff;
+ BIO_snprintf(buf + n, 4, "%02x%c", ch,
+ j == 7 ? '-' : ' ');
+ }
+ n += 3;
}
}
- OPENSSL_strlcat(buf, " ", sizeof(buf));
+ if (SPACE(buf, n, 2)) {
+ strcpy(buf + n, " ");
+ n += 2;
+ }
for (j = 0; j < dump_width; j++) {
if (((i * dump_width) + j) >= len)
break;
- ch = ((unsigned char)*(s + i * dump_width + j)) & 0xff;
+ if (SPACE(buf, n, 1)) {
+ ch = ((unsigned char)*(s + i * dump_width + j)) & 0xff;
#ifndef CHARSET_EBCDIC
- BIO_snprintf(tmp, sizeof(tmp), "%c",
- ((ch >= ' ') && (ch <= '~')) ? ch : '.');
+ buf[n++] = ((ch >= ' ') && (ch <= '~')) ? ch : '.';
#else
- BIO_snprintf(tmp, sizeof(tmp), "%c",
- ((ch >= os_toascii[' ']) && (ch <= os_toascii['~']))
- ? os_toebcdic[ch]
- : '.');
+ buf[n++] = ((ch >= os_toascii[' ']) && (ch <= os_toascii['~']))
+ ? os_toebcdic[ch]
+ : '.';
#endif
- OPENSSL_strlcat(buf, tmp, sizeof(buf));
+ buf[n] = '\0';
+ }
+ }
+ if (SPACE(buf, n, 1)) {
+ buf[n++] = '\n';
+ buf[n] = '\0';
}
- OPENSSL_strlcat(buf, "\n", sizeof(buf));
/*
* if this is the last call then update the ddt_dump thing so that we
* will move the selection point in the debug window
*/
- ret += cb((void *)buf, strlen(buf), u);
+ ret += cb((void *)buf, n, u);
}
return ret;
}
diff --git a/deps/openssl/openssl/crypto/bio/b_print.c b/deps/openssl/openssl/crypto/bio/b_print.c
index 8f50cb8c14..9e907fcaa7 100644
--- a/deps/openssl/openssl/crypto/bio/b_print.c
+++ b/deps/openssl/openssl/crypto/bio/b_print.c
@@ -9,10 +9,10 @@
#include <stdio.h>
#include <string.h>
-#include <ctype.h>
-#include <openssl/bio.h>
#include "internal/cryptlib.h"
+#include "internal/ctype.h"
#include "internal/numbers.h"
+#include <openssl/bio.h>
/*
* Copyright Patrick Powell 1995
@@ -69,6 +69,7 @@ static int _dopr(char **sbuffer, char **buffer,
#define DP_C_LONG 2
#define DP_C_LDOUBLE 3
#define DP_C_LLONG 4
+#define DP_C_SIZE 5
/* Floating point formats */
#define F_FORMAT 0
@@ -110,7 +111,7 @@ _dopr(char **sbuffer,
if (ch == '%')
state = DP_S_FLAGS;
else
- if(!doapr_outch(sbuffer, buffer, &currlen, maxlen, ch))
+ if (!doapr_outch(sbuffer, buffer, &currlen, maxlen, ch))
return 0;
ch = *format++;
break;
@@ -142,7 +143,7 @@ _dopr(char **sbuffer,
}
break;
case DP_S_MIN:
- if (isdigit((unsigned char)ch)) {
+ if (ossl_isdigit(ch)) {
min = 10 * min + char_to_int(ch);
ch = *format++;
} else if (ch == '*') {
@@ -160,7 +161,7 @@ _dopr(char **sbuffer,
state = DP_S_MOD;
break;
case DP_S_MAX:
- if (isdigit((unsigned char)ch)) {
+ if (ossl_isdigit(ch)) {
if (max < 0)
max = 0;
max = 10 * max + char_to_int(ch);
@@ -187,6 +188,7 @@ _dopr(char **sbuffer,
ch = *format++;
break;
case 'q':
+ case 'j':
cflags = DP_C_LLONG;
ch = *format++;
break;
@@ -194,6 +196,10 @@ _dopr(char **sbuffer,
cflags = DP_C_LDOUBLE;
ch = *format++;
break;
+ case 'z':
+ cflags = DP_C_SIZE;
+ ch = *format++;
+ break;
default:
break;
}
@@ -213,6 +219,9 @@ _dopr(char **sbuffer,
case DP_C_LLONG:
value = va_arg(args, int64_t);
break;
+ case DP_C_SIZE:
+ value = va_arg(args, ossl_ssize_t);
+ break;
default:
value = va_arg(args, int);
break;
@@ -238,6 +247,9 @@ _dopr(char **sbuffer,
case DP_C_LLONG:
value = va_arg(args, uint64_t);
break;
+ case DP_C_SIZE:
+ value = va_arg(args, size_t);
+ break;
default:
value = va_arg(args, unsigned int);
break;
@@ -281,8 +293,8 @@ _dopr(char **sbuffer,
return 0;
break;
case 'c':
- if(!doapr_outch(sbuffer, buffer, &currlen, maxlen,
- va_arg(args, int)))
+ if (!doapr_outch(sbuffer, buffer, &currlen, maxlen,
+ va_arg(args, int)))
return 0;
break;
case 's':
@@ -303,27 +315,15 @@ _dopr(char **sbuffer,
value, 16, min, max, flags | DP_F_NUM))
return 0;
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 */
- int64_t *num;
- num = va_arg(args, int64_t *);
- *num = (int64_t)currlen;
- } else {
+ case 'n':
+ {
int *num;
num = va_arg(args, int *);
*num = currlen;
}
break;
case '%':
- if(!doapr_outch(sbuffer, buffer, &currlen, maxlen, ch))
+ if (!doapr_outch(sbuffer, buffer, &currlen, maxlen, ch))
return 0;
break;
case 'w':
@@ -354,7 +354,7 @@ _dopr(char **sbuffer,
if (*truncated)
currlen = *maxlen - 1;
}
- if(!doapr_outch(sbuffer, buffer, &currlen, maxlen, '\0'))
+ if (!doapr_outch(sbuffer, buffer, &currlen, maxlen, '\0'))
return 0;
*retlen = currlen - 1;
return 1;
@@ -392,19 +392,19 @@ fmtstr(char **sbuffer,
padlen = -padlen;
while ((padlen > 0) && (max < 0 || cnt < max)) {
- if(!doapr_outch(sbuffer, buffer, currlen, maxlen, ' '))
+ if (!doapr_outch(sbuffer, buffer, currlen, maxlen, ' '))
return 0;
--padlen;
++cnt;
}
while (strln > 0 && (max < 0 || cnt < max)) {
- if(!doapr_outch(sbuffer, buffer, currlen, maxlen, *value++))
+ if (!doapr_outch(sbuffer, buffer, currlen, maxlen, *value++))
return 0;
--strln;
++cnt;
}
while ((padlen < 0) && (max < 0 || cnt < max)) {
- if(!doapr_outch(sbuffer, buffer, currlen, maxlen, ' '))
+ if (!doapr_outch(sbuffer, buffer, currlen, maxlen, ' '))
return 0;
++padlen;
++cnt;
@@ -472,19 +472,19 @@ fmtint(char **sbuffer,
/* spaces */
while (spadlen > 0) {
- if(!doapr_outch(sbuffer, buffer, currlen, maxlen, ' '))
+ if (!doapr_outch(sbuffer, buffer, currlen, maxlen, ' '))
return 0;
--spadlen;
}
/* sign */
if (signvalue)
- if(!doapr_outch(sbuffer, buffer, currlen, maxlen, signvalue))
+ if (!doapr_outch(sbuffer, buffer, currlen, maxlen, signvalue))
return 0;
/* prefix */
while (*prefix) {
- if(!doapr_outch(sbuffer, buffer, currlen, maxlen, *prefix))
+ if (!doapr_outch(sbuffer, buffer, currlen, maxlen, *prefix))
return 0;
prefix++;
}
@@ -492,7 +492,7 @@ fmtint(char **sbuffer,
/* zeros */
if (zpadlen > 0) {
while (zpadlen > 0) {
- if(!doapr_outch(sbuffer, buffer, currlen, maxlen, '0'))
+ if (!doapr_outch(sbuffer, buffer, currlen, maxlen, '0'))
return 0;
--zpadlen;
}
@@ -758,8 +758,8 @@ fmtfp(char **sbuffer,
return 0;
while (fplace > 0) {
- if(!doapr_outch(sbuffer, buffer, currlen, maxlen,
- fconvert[--fplace]))
+ if (!doapr_outch(sbuffer, buffer, currlen, maxlen,
+ fconvert[--fplace]))
return 0;
}
}
@@ -805,11 +805,13 @@ static int
doapr_outch(char **sbuffer,
char **buffer, size_t *currlen, size_t *maxlen, int c)
{
- /* If we haven't at least one buffer, someone has doe a big booboo */
- OPENSSL_assert(*sbuffer != NULL || buffer != NULL);
+ /* If we haven't at least one buffer, someone has done a big booboo */
+ if (!ossl_assert(*sbuffer != NULL || buffer != NULL))
+ return 0;
/* |currlen| must always be <= |*maxlen| */
- OPENSSL_assert(*currlen <= *maxlen);
+ if (!ossl_assert(*currlen <= *maxlen))
+ return 0;
if (buffer && *currlen == *maxlen) {
if (*maxlen > INT_MAX - BUFFER_INC)
@@ -817,11 +819,13 @@ doapr_outch(char **sbuffer,
*maxlen += BUFFER_INC;
if (*buffer == NULL) {
- *buffer = OPENSSL_malloc(*maxlen);
- if (*buffer == NULL)
+ if ((*buffer = OPENSSL_malloc(*maxlen)) == NULL) {
+ BIOerr(BIO_F_DOAPR_OUTCH, ERR_R_MALLOC_FAILURE);
return 0;
+ }
if (*currlen > 0) {
- OPENSSL_assert(*sbuffer != NULL);
+ if (!ossl_assert(*sbuffer != NULL))
+ return 0;
memcpy(*buffer, *sbuffer, *currlen);
}
*sbuffer = NULL;
@@ -856,7 +860,7 @@ int BIO_printf(BIO *bio, const char *format, ...)
ret = BIO_vprintf(bio, format, args);
va_end(args);
- return (ret);
+ return ret;
}
int BIO_vprintf(BIO *bio, const char *format, va_list args)
@@ -883,7 +887,7 @@ int BIO_vprintf(BIO *bio, const char *format, va_list args)
} else {
ret = BIO_write(bio, hugebuf, (int)retlen);
}
- return (ret);
+ return ret;
}
/*
@@ -902,7 +906,7 @@ int BIO_snprintf(char *buf, size_t n, const char *format, ...)
ret = BIO_vsnprintf(buf, n, format, args);
va_end(args);
- return (ret);
+ return ret;
}
int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args)
@@ -910,7 +914,7 @@ int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args)
size_t retlen;
int truncated;
- if(!_dopr(&buf, NULL, &n, &retlen, &truncated, format, args))
+ if (!_dopr(&buf, NULL, &n, &retlen, &truncated, format, args))
return -1;
if (truncated)
diff --git a/deps/openssl/openssl/crypto/bio/b_sock.c b/deps/openssl/openssl/crypto/bio/b_sock.c
index fac1432787..e7a24d02cb 100644
--- a/deps/openssl/openssl/crypto/bio/b_sock.c
+++ b/deps/openssl/openssl/crypto/bio/b_sock.c
@@ -11,10 +11,6 @@
#include <stdlib.h>
#include <errno.h>
#include "bio_lcl.h"
-#if defined(NETWARE_CLIB)
-# include <sys/ioctl.h>
-NETDB_DEFINE_CONTEXT
-#endif
#ifndef OPENSSL_NO_SOCK
# define SOCKET_PROTOCOL IPPROTO_TCP
# ifdef SO_MAXCONN
@@ -43,14 +39,13 @@ int BIO_get_host_ip(const char *str, unsigned char *ip)
if (BIO_ADDRINFO_family(res) != AF_INET) {
BIOerr(BIO_F_BIO_GET_HOST_IP,
BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET);
- } else {
- BIO_ADDR_rawaddress(BIO_ADDRINFO_address(res), NULL, &l);
- /* Because only AF_INET addresses will reach this far,
- we can assert that l should be 4 */
- OPENSSL_assert(l == 4);
-
- BIO_ADDR_rawaddress(BIO_ADDRINFO_address(res), ip, &l);
- ret = 1;
+ } else if (BIO_ADDR_rawaddress(BIO_ADDRINFO_address(res), NULL, &l)) {
+ /*
+ * Because only AF_INET addresses will reach this far, we can assert
+ * that l should be 4
+ */
+ if (ossl_assert(l == 4))
+ ret = BIO_ADDR_rawaddress(BIO_ADDRINFO_address(res), ip, &l);
}
BIO_ADDRINFO_free(res);
} else {
@@ -67,7 +62,7 @@ int BIO_get_port(const char *str, unsigned short *port_ptr)
if (str == NULL) {
BIOerr(BIO_F_BIO_GET_PORT, BIO_R_NO_PORT_DEFINED);
- return (0);
+ return 0;
}
if (BIO_sock_init() != 1)
@@ -103,9 +98,9 @@ int BIO_sock_error(int sock)
*/
i = getsockopt(sock, SOL_SOCKET, SO_ERROR, (void *)&j, &size);
if (i < 0)
- return (get_last_socket_error());
+ return get_last_socket_error();
else
- return (j);
+ return j;
}
# if OPENSSL_API_COMPAT < 0x10100000L
@@ -115,11 +110,7 @@ struct hostent *BIO_gethostbyname(const char *name)
* Caching gethostbyname() results forever is wrong, so we have to let
* the true gethostbyname() worry about this
*/
-# if (defined(NETWARE_BSDSOCK) && !defined(__NOVELL_LIBC__))
- return gethostbyname((char *)name);
-# else
return gethostbyname(name);
-# endif
}
# endif
@@ -143,7 +134,7 @@ int BIO_sock_init(void)
err = WSAGetLastError();
SYSerr(SYS_F_WSASTARTUP, err);
BIOerr(BIO_F_BIO_SOCK_INIT, BIO_R_WSASTARTUP);
- return (-1);
+ return -1;
}
}
# endif /* OPENSSL_SYS_WINDOWS */
@@ -151,10 +142,10 @@ int BIO_sock_init(void)
extern int _watt_do_exit;
_watt_do_exit = 0; /* don't make sock_init() call exit() */
if (sock_init())
- return (-1);
+ return -1;
# endif
- return (1);
+ return 1;
}
void bio_sock_cleanup_int(void)
@@ -202,7 +193,7 @@ int BIO_socket_ioctl(int fd, long type, void *arg)
# endif /* __DJGPP__ */
if (i < 0)
SYSerr(SYS_F_IOCTLSOCKET, get_last_socket_error());
- return (i);
+ return i;
}
# if OPENSSL_API_COMPAT < 0x10100000L
diff --git a/deps/openssl/openssl/crypto/bio/b_sock2.c b/deps/openssl/openssl/crypto/bio/b_sock2.c
index d8b49d022c..5d82ab22dc 100644
--- a/deps/openssl/openssl/crypto/bio/b_sock2.c
+++ b/deps/openssl/openssl/crypto/bio/b_sock2.c
@@ -76,7 +76,7 @@ int BIO_socket(int domain, int socktype, int protocol, int options)
*/
int BIO_connect(int sock, const BIO_ADDR *addr, int options)
{
- int on = 1;
+ const int on = 1;
if (sock == -1) {
BIOerr(BIO_F_BIO_CONNECT, BIO_R_INVALID_SOCKET);
@@ -87,7 +87,8 @@ int BIO_connect(int sock, const BIO_ADDR *addr, int options)
return 0;
if (options & BIO_SOCK_KEEPALIVE) {
- if (setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof(on)) != 0) {
+ if (setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE,
+ (const void *)&on, sizeof(on)) != 0) {
SYSerr(SYS_F_SETSOCKOPT, get_last_socket_error());
BIOerr(BIO_F_BIO_CONNECT, BIO_R_UNABLE_TO_KEEPALIVE);
return 0;
@@ -95,7 +96,8 @@ int BIO_connect(int sock, const BIO_ADDR *addr, int options)
}
if (options & BIO_SOCK_NODELAY) {
- if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on)) != 0) {
+ if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
+ (const void *)&on, sizeof(on)) != 0) {
SYSerr(SYS_F_SETSOCKOPT, get_last_socket_error());
BIOerr(BIO_F_BIO_CONNECT, BIO_R_UNABLE_TO_NODELAY);
return 0;
@@ -114,6 +116,57 @@ int BIO_connect(int sock, const BIO_ADDR *addr, int options)
}
/*-
+ * BIO_bind - bind socket to address
+ * @sock: the socket to set
+ * @addr: local address to bind to
+ * @options: BIO socket options
+ *
+ * Binds to the address using the given socket and options.
+ *
+ * Options can be a combination of the following:
+ * - BIO_SOCK_REUSEADDR: Try to reuse the address and port combination
+ * for a recently closed port.
+ *
+ * When restarting the program it could be that the port is still in use. If
+ * you set to BIO_SOCK_REUSEADDR option it will try to reuse the port anyway.
+ * It's recommended that you use this.
+ */
+int BIO_bind(int sock, const BIO_ADDR *addr, int options)
+{
+# ifndef OPENSSL_SYS_WINDOWS
+ int on = 1;
+# endif
+
+ if (sock == -1) {
+ BIOerr(BIO_F_BIO_BIND, BIO_R_INVALID_SOCKET);
+ return 0;
+ }
+
+# ifndef OPENSSL_SYS_WINDOWS
+ /*
+ * SO_REUSEADDR has different behavior on Windows than on
+ * other operating systems, don't set it there.
+ */
+ if (options & BIO_SOCK_REUSEADDR) {
+ if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
+ (const void *)&on, sizeof(on)) != 0) {
+ SYSerr(SYS_F_SETSOCKOPT, get_last_socket_error());
+ BIOerr(BIO_F_BIO_BIND, BIO_R_UNABLE_TO_REUSEADDR);
+ return 0;
+ }
+ }
+# endif
+
+ if (bind(sock, BIO_ADDR_sockaddr(addr), BIO_ADDR_sockaddr_size(addr)) != 0) {
+ SYSerr(SYS_F_BIND, get_last_socket_error());
+ BIOerr(BIO_F_BIO_BIND, BIO_R_UNABLE_TO_BIND_SOCKET);
+ return 0;
+ }
+
+ return 1;
+}
+
+/*-
* BIO_listen - Creates a listen socket
* @sock: the socket to listen with
* @addr: local address to bind to
@@ -161,7 +214,8 @@ int BIO_listen(int sock, const BIO_ADDR *addr, int options)
return 0;
}
- if (getsockopt(sock, SOL_SOCKET, SO_TYPE, &socktype, &socktype_len) != 0
+ if (getsockopt(sock, SOL_SOCKET, SO_TYPE,
+ (void *)&socktype, &socktype_len) != 0
|| socktype_len != sizeof(socktype)) {
SYSerr(SYS_F_GETSOCKOPT, get_last_socket_error());
BIOerr(BIO_F_BIO_LISTEN, BIO_R_GETTING_SOCKTYPE);
@@ -171,22 +225,9 @@ int BIO_listen(int sock, const BIO_ADDR *addr, int options)
if (!BIO_socket_nbio(sock, (options & BIO_SOCK_NONBLOCK) != 0))
return 0;
-# ifndef OPENSSL_SYS_WINDOWS
- /*
- * SO_REUSEADDR has different behavior on Windows than on
- * other operating systems, don't set it there.
- */
- if (options & BIO_SOCK_REUSEADDR) {
- if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) != 0) {
- SYSerr(SYS_F_SETSOCKOPT, get_last_socket_error());
- BIOerr(BIO_F_BIO_LISTEN, BIO_R_UNABLE_TO_REUSEADDR);
- return 0;
- }
- }
-# endif
-
if (options & BIO_SOCK_KEEPALIVE) {
- if (setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof(on)) != 0) {
+ if (setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE,
+ (const void *)&on, sizeof(on)) != 0) {
SYSerr(SYS_F_SETSOCKOPT, get_last_socket_error());
BIOerr(BIO_F_BIO_LISTEN, BIO_R_UNABLE_TO_KEEPALIVE);
return 0;
@@ -194,7 +235,8 @@ int BIO_listen(int sock, const BIO_ADDR *addr, int options)
}
if (options & BIO_SOCK_NODELAY) {
- if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on)) != 0) {
+ if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
+ (const void *)&on, sizeof(on)) != 0) {
SYSerr(SYS_F_SETSOCKOPT, get_last_socket_error());
BIOerr(BIO_F_BIO_LISTEN, BIO_R_UNABLE_TO_NODELAY);
return 0;
@@ -208,7 +250,8 @@ int BIO_listen(int sock, const BIO_ADDR *addr, int options)
* Therefore we always have to use setsockopt here.
*/
on = options & BIO_SOCK_V6_ONLY ? 1 : 0;
- if (setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)) != 0) {
+ if (setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY,
+ (const void *)&on, sizeof(on)) != 0) {
SYSerr(SYS_F_SETSOCKOPT, get_last_socket_error());
BIOerr(BIO_F_BIO_LISTEN, BIO_R_LISTEN_V6_ONLY);
return 0;
@@ -216,11 +259,8 @@ int BIO_listen(int sock, const BIO_ADDR *addr, int options)
}
# endif
- if (bind(sock, BIO_ADDR_sockaddr(addr), BIO_ADDR_sockaddr_size(addr)) != 0) {
- SYSerr(SYS_F_BIND, get_last_socket_error());
- BIOerr(BIO_F_BIO_LISTEN, BIO_R_UNABLE_TO_BIND_SOCKET);
+ if (!BIO_bind(sock, addr, options))
return 0;
- }
if (socktype != SOCK_DGRAM && listen(sock, MAX_LISTEN) == -1) {
SYSerr(SYS_F_LISTEN, get_last_socket_error());
diff --git a/deps/openssl/openssl/crypto/bio/bf_buff.c b/deps/openssl/openssl/crypto/bio/bf_buff.c
index 8509956159..8e87a629b8 100644
--- a/deps/openssl/openssl/crypto/bio/bf_buff.c
+++ b/deps/openssl/openssl/crypto/bio/bf_buff.c
@@ -25,7 +25,11 @@ static long buffer_callback_ctrl(BIO *h, int cmd, BIO_info_cb *fp);
static const BIO_METHOD methods_buffer = {
BIO_TYPE_BUFFER,
"buffer",
+ /* TODO: Convert to new style write function */
+ bwrite_conv,
buffer_write,
+ /* TODO: Convert to new style read function */
+ bread_conv,
buffer_read,
buffer_puts,
buffer_gets,
@@ -37,7 +41,7 @@ static const BIO_METHOD methods_buffer = {
const BIO_METHOD *BIO_f_buffer(void)
{
- return (&methods_buffer);
+ return &methods_buffer;
}
static int buffer_new(BIO *bi)
@@ -45,25 +49,25 @@ static int buffer_new(BIO *bi)
BIO_F_BUFFER_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));
if (ctx == NULL)
- return (0);
+ return 0;
ctx->ibuf_size = DEFAULT_BUFFER_SIZE;
ctx->ibuf = OPENSSL_malloc(DEFAULT_BUFFER_SIZE);
if (ctx->ibuf == NULL) {
OPENSSL_free(ctx);
- return (0);
+ return 0;
}
ctx->obuf_size = DEFAULT_BUFFER_SIZE;
ctx->obuf = OPENSSL_malloc(DEFAULT_BUFFER_SIZE);
if (ctx->obuf == NULL) {
OPENSSL_free(ctx->ibuf);
OPENSSL_free(ctx);
- return (0);
+ return 0;
}
bi->init = 1;
bi->ptr = (char *)ctx;
bi->flags = 0;
- return (1);
+ return 1;
}
static int buffer_free(BIO *a)
@@ -71,7 +75,7 @@ static int buffer_free(BIO *a)
BIO_F_BUFFER_CTX *b;
if (a == NULL)
- return (0);
+ return 0;
b = (BIO_F_BUFFER_CTX *)a->ptr;
OPENSSL_free(b->ibuf);
OPENSSL_free(b->obuf);
@@ -79,7 +83,7 @@ static int buffer_free(BIO *a)
a->ptr = NULL;
a->init = 0;
a->flags = 0;
- return (1);
+ return 1;
}
static int buffer_read(BIO *b, char *out, int outl)
@@ -88,11 +92,11 @@ static int buffer_read(BIO *b, char *out, int outl)
BIO_F_BUFFER_CTX *ctx;
if (out == NULL)
- return (0);
+ return 0;
ctx = (BIO_F_BUFFER_CTX *)b->ptr;
if ((ctx == NULL) || (b->next_bio == NULL))
- return (0);
+ return 0;
num = 0;
BIO_clear_retry_flags(b);
@@ -107,7 +111,7 @@ static int buffer_read(BIO *b, char *out, int outl)
ctx->ibuf_len -= i;
num += i;
if (outl == i)
- return (num);
+ return num;
outl -= i;
out += i;
}
@@ -126,11 +130,11 @@ static int buffer_read(BIO *b, char *out, int outl)
if (i < 0)
return ((num > 0) ? num : i);
if (i == 0)
- return (num);
+ return num;
}
num += i;
if (outl == i)
- return (num);
+ return num;
out += i;
outl -= i;
}
@@ -144,7 +148,7 @@ static int buffer_read(BIO *b, char *out, int outl)
if (i < 0)
return ((num > 0) ? num : i);
if (i == 0)
- return (num);
+ return num;
}
ctx->ibuf_off = 0;
ctx->ibuf_len = i;
@@ -159,10 +163,10 @@ static int buffer_write(BIO *b, const char *in, int inl)
BIO_F_BUFFER_CTX *ctx;
if ((in == NULL) || (inl <= 0))
- return (0);
+ return 0;
ctx = (BIO_F_BUFFER_CTX *)b->ptr;
if ((ctx == NULL) || (b->next_bio == NULL))
- return (0);
+ return 0;
BIO_clear_retry_flags(b);
start:
@@ -193,7 +197,7 @@ static int buffer_write(BIO *b, const char *in, int inl)
if (i < 0)
return ((num > 0) ? num : i);
if (i == 0)
- return (num);
+ return num;
}
ctx->obuf_off += i;
ctx->obuf_len -= i;
@@ -215,13 +219,13 @@ static int buffer_write(BIO *b, const char *in, int inl)
if (i < 0)
return ((num > 0) ? num : i);
if (i == 0)
- return (num);
+ return num;
}
num += i;
in += i;
inl -= i;
if (inl == 0)
- return (num);
+ return num;
}
/*
@@ -248,7 +252,12 @@ static long buffer_ctrl(BIO *b, int cmd, long num, void *ptr)
ctx->obuf_off = 0;
ctx->obuf_len = 0;
if (b->next_bio == NULL)
- return (0);
+ return 0;
+ ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
+ break;
+ case BIO_CTRL_EOF:
+ if (ctx->ibuf_len > 0)
+ return 0;
ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
break;
case BIO_CTRL_INFO:
@@ -266,7 +275,7 @@ static long buffer_ctrl(BIO *b, int cmd, long num, void *ptr)
ret = (long)ctx->obuf_len;
if (ret == 0) {
if (b->next_bio == NULL)
- return (0);
+ return 0;
ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
}
break;
@@ -274,7 +283,7 @@ static long buffer_ctrl(BIO *b, int cmd, long num, void *ptr)
ret = (long)ctx->ibuf_len;
if (ret == 0) {
if (b->next_bio == NULL)
- return (0);
+ return 0;
ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
}
break;
@@ -338,7 +347,7 @@ static long buffer_ctrl(BIO *b, int cmd, long num, void *ptr)
break;
case BIO_C_DO_STATE_MACHINE:
if (b->next_bio == NULL)
- return (0);
+ return 0;
BIO_clear_retry_flags(b);
ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
BIO_copy_next_retry(b);
@@ -346,7 +355,7 @@ static long buffer_ctrl(BIO *b, int cmd, long num, void *ptr)
case BIO_CTRL_FLUSH:
if (b->next_bio == NULL)
- return (0);
+ return 0;
if (ctx->obuf_len <= 0) {
ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
break;
@@ -359,7 +368,7 @@ static long buffer_ctrl(BIO *b, int cmd, long num, void *ptr)
&(ctx->obuf[ctx->obuf_off]), ctx->obuf_len);
BIO_copy_next_retry(b);
if (r <= 0)
- return ((long)r);
+ return (long)r;
ctx->obuf_off += r;
ctx->obuf_len -= r;
} else {
@@ -376,16 +385,27 @@ static long buffer_ctrl(BIO *b, int cmd, long num, void *ptr)
!BIO_set_write_buffer_size(dbio, ctx->obuf_size))
ret = 0;
break;
+ case BIO_CTRL_PEEK:
+ /* Ensure there's stuff in the input buffer */
+ {
+ char fake_buf[1];
+ (void)buffer_read(b, fake_buf, 0);
+ }
+ if (num > ctx->ibuf_len)
+ num = ctx->ibuf_len;
+ memcpy(ptr, &(ctx->ibuf[ctx->ibuf_off]), num);
+ ret = num;
+ break;
default:
if (b->next_bio == NULL)
- return (0);
+ return 0;
ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
break;
}
- return (ret);
+ return ret;
malloc_error:
BIOerr(BIO_F_BUFFER_CTRL, ERR_R_MALLOC_FAILURE);
- return (0);
+ return 0;
}
static long buffer_callback_ctrl(BIO *b, int cmd, BIO_info_cb *fp)
@@ -393,13 +413,13 @@ static long buffer_callback_ctrl(BIO *b, int cmd, BIO_info_cb *fp)
long ret = 1;
if (b->next_bio == NULL)
- return (0);
+ return 0;
switch (cmd) {
default:
ret = BIO_callback_ctrl(b->next_bio, cmd, fp);
break;
}
- return (ret);
+ return ret;
}
static int buffer_gets(BIO *b, char *buf, int size)
@@ -430,7 +450,7 @@ static int buffer_gets(BIO *b, char *buf, int size)
ctx->ibuf_off += i;
if (flag || size == 0) {
*buf = '\0';
- return (num);
+ return num;
}
} else { /* read another chunk */
@@ -441,7 +461,7 @@ static int buffer_gets(BIO *b, char *buf, int size)
if (i < 0)
return ((num > 0) ? num : i);
if (i == 0)
- return (num);
+ return num;
}
ctx->ibuf_len = i;
ctx->ibuf_off = 0;
@@ -451,5 +471,5 @@ static int buffer_gets(BIO *b, char *buf, int size)
static int buffer_puts(BIO *b, const char *str)
{
- return (buffer_write(b, str, strlen(str)));
+ return buffer_write(b, str, strlen(str));
}
diff --git a/deps/openssl/openssl/crypto/bio/bf_lbuf.c b/deps/openssl/openssl/crypto/bio/bf_lbuf.c
index a80f899a0e..194c7b8af7 100644
--- a/deps/openssl/openssl/crypto/bio/bf_lbuf.c
+++ b/deps/openssl/openssl/crypto/bio/bf_lbuf.c
@@ -30,7 +30,11 @@ static long linebuffer_callback_ctrl(BIO *h, int cmd, BIO_info_cb *fp);
static const BIO_METHOD methods_linebuffer = {
BIO_TYPE_LINEBUFFER,
"linebuffer",
+ /* TODO: Convert to new style write function */
+ bwrite_conv,
linebuffer_write,
+ /* TODO: Convert to new style read function */
+ bread_conv,
linebuffer_read,
linebuffer_puts,
linebuffer_gets,
@@ -42,7 +46,7 @@ static const BIO_METHOD methods_linebuffer = {
const BIO_METHOD *BIO_f_linebuffer(void)
{
- return (&methods_linebuffer);
+ return &methods_linebuffer;
}
typedef struct bio_linebuffer_ctx_struct {
@@ -55,13 +59,15 @@ static int linebuffer_new(BIO *bi)
{
BIO_LINEBUFFER_CTX *ctx;
- ctx = OPENSSL_malloc(sizeof(*ctx));
- if (ctx == NULL)
- return (0);
+ if ((ctx = OPENSSL_malloc(sizeof(*ctx))) == NULL) {
+ BIOerr(BIO_F_LINEBUFFER_NEW, ERR_R_MALLOC_FAILURE);
+ return 0;
+ }
ctx->obuf = OPENSSL_malloc(DEFAULT_LINEBUFFER_SIZE);
if (ctx->obuf == NULL) {
+ BIOerr(BIO_F_LINEBUFFER_NEW, ERR_R_MALLOC_FAILURE);
OPENSSL_free(ctx);
- return (0);
+ return 0;
}
ctx->obuf_size = DEFAULT_LINEBUFFER_SIZE;
ctx->obuf_len = 0;
@@ -69,7 +75,7 @@ static int linebuffer_new(BIO *bi)
bi->init = 1;
bi->ptr = (char *)ctx;
bi->flags = 0;
- return (1);
+ return 1;
}
static int linebuffer_free(BIO *a)
@@ -77,14 +83,14 @@ static int linebuffer_free(BIO *a)
BIO_LINEBUFFER_CTX *b;
if (a == NULL)
- return (0);
+ return 0;
b = (BIO_LINEBUFFER_CTX *)a->ptr;
OPENSSL_free(b->obuf);
OPENSSL_free(a->ptr);
a->ptr = NULL;
a->init = 0;
a->flags = 0;
- return (1);
+ return 1;
}
static int linebuffer_read(BIO *b, char *out, int outl)
@@ -92,13 +98,13 @@ static int linebuffer_read(BIO *b, char *out, int outl)
int ret = 0;
if (out == NULL)
- return (0);
+ return 0;
if (b->next_bio == NULL)
- return (0);
+ return 0;
ret = BIO_read(b->next_bio, out, outl);
BIO_clear_retry_flags(b);
BIO_copy_next_retry(b);
- return (ret);
+ return ret;
}
static int linebuffer_write(BIO *b, const char *in, int inl)
@@ -107,10 +113,10 @@ static int linebuffer_write(BIO *b, const char *in, int inl)
BIO_LINEBUFFER_CTX *ctx;
if ((in == NULL) || (inl <= 0))
- return (0);
+ return 0;
ctx = (BIO_LINEBUFFER_CTX *)b->ptr;
if ((ctx == NULL) || (b->next_bio == NULL))
- return (0);
+ return 0;
BIO_clear_retry_flags(b);
@@ -157,7 +163,7 @@ static int linebuffer_write(BIO *b, const char *in, int inl)
if (i < 0)
return ((num > 0) ? num : i);
if (i == 0)
- return (num);
+ return num;
}
if (i < ctx->obuf_len)
memmove(ctx->obuf, ctx->obuf + i, ctx->obuf_len - i);
@@ -175,7 +181,7 @@ static int linebuffer_write(BIO *b, const char *in, int inl)
if (i < 0)
return ((num > 0) ? num : i);
if (i == 0)
- return (num);
+ return num;
}
num += i;
in += i;
@@ -211,7 +217,7 @@ static long linebuffer_ctrl(BIO *b, int cmd, long num, void *ptr)
case BIO_CTRL_RESET:
ctx->obuf_len = 0;
if (b->next_bio == NULL)
- return (0);
+ return 0;
ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
break;
case BIO_CTRL_INFO:
@@ -221,7 +227,7 @@ static long linebuffer_ctrl(BIO *b, int cmd, long num, void *ptr)
ret = (long)ctx->obuf_len;
if (ret == 0) {
if (b->next_bio == NULL)
- return (0);
+ return 0;
ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
}
break;
@@ -245,7 +251,7 @@ static long linebuffer_ctrl(BIO *b, int cmd, long num, void *ptr)
break;
case BIO_C_DO_STATE_MACHINE:
if (b->next_bio == NULL)
- return (0);
+ return 0;
BIO_clear_retry_flags(b);
ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
BIO_copy_next_retry(b);
@@ -253,7 +259,7 @@ static long linebuffer_ctrl(BIO *b, int cmd, long num, void *ptr)
case BIO_CTRL_FLUSH:
if (b->next_bio == NULL)
- return (0);
+ return 0;
if (ctx->obuf_len <= 0) {
ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
break;
@@ -265,7 +271,7 @@ static long linebuffer_ctrl(BIO *b, int cmd, long num, void *ptr)
r = BIO_write(b->next_bio, ctx->obuf, ctx->obuf_len);
BIO_copy_next_retry(b);
if (r <= 0)
- return ((long)r);
+ return (long)r;
if (r < ctx->obuf_len)
memmove(ctx->obuf, ctx->obuf + r, ctx->obuf_len - r);
ctx->obuf_len -= r;
@@ -283,14 +289,14 @@ static long linebuffer_ctrl(BIO *b, int cmd, long num, void *ptr)
break;
default:
if (b->next_bio == NULL)
- return (0);
+ return 0;
ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
break;
}
- return (ret);
+ return ret;
malloc_error:
BIOerr(BIO_F_LINEBUFFER_CTRL, ERR_R_MALLOC_FAILURE);
- return (0);
+ return 0;
}
static long linebuffer_callback_ctrl(BIO *b, int cmd, BIO_info_cb *fp)
@@ -298,23 +304,23 @@ static long linebuffer_callback_ctrl(BIO *b, int cmd, BIO_info_cb *fp)
long ret = 1;
if (b->next_bio == NULL)
- return (0);
+ return 0;
switch (cmd) {
default:
ret = BIO_callback_ctrl(b->next_bio, cmd, fp);
break;
}
- return (ret);
+ return ret;
}
static int linebuffer_gets(BIO *b, char *buf, int size)
{
if (b->next_bio == NULL)
- return (0);
- return (BIO_gets(b->next_bio, buf, size));
+ return 0;
+ return BIO_gets(b->next_bio, buf, size);
}
static int linebuffer_puts(BIO *b, const char *str)
{
- return (linebuffer_write(b, str, strlen(str)));
+ return linebuffer_write(b, str, strlen(str));
}
diff --git a/deps/openssl/openssl/crypto/bio/bf_nbio.c b/deps/openssl/openssl/crypto/bio/bf_nbio.c
index 3328506dbc..4bc84eeba6 100644
--- a/deps/openssl/openssl/crypto/bio/bf_nbio.c
+++ b/deps/openssl/openssl/crypto/bio/bf_nbio.c
@@ -1,5 +1,5 @@
/*
- * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
@@ -34,7 +34,11 @@ typedef struct nbio_test_st {
static const BIO_METHOD methods_nbiof = {
BIO_TYPE_NBIO_TEST,
"non-blocking IO test filter",
+ /* TODO: Convert to new style write function */
+ bwrite_conv,
nbiof_write,
+ /* TODO: Convert to new style read function */
+ bread_conv,
nbiof_read,
nbiof_puts,
nbiof_gets,
@@ -46,31 +50,33 @@ static const BIO_METHOD methods_nbiof = {
const BIO_METHOD *BIO_f_nbio_test(void)
{
- return (&methods_nbiof);
+ return &methods_nbiof;
}
static int nbiof_new(BIO *bi)
{
NBIO_TEST *nt;
- if ((nt = OPENSSL_zalloc(sizeof(*nt))) == NULL)
- return (0);
+ if ((nt = OPENSSL_zalloc(sizeof(*nt))) == NULL) {
+ BIOerr(BIO_F_NBIOF_NEW, ERR_R_MALLOC_FAILURE);
+ return 0;
+ }
nt->lrn = -1;
nt->lwn = -1;
bi->ptr = (char *)nt;
bi->init = 1;
- return (1);
+ return 1;
}
static int nbiof_free(BIO *a)
{
if (a == NULL)
- return (0);
+ return 0;
OPENSSL_free(a->ptr);
a->ptr = NULL;
a->init = 0;
a->flags = 0;
- return (1);
+ return 1;
}
static int nbiof_read(BIO *b, char *out, int outl)
@@ -80,12 +86,12 @@ static int nbiof_read(BIO *b, char *out, int outl)
unsigned char n;
if (out == NULL)
- return (0);
+ return 0;
if (b->next_bio == NULL)
- return (0);
+ return 0;
BIO_clear_retry_flags(b);
- if (RAND_bytes(&n, 1) <= 0)
+ if (RAND_priv_bytes(&n, 1) <= 0)
return -1;
num = (n & 0x07);
@@ -100,7 +106,7 @@ static int nbiof_read(BIO *b, char *out, int outl)
if (ret < 0)
BIO_copy_next_retry(b);
}
- return (ret);
+ return ret;
}
static int nbiof_write(BIO *b, const char *in, int inl)
@@ -111,9 +117,9 @@ static int nbiof_write(BIO *b, const char *in, int inl)
unsigned char n;
if ((in == NULL) || (inl <= 0))
- return (0);
+ return 0;
if (b->next_bio == NULL)
- return (0);
+ return 0;
nt = (NBIO_TEST *)b->ptr;
BIO_clear_retry_flags(b);
@@ -122,7 +128,7 @@ static int nbiof_write(BIO *b, const char *in, int inl)
num = nt->lwn;
nt->lwn = 0;
} else {
- if (RAND_bytes(&n, 1) <= 0)
+ if (RAND_priv_bytes(&n, 1) <= 0)
return -1;
num = (n & 7);
}
@@ -140,7 +146,7 @@ static int nbiof_write(BIO *b, const char *in, int inl)
nt->lwn = inl;
}
}
- return (ret);
+ return ret;
}
static long nbiof_ctrl(BIO *b, int cmd, long num, void *ptr)
@@ -148,7 +154,7 @@ static long nbiof_ctrl(BIO *b, int cmd, long num, void *ptr)
long ret;
if (b->next_bio == NULL)
- return (0);
+ return 0;
switch (cmd) {
case BIO_C_DO_STATE_MACHINE:
BIO_clear_retry_flags(b);
@@ -162,7 +168,7 @@ static long nbiof_ctrl(BIO *b, int cmd, long num, void *ptr)
ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
break;
}
- return (ret);
+ return ret;
}
static long nbiof_callback_ctrl(BIO *b, int cmd, BIO_info_cb *fp)
@@ -170,25 +176,25 @@ static long nbiof_callback_ctrl(BIO *b, int cmd, BIO_info_cb *fp)
long ret = 1;
if (b->next_bio == NULL)
- return (0);
+ return 0;
switch (cmd) {
default:
ret = BIO_callback_ctrl(b->next_bio, cmd, fp);
break;
}
- return (ret);
+ return ret;
}
static int nbiof_gets(BIO *bp, char *buf, int size)
{
if (bp->next_bio == NULL)
- return (0);
- return (BIO_gets(bp->next_bio, buf, size));
+ return 0;
+ return BIO_gets(bp->next_bio, buf, size);
}
static int nbiof_puts(BIO *bp, const char *str)
{
if (bp->next_bio == NULL)
- return (0);
- return (BIO_puts(bp->next_bio, str));
+ return 0;
+ return BIO_puts(bp->next_bio, str);
}
diff --git a/deps/openssl/openssl/crypto/bio/bf_null.c b/deps/openssl/openssl/crypto/bio/bf_null.c
index 6b86aa550b..613fb2e058 100644
--- a/deps/openssl/openssl/crypto/bio/bf_null.c
+++ b/deps/openssl/openssl/crypto/bio/bf_null.c
@@ -25,7 +25,11 @@ static long nullf_callback_ctrl(BIO *h, int cmd, BIO_info_cb *fp);
static const BIO_METHOD methods_nullf = {
BIO_TYPE_NULL_FILTER,
"NULL filter",
+ /* TODO: Convert to new style write function */
+ bwrite_conv,
nullf_write,
+ /* TODO: Convert to new style read function */
+ bread_conv,
nullf_read,
nullf_puts,
nullf_gets,
@@ -37,7 +41,7 @@ static const BIO_METHOD methods_nullf = {
const BIO_METHOD *BIO_f_null(void)
{
- return (&methods_nullf);
+ return &methods_nullf;
}
static int nullf_read(BIO *b, char *out, int outl)
@@ -45,13 +49,13 @@ static int nullf_read(BIO *b, char *out, int outl)
int ret = 0;
if (out == NULL)
- return (0);
+ return 0;
if (b->next_bio == NULL)
- return (0);
+ return 0;
ret = BIO_read(b->next_bio, out, outl);
BIO_clear_retry_flags(b);
BIO_copy_next_retry(b);
- return (ret);
+ return ret;
}
static int nullf_write(BIO *b, const char *in, int inl)
@@ -59,13 +63,13 @@ static int nullf_write(BIO *b, const char *in, int inl)
int ret = 0;
if ((in == NULL) || (inl <= 0))
- return (0);
+ return 0;
if (b->next_bio == NULL)
- return (0);
+ return 0;
ret = BIO_write(b->next_bio, in, inl);
BIO_clear_retry_flags(b);
BIO_copy_next_retry(b);
- return (ret);
+ return ret;
}
static long nullf_ctrl(BIO *b, int cmd, long num, void *ptr)
@@ -73,7 +77,7 @@ static long nullf_ctrl(BIO *b, int cmd, long num, void *ptr)
long ret;
if (b->next_bio == NULL)
- return (0);
+ return 0;
switch (cmd) {
case BIO_C_DO_STATE_MACHINE:
BIO_clear_retry_flags(b);
@@ -86,7 +90,7 @@ static long nullf_ctrl(BIO *b, int cmd, long num, void *ptr)
default:
ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
}
- return (ret);
+ return ret;
}
static long nullf_callback_ctrl(BIO *b, int cmd, BIO_info_cb *fp)
@@ -94,25 +98,25 @@ static long nullf_callback_ctrl(BIO *b, int cmd, BIO_info_cb *fp)
long ret = 1;
if (b->next_bio == NULL)
- return (0);
+ return 0;
switch (cmd) {
default:
ret = BIO_callback_ctrl(b->next_bio, cmd, fp);
break;
}
- return (ret);
+ return ret;
}
static int nullf_gets(BIO *bp, char *buf, int size)
{
if (bp->next_bio == NULL)
- return (0);
- return (BIO_gets(bp->next_bio, buf, size));
+ return 0;
+ return BIO_gets(bp->next_bio, buf, size);
}
static int nullf_puts(BIO *bp, const char *str)
{
if (bp->next_bio == NULL)
- return (0);
- return (BIO_puts(bp->next_bio, str));
+ return 0;
+ return BIO_puts(bp->next_bio, str);
}
diff --git a/deps/openssl/openssl/crypto/bio/bio_cb.c b/deps/openssl/openssl/crypto/bio/bio_cb.c
index 412387b6b2..1154c233af 100644
--- a/deps/openssl/openssl/crypto/bio/bio_cb.c
+++ b/deps/openssl/openssl/crypto/bio/bio_cb.c
@@ -1,5 +1,5 @@
/*
- * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
@@ -21,8 +21,7 @@ long BIO_debug_callback(BIO *bio, int cmd, const char *argp,
char buf[256];
char *p;
long r = 1;
- int len;
- size_t p_maxlen;
+ int len, left;
if (BIO_CB_RETURN & cmd)
r = ret;
@@ -33,58 +32,58 @@ long BIO_debug_callback(BIO *bio, int cmd, const char *argp,
if (len < 0)
len = 0;
p = buf + len;
- p_maxlen = sizeof(buf) - len;
+ left = sizeof(buf) - len;
switch (cmd) {
case BIO_CB_FREE:
- BIO_snprintf(p, p_maxlen, "Free - %s\n", bio->method->name);
+ BIO_snprintf(p, left, "Free - %s\n", bio->method->name);
break;
case BIO_CB_READ:
if (bio->method->type & BIO_TYPE_DESCRIPTOR)
- BIO_snprintf(p, p_maxlen, "read(%d,%lu) - %s fd=%d\n",
+ BIO_snprintf(p, left, "read(%d,%lu) - %s fd=%d\n",
bio->num, (unsigned long)argi,
bio->method->name, bio->num);
else
- BIO_snprintf(p, p_maxlen, "read(%d,%lu) - %s\n",
- bio->num, (unsigned long)argi, bio->method->name);
+ BIO_snprintf(p, left, "read(%d,%lu) - %s\n",
+ bio->num, (unsigned long)argi, bio->method->name);
break;
case BIO_CB_WRITE:
if (bio->method->type & BIO_TYPE_DESCRIPTOR)
- BIO_snprintf(p, p_maxlen, "write(%d,%lu) - %s fd=%d\n",
+ BIO_snprintf(p, left, "write(%d,%lu) - %s fd=%d\n",
bio->num, (unsigned long)argi,
bio->method->name, bio->num);
else
- BIO_snprintf(p, p_maxlen, "write(%d,%lu) - %s\n",
+ BIO_snprintf(p, left, "write(%d,%lu) - %s\n",
bio->num, (unsigned long)argi, bio->method->name);
break;
case BIO_CB_PUTS:
- BIO_snprintf(p, p_maxlen, "puts() - %s\n", bio->method->name);
+ BIO_snprintf(p, left, "puts() - %s\n", bio->method->name);
break;
case BIO_CB_GETS:
- BIO_snprintf(p, p_maxlen, "gets(%lu) - %s\n", (unsigned long)argi,
+ BIO_snprintf(p, left, "gets(%lu) - %s\n", (unsigned long)argi,
bio->method->name);
break;
case BIO_CB_CTRL:
- BIO_snprintf(p, p_maxlen, "ctrl(%lu) - %s\n", (unsigned long)argi,
+ BIO_snprintf(p, left, "ctrl(%lu) - %s\n", (unsigned long)argi,
bio->method->name);
break;
case BIO_CB_RETURN | BIO_CB_READ:
- BIO_snprintf(p, p_maxlen, "read return %ld\n", ret);
+ BIO_snprintf(p, left, "read return %ld\n", ret);
break;
case BIO_CB_RETURN | BIO_CB_WRITE:
- BIO_snprintf(p, p_maxlen, "write return %ld\n", ret);
+ BIO_snprintf(p, left, "write return %ld\n", ret);
break;
case BIO_CB_RETURN | BIO_CB_GETS:
- BIO_snprintf(p, p_maxlen, "gets return %ld\n", ret);
+ BIO_snprintf(p, left, "gets return %ld\n", ret);
break;
case BIO_CB_RETURN | BIO_CB_PUTS:
- BIO_snprintf(p, p_maxlen, "puts return %ld\n", ret);
+ BIO_snprintf(p, left, "puts return %ld\n", ret);
break;
case BIO_CB_RETURN | BIO_CB_CTRL:
- BIO_snprintf(p, p_maxlen, "ctrl return %ld\n", ret);
+ BIO_snprintf(p, left, "ctrl return %ld\n", ret);
break;
default:
- BIO_snprintf(p, p_maxlen, "bio callback - unknown type (%d)\n", cmd);
+ BIO_snprintf(p, left, "bio callback - unknown type (%d)\n", cmd);
break;
}
@@ -95,5 +94,5 @@ long BIO_debug_callback(BIO *bio, int cmd, const char *argp,
else
fputs(buf, stderr);
#endif
- return (r);
+ return r;
}
diff --git a/deps/openssl/openssl/crypto/bio/bio_err.c b/deps/openssl/openssl/crypto/bio/bio_err.c
index c914dcffdd..7aa9dabb29 100644
--- a/deps/openssl/openssl/crypto/bio/bio_err.c
+++ b/deps/openssl/openssl/crypto/bio/bio_err.c
@@ -8,106 +8,126 @@
* https://www.openssl.org/source/license.html
*/
-#include <stdio.h>
#include <openssl/err.h>
-#include <openssl/bio.h>
+#include <openssl/bioerr.h>
-/* BEGIN ERROR CODES */
#ifndef OPENSSL_NO_ERR
-# define ERR_FUNC(func) ERR_PACK(ERR_LIB_BIO,func,0)
-# define ERR_REASON(reason) ERR_PACK(ERR_LIB_BIO,0,reason)
-
-static ERR_STRING_DATA BIO_str_functs[] = {
- {ERR_FUNC(BIO_F_ACPT_STATE), "acpt_state"},
- {ERR_FUNC(BIO_F_ADDR_STRINGS), "addr_strings"},
- {ERR_FUNC(BIO_F_BIO_ACCEPT), "BIO_accept"},
- {ERR_FUNC(BIO_F_BIO_ACCEPT_EX), "BIO_accept_ex"},
- {ERR_FUNC(BIO_F_BIO_ADDR_NEW), "BIO_ADDR_new"},
- {ERR_FUNC(BIO_F_BIO_CALLBACK_CTRL), "BIO_callback_ctrl"},
- {ERR_FUNC(BIO_F_BIO_CONNECT), "BIO_connect"},
- {ERR_FUNC(BIO_F_BIO_CTRL), "BIO_ctrl"},
- {ERR_FUNC(BIO_F_BIO_GETS), "BIO_gets"},
- {ERR_FUNC(BIO_F_BIO_GET_HOST_IP), "BIO_get_host_ip"},
- {ERR_FUNC(BIO_F_BIO_GET_NEW_INDEX), "BIO_get_new_index"},
- {ERR_FUNC(BIO_F_BIO_GET_PORT), "BIO_get_port"},
- {ERR_FUNC(BIO_F_BIO_LISTEN), "BIO_listen"},
- {ERR_FUNC(BIO_F_BIO_LOOKUP), "BIO_lookup"},
- {ERR_FUNC(BIO_F_BIO_MAKE_PAIR), "bio_make_pair"},
- {ERR_FUNC(BIO_F_BIO_METH_NEW), "BIO_meth_new"},
- {ERR_FUNC(BIO_F_BIO_NEW), "BIO_new"},
- {ERR_FUNC(BIO_F_BIO_NEW_FILE), "BIO_new_file"},
- {ERR_FUNC(BIO_F_BIO_NEW_MEM_BUF), "BIO_new_mem_buf"},
- {ERR_FUNC(BIO_F_BIO_NREAD), "BIO_nread"},
- {ERR_FUNC(BIO_F_BIO_NREAD0), "BIO_nread0"},
- {ERR_FUNC(BIO_F_BIO_NWRITE), "BIO_nwrite"},
- {ERR_FUNC(BIO_F_BIO_NWRITE0), "BIO_nwrite0"},
- {ERR_FUNC(BIO_F_BIO_PARSE_HOSTSERV), "BIO_parse_hostserv"},
- {ERR_FUNC(BIO_F_BIO_PUTS), "BIO_puts"},
- {ERR_FUNC(BIO_F_BIO_READ), "BIO_read"},
- {ERR_FUNC(BIO_F_BIO_SOCKET), "BIO_socket"},
- {ERR_FUNC(BIO_F_BIO_SOCKET_NBIO), "BIO_socket_nbio"},
- {ERR_FUNC(BIO_F_BIO_SOCK_INFO), "BIO_sock_info"},
- {ERR_FUNC(BIO_F_BIO_SOCK_INIT), "BIO_sock_init"},
- {ERR_FUNC(BIO_F_BIO_WRITE), "BIO_write"},
- {ERR_FUNC(BIO_F_BUFFER_CTRL), "buffer_ctrl"},
- {ERR_FUNC(BIO_F_CONN_CTRL), "conn_ctrl"},
- {ERR_FUNC(BIO_F_CONN_STATE), "conn_state"},
- {ERR_FUNC(BIO_F_DGRAM_SCTP_READ), "dgram_sctp_read"},
- {ERR_FUNC(BIO_F_DGRAM_SCTP_WRITE), "dgram_sctp_write"},
- {ERR_FUNC(BIO_F_FILE_CTRL), "file_ctrl"},
- {ERR_FUNC(BIO_F_FILE_READ), "file_read"},
- {ERR_FUNC(BIO_F_LINEBUFFER_CTRL), "linebuffer_ctrl"},
- {ERR_FUNC(BIO_F_MEM_WRITE), "mem_write"},
- {ERR_FUNC(BIO_F_SSL_NEW), "SSL_new"},
+static const ERR_STRING_DATA BIO_str_functs[] = {
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_ACPT_STATE, 0), "acpt_state"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_ADDRINFO_WRAP, 0), "addrinfo_wrap"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_ADDR_STRINGS, 0), "addr_strings"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_ACCEPT, 0), "BIO_accept"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_ACCEPT_EX, 0), "BIO_accept_ex"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_ACCEPT_NEW, 0), "BIO_ACCEPT_new"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_ADDR_NEW, 0), "BIO_ADDR_new"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_BIND, 0), "BIO_bind"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_CALLBACK_CTRL, 0), "BIO_callback_ctrl"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_CONNECT, 0), "BIO_connect"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_CONNECT_NEW, 0), "BIO_CONNECT_new"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_CTRL, 0), "BIO_ctrl"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_GETS, 0), "BIO_gets"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_GET_HOST_IP, 0), "BIO_get_host_ip"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_GET_NEW_INDEX, 0), "BIO_get_new_index"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_GET_PORT, 0), "BIO_get_port"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_LISTEN, 0), "BIO_listen"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_LOOKUP, 0), "BIO_lookup"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_LOOKUP_EX, 0), "BIO_lookup_ex"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_MAKE_PAIR, 0), "bio_make_pair"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_METH_NEW, 0), "BIO_meth_new"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_NEW, 0), "BIO_new"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_NEW_DGRAM_SCTP, 0), "BIO_new_dgram_sctp"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_NEW_FILE, 0), "BIO_new_file"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_NEW_MEM_BUF, 0), "BIO_new_mem_buf"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_NREAD, 0), "BIO_nread"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_NREAD0, 0), "BIO_nread0"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_NWRITE, 0), "BIO_nwrite"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_NWRITE0, 0), "BIO_nwrite0"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_PARSE_HOSTSERV, 0), "BIO_parse_hostserv"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_PUTS, 0), "BIO_puts"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_READ, 0), "BIO_read"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_READ_EX, 0), "BIO_read_ex"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_READ_INTERN, 0), "bio_read_intern"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_SOCKET, 0), "BIO_socket"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_SOCKET_NBIO, 0), "BIO_socket_nbio"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_SOCK_INFO, 0), "BIO_sock_info"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_SOCK_INIT, 0), "BIO_sock_init"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_WRITE, 0), "BIO_write"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_WRITE_EX, 0), "BIO_write_ex"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_BIO_WRITE_INTERN, 0), "bio_write_intern"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_BUFFER_CTRL, 0), "buffer_ctrl"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_CONN_CTRL, 0), "conn_ctrl"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_CONN_STATE, 0), "conn_state"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_DGRAM_SCTP_NEW, 0), "dgram_sctp_new"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_DGRAM_SCTP_READ, 0), "dgram_sctp_read"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_DGRAM_SCTP_WRITE, 0), "dgram_sctp_write"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_DOAPR_OUTCH, 0), "doapr_outch"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_FILE_CTRL, 0), "file_ctrl"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_FILE_READ, 0), "file_read"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_LINEBUFFER_CTRL, 0), "linebuffer_ctrl"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_LINEBUFFER_NEW, 0), "linebuffer_new"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_MEM_WRITE, 0), "mem_write"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_NBIOF_NEW, 0), "nbiof_new"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_SLG_WRITE, 0), "slg_write"},
+ {ERR_PACK(ERR_LIB_BIO, BIO_F_SSL_NEW, 0), "SSL_new"},
{0, NULL}
};
-static ERR_STRING_DATA BIO_str_reasons[] = {
- {ERR_REASON(BIO_R_ACCEPT_ERROR), "accept error"},
- {ERR_REASON(BIO_R_ADDRINFO_ADDR_IS_NOT_AF_INET),
- "addrinfo addr is not af inet"},
- {ERR_REASON(BIO_R_AMBIGUOUS_HOST_OR_SERVICE),
- "ambiguous host or service"},
- {ERR_REASON(BIO_R_BAD_FOPEN_MODE), "bad fopen mode"},
- {ERR_REASON(BIO_R_BROKEN_PIPE), "broken pipe"},
- {ERR_REASON(BIO_R_CONNECT_ERROR), "connect error"},
- {ERR_REASON(BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET),
- "gethostbyname addr is not af inet"},
- {ERR_REASON(BIO_R_GETSOCKNAME_ERROR), "getsockname error"},
- {ERR_REASON(BIO_R_GETSOCKNAME_TRUNCATED_ADDRESS),
- "getsockname truncated address"},
- {ERR_REASON(BIO_R_GETTING_SOCKTYPE), "getting socktype"},
- {ERR_REASON(BIO_R_INVALID_ARGUMENT), "invalid argument"},
- {ERR_REASON(BIO_R_INVALID_SOCKET), "invalid socket"},
- {ERR_REASON(BIO_R_IN_USE), "in use"},
- {ERR_REASON(BIO_R_LISTEN_V6_ONLY), "listen v6 only"},
- {ERR_REASON(BIO_R_LOOKUP_RETURNED_NOTHING), "lookup returned nothing"},
- {ERR_REASON(BIO_R_MALFORMED_HOST_OR_SERVICE),
- "malformed host or service"},
- {ERR_REASON(BIO_R_NBIO_CONNECT_ERROR), "nbio connect error"},
- {ERR_REASON(BIO_R_NO_ACCEPT_ADDR_OR_SERVICE_SPECIFIED),
- "no accept addr or service specified"},
- {ERR_REASON(BIO_R_NO_HOSTNAME_OR_SERVICE_SPECIFIED),
- "no hostname or service specified"},
- {ERR_REASON(BIO_R_NO_PORT_DEFINED), "no port defined"},
- {ERR_REASON(BIO_R_NO_SUCH_FILE), "no such file"},
- {ERR_REASON(BIO_R_NULL_PARAMETER), "null parameter"},
- {ERR_REASON(BIO_R_UNABLE_TO_BIND_SOCKET), "unable to bind socket"},
- {ERR_REASON(BIO_R_UNABLE_TO_CREATE_SOCKET), "unable to create socket"},
- {ERR_REASON(BIO_R_UNABLE_TO_KEEPALIVE), "unable to keepalive"},
- {ERR_REASON(BIO_R_UNABLE_TO_LISTEN_SOCKET), "unable to listen socket"},
- {ERR_REASON(BIO_R_UNABLE_TO_NODELAY), "unable to nodelay"},
- {ERR_REASON(BIO_R_UNABLE_TO_REUSEADDR), "unable to reuseaddr"},
- {ERR_REASON(BIO_R_UNAVAILABLE_IP_FAMILY), "unavailable ip family"},
- {ERR_REASON(BIO_R_UNINITIALIZED), "uninitialized"},
- {ERR_REASON(BIO_R_UNKNOWN_INFO_TYPE), "unknown info type"},
- {ERR_REASON(BIO_R_UNSUPPORTED_IP_FAMILY), "unsupported ip family"},
- {ERR_REASON(BIO_R_UNSUPPORTED_METHOD), "unsupported method"},
- {ERR_REASON(BIO_R_UNSUPPORTED_PROTOCOL_FAMILY),
- "unsupported protocol family"},
- {ERR_REASON(BIO_R_WRITE_TO_READ_ONLY_BIO), "write to read only BIO"},
- {ERR_REASON(BIO_R_WSASTARTUP), "WSAStartup"},
+static const ERR_STRING_DATA BIO_str_reasons[] = {
+ {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_ACCEPT_ERROR), "accept error"},
+ {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_ADDRINFO_ADDR_IS_NOT_AF_INET),
+ "addrinfo addr is not af inet"},
+ {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_AMBIGUOUS_HOST_OR_SERVICE),
+ "ambiguous host or service"},
+ {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_BAD_FOPEN_MODE), "bad fopen mode"},
+ {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_BROKEN_PIPE), "broken pipe"},
+ {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_CONNECT_ERROR), "connect error"},
+ {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET),
+ "gethostbyname addr is not af inet"},
+ {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_GETSOCKNAME_ERROR), "getsockname error"},
+ {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_GETSOCKNAME_TRUNCATED_ADDRESS),
+ "getsockname truncated address"},
+ {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_GETTING_SOCKTYPE), "getting socktype"},
+ {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_INVALID_ARGUMENT), "invalid argument"},
+ {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_INVALID_SOCKET), "invalid socket"},
+ {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_IN_USE), "in use"},
+ {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_LENGTH_TOO_LONG), "length too long"},
+ {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_LISTEN_V6_ONLY), "listen v6 only"},
+ {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_LOOKUP_RETURNED_NOTHING),
+ "lookup returned nothing"},
+ {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_MALFORMED_HOST_OR_SERVICE),
+ "malformed host or service"},
+ {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_NBIO_CONNECT_ERROR), "nbio connect error"},
+ {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_NO_ACCEPT_ADDR_OR_SERVICE_SPECIFIED),
+ "no accept addr or service specified"},
+ {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_NO_HOSTNAME_OR_SERVICE_SPECIFIED),
+ "no hostname or service specified"},
+ {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_NO_PORT_DEFINED), "no port defined"},
+ {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_NO_SUCH_FILE), "no such file"},
+ {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_NULL_PARAMETER), "null parameter"},
+ {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_UNABLE_TO_BIND_SOCKET),
+ "unable to bind socket"},
+ {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_UNABLE_TO_CREATE_SOCKET),
+ "unable to create socket"},
+ {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_UNABLE_TO_KEEPALIVE),
+ "unable to keepalive"},
+ {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_UNABLE_TO_LISTEN_SOCKET),
+ "unable to listen socket"},
+ {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_UNABLE_TO_NODELAY), "unable to nodelay"},
+ {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_UNABLE_TO_REUSEADDR),
+ "unable to reuseaddr"},
+ {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_UNAVAILABLE_IP_FAMILY),
+ "unavailable ip family"},
+ {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_UNINITIALIZED), "uninitialized"},
+ {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_UNKNOWN_INFO_TYPE), "unknown info type"},
+ {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_UNSUPPORTED_IP_FAMILY),
+ "unsupported ip family"},
+ {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_UNSUPPORTED_METHOD), "unsupported method"},
+ {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_UNSUPPORTED_PROTOCOL_FAMILY),
+ "unsupported protocol family"},
+ {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_WRITE_TO_READ_ONLY_BIO),
+ "write to read only BIO"},
+ {ERR_PACK(ERR_LIB_BIO, 0, BIO_R_WSASTARTUP), "WSAStartup"},
{0, NULL}
};
@@ -116,10 +136,9 @@ static ERR_STRING_DATA BIO_str_reasons[] = {
int ERR_load_BIO_strings(void)
{
#ifndef OPENSSL_NO_ERR
-
if (ERR_func_error_string(BIO_str_functs[0].error) == NULL) {
- ERR_load_strings(0, BIO_str_functs);
- ERR_load_strings(0, BIO_str_reasons);
+ ERR_load_strings_const(BIO_str_functs);
+ ERR_load_strings_const(BIO_str_reasons);
}
#endif
return 1;
diff --git a/deps/openssl/openssl/crypto/bio/bio_lcl.h b/deps/openssl/openssl/crypto/bio/bio_lcl.h
index 39178cf50a..e2c05a20de 100644
--- a/deps/openssl/openssl/crypto/bio/bio_lcl.h
+++ b/deps/openssl/openssl/crypto/bio/bio_lcl.h
@@ -7,8 +7,9 @@
* https://www.openssl.org/source/license.html
*/
-#define USE_SOCKETS
#include "e_os.h"
+#include "internal/sockets.h"
+#include "internal/refcount.h"
/* BEGIN BIO_ADDRINFO/BIO_ADDR stuff. */
@@ -86,7 +87,7 @@ union bio_addr_st {
/* END BIO_ADDRINFO/BIO_ADDR stuff. */
#include "internal/cryptlib.h"
-#include <internal/bio.h>
+#include "internal/bio.h"
typedef struct bio_f_buffer_ctx_struct {
/*-
@@ -114,7 +115,8 @@ typedef struct bio_f_buffer_ctx_struct {
struct bio_st {
const BIO_METHOD *method;
/* bio, mode, argp, argi, argl, ret */
- long (*callback) (struct bio_st *, int, const char *, int, long, long);
+ BIO_callback_fn callback;
+ BIO_callback_fn_ex callback_ex;
char *cb_arg; /* first argument for the callback */
int init;
int shutdown;
@@ -124,7 +126,7 @@ struct bio_st {
void *ptr;
struct bio_st *next_bio; /* used by filter BIOs */
struct bio_st *prev_bio; /* used by filter BIOs */
- int references;
+ CRYPTO_REF_COUNT references;
uint64_t num_read;
uint64_t num_write;
CRYPTO_EX_DATA ex_data;
diff --git a/deps/openssl/openssl/crypto/bio/bio_lib.c b/deps/openssl/openssl/crypto/bio/bio_lib.c
index 7b98dc931e..ca375b911a 100644
--- a/deps/openssl/openssl/crypto/bio/bio_lib.c
+++ b/deps/openssl/openssl/crypto/bio/bio_lib.c
@@ -13,13 +13,68 @@
#include "bio_lcl.h"
#include "internal/cryptlib.h"
+
+/*
+ * Helper macro for the callback to determine whether an operator expects a
+ * len parameter or not
+ */
+#define HAS_LEN_OPER(o) ((o) == BIO_CB_READ || (o) == BIO_CB_WRITE || \
+ (o) == BIO_CB_GETS)
+
+/*
+ * Helper function to work out whether to call the new style callback or the old
+ * one, and translate between the two.
+ *
+ * This has a long return type for consistency with the old callback. Similarly
+ * for the "long" used for "inret"
+ */
+static long bio_call_callback(BIO *b, int oper, const char *argp, size_t len,
+ int argi, long argl, long inret, size_t *processed)
+{
+ long ret;
+ int bareoper;
+
+ if (b->callback_ex != NULL)
+ return b->callback_ex(b, oper, argp, len, argi, argl, inret, processed);
+
+ /* Strip off any BIO_CB_RETURN flag */
+ bareoper = oper & ~BIO_CB_RETURN;
+
+ /*
+ * We have an old style callback, so we will have to do nasty casts and
+ * check for overflows.
+ */
+ if (HAS_LEN_OPER(bareoper)) {
+ /* In this case |len| is set, and should be used instead of |argi| */
+ if (len > INT_MAX)
+ return -1;
+
+ argi = (int)len;
+ }
+
+ if (inret > 0 && (oper & BIO_CB_RETURN) && bareoper != BIO_CB_CTRL) {
+ if (*processed > INT_MAX)
+ return -1;
+ inret = *processed;
+ }
+
+ ret = b->callback(b, oper, argp, argi, argl, inret);
+
+ if (ret > 0 && (oper & BIO_CB_RETURN) && bareoper != BIO_CB_CTRL) {
+ *processed = (size_t)ret;
+ ret = 1;
+ }
+
+ return ret;
+}
+
BIO *BIO_new(const BIO_METHOD *method)
{
BIO *bio = OPENSSL_zalloc(sizeof(*bio));
if (bio == NULL) {
BIOerr(BIO_F_BIO_NEW, ERR_R_MALLOC_FAILURE);
- return (NULL);
+ return NULL;
}
bio->method = method;
@@ -54,21 +109,24 @@ err:
int BIO_free(BIO *a)
{
- int i;
+ int ret;
if (a == NULL)
return 0;
- if (CRYPTO_atomic_add(&a->references, -1, &i, a->lock) <= 0)
+ if (CRYPTO_DOWN_REF(&a->references, &ret, a->lock) <= 0)
return 0;
REF_PRINT_COUNT("BIO", a);
- if (i > 0)
+ if (ret > 0)
return 1;
- REF_ASSERT_ISNT(i < 0);
- if ((a->callback != NULL) &&
- ((i = (int)a->callback(a, BIO_CB_FREE, NULL, 0, 0L, 1L)) <= 0))
- return i;
+ REF_ASSERT_ISNT(ret < 0);
+
+ if (a->callback != NULL || a->callback_ex != NULL) {
+ ret = (int)bio_call_callback(a, BIO_CB_FREE, NULL, 0, 0, 0L, 1L, NULL);
+ if (ret <= 0)
+ return ret;
+ }
if ((a->method != NULL) && (a->method->destroy != NULL))
a->method->destroy(a);
@@ -121,7 +179,7 @@ int BIO_up_ref(BIO *a)
{
int i;
- if (CRYPTO_atomic_add(&a->references, 1, &i, a->lock) <= 0)
+ if (CRYPTO_UP_REF(&a->references, &i, a->lock) <= 0)
return 0;
REF_PRINT_COUNT("BIO", a);
@@ -144,18 +202,26 @@ void BIO_set_flags(BIO *b, int flags)
b->flags |= flags;
}
-long (*BIO_get_callback(const BIO *b)) (struct bio_st *, int, const char *,
- int, long, long) {
+BIO_callback_fn BIO_get_callback(const BIO *b)
+{
return b->callback;
}
-void BIO_set_callback(BIO *b,
- long (*cb) (struct bio_st *, int, const char *, int,
- long, long))
+void BIO_set_callback(BIO *b, BIO_callback_fn cb)
{
b->callback = cb;
}
+BIO_callback_fn_ex BIO_get_callback_ex(const BIO *b)
+{
+ return b->callback_ex;
+}
+
+void BIO_set_callback_ex(BIO *b, BIO_callback_fn_ex cb)
+{
+ b->callback_ex = cb;
+}
+
void BIO_set_callback_arg(BIO *b, char *arg)
{
b->cb_arg = arg;
@@ -176,124 +242,239 @@ int BIO_method_type(const BIO *b)
return b->method->type;
}
-int BIO_read(BIO *b, void *out, int outl)
+/*
+ * This is essentially the same as BIO_read_ex() except that it allows
+ * 0 or a negative value to indicate failure (retryable or not) in the return.
+ * This is for compatibility with the old style BIO_read(), where existing code
+ * may make assumptions about the return value that it might get.
+ */
+static int bio_read_intern(BIO *b, void *data, size_t dlen, size_t *readbytes)
{
- int i;
- long (*cb) (BIO *, int, const char *, int, long, long);
+ int ret;
if ((b == NULL) || (b->method == NULL) || (b->method->bread == NULL)) {
- BIOerr(BIO_F_BIO_READ, BIO_R_UNSUPPORTED_METHOD);
- return (-2);
+ BIOerr(BIO_F_BIO_READ_INTERN, BIO_R_UNSUPPORTED_METHOD);
+ return -2;
}
- cb = b->callback;
- if ((cb != NULL) &&
- ((i = (int)cb(b, BIO_CB_READ, out, outl, 0L, 1L)) <= 0))
- return (i);
+ if ((b->callback != NULL || b->callback_ex != NULL) &&
+ ((ret = (int)bio_call_callback(b, BIO_CB_READ, data, dlen, 0, 0L, 1L,
+ NULL)) <= 0))
+ return ret;
if (!b->init) {
- BIOerr(BIO_F_BIO_READ, BIO_R_UNINITIALIZED);
- return (-2);
+ BIOerr(BIO_F_BIO_READ_INTERN, BIO_R_UNINITIALIZED);
+ return -2;
+ }
+
+ ret = b->method->bread(b, data, dlen, readbytes);
+
+ if (ret > 0)
+ b->num_read += (uint64_t)*readbytes;
+
+ if (b->callback != NULL || b->callback_ex != NULL)
+ ret = (int)bio_call_callback(b, BIO_CB_READ | BIO_CB_RETURN, data,
+ dlen, 0, 0L, ret, readbytes);
+
+ /* Shouldn't happen */
+ if (ret > 0 && *readbytes > dlen) {
+ BIOerr(BIO_F_BIO_READ_INTERN, ERR_R_INTERNAL_ERROR);
+ return -1;
}
- i = b->method->bread(b, out, outl);
+ return ret;
+}
+
+int BIO_read(BIO *b, void *data, int dlen)
+{
+ size_t readbytes;
+ int ret;
+
+ if (dlen < 0)
+ return 0;
- if (i > 0)
- b->num_read += (uint64_t)i;
+ ret = bio_read_intern(b, data, (size_t)dlen, &readbytes);
- if (cb != NULL)
- i = (int)cb(b, BIO_CB_READ | BIO_CB_RETURN, out, outl, 0L, (long)i);
- return (i);
+ if (ret > 0) {
+ /* *readbytes should always be <= dlen */
+ ret = (int)readbytes;
+ }
+
+ return ret;
}
-int BIO_write(BIO *b, const void *in, int inl)
+int BIO_read_ex(BIO *b, void *data, size_t dlen, size_t *readbytes)
{
- int i;
- long (*cb) (BIO *, int, const char *, int, long, long);
+ int ret;
+
+ ret = bio_read_intern(b, data, dlen, readbytes);
+
+ if (ret > 0)
+ ret = 1;
+ else
+ ret = 0;
+
+ return ret;
+}
+
+static int bio_write_intern(BIO *b, const void *data, size_t dlen,
+ size_t *written)
+{
+ int ret;
if (b == NULL)
- return (0);
+ return 0;
- cb = b->callback;
if ((b->method == NULL) || (b->method->bwrite == NULL)) {
- BIOerr(BIO_F_BIO_WRITE, BIO_R_UNSUPPORTED_METHOD);
- return (-2);
+ BIOerr(BIO_F_BIO_WRITE_INTERN, BIO_R_UNSUPPORTED_METHOD);
+ return -2;
}
- if ((cb != NULL) &&
- ((i = (int)cb(b, BIO_CB_WRITE, in, inl, 0L, 1L)) <= 0))
- return (i);
+ if ((b->callback != NULL || b->callback_ex != NULL) &&
+ ((ret = (int)bio_call_callback(b, BIO_CB_WRITE, data, dlen, 0, 0L, 1L,
+ NULL)) <= 0))
+ return ret;
if (!b->init) {
- BIOerr(BIO_F_BIO_WRITE, BIO_R_UNINITIALIZED);
- return (-2);
+ BIOerr(BIO_F_BIO_WRITE_INTERN, BIO_R_UNINITIALIZED);
+ return -2;
}
- i = b->method->bwrite(b, in, inl);
+ ret = b->method->bwrite(b, data, dlen, written);
+
+ if (ret > 0)
+ b->num_write += (uint64_t)*written;
- if (i > 0)
- b->num_write += (uint64_t)i;
+ if (b->callback != NULL || b->callback_ex != NULL)
+ ret = (int)bio_call_callback(b, BIO_CB_WRITE | BIO_CB_RETURN, data,
+ dlen, 0, 0L, ret, written);
- if (cb != NULL)
- i = (int)cb(b, BIO_CB_WRITE | BIO_CB_RETURN, in, inl, 0L, (long)i);
- return (i);
+ return ret;
}
-int BIO_puts(BIO *b, const char *in)
+int BIO_write(BIO *b, const void *data, int dlen)
{
- int i;
- long (*cb) (BIO *, int, const char *, int, long, long);
+ size_t written;
+ int ret;
+
+ if (dlen < 0)
+ return 0;
+
+ ret = bio_write_intern(b, data, (size_t)dlen, &written);
+
+ if (ret > 0) {
+ /* *written should always be <= dlen */
+ ret = (int)written;
+ }
+
+ return ret;
+}
+
+int BIO_write_ex(BIO *b, const void *data, size_t dlen, size_t *written)
+{
+ int ret;
+
+ ret = bio_write_intern(b, data, dlen, written);
+
+ if (ret > 0)
+ ret = 1;
+ else
+ ret = 0;
+
+ return ret;
+}
+
+int BIO_puts(BIO *b, const char *buf)
+{
+ int ret;
+ size_t written = 0;
if ((b == NULL) || (b->method == NULL) || (b->method->bputs == NULL)) {
BIOerr(BIO_F_BIO_PUTS, BIO_R_UNSUPPORTED_METHOD);
- return (-2);
+ return -2;
}
- cb = b->callback;
-
- if ((cb != NULL) && ((i = (int)cb(b, BIO_CB_PUTS, in, 0, 0L, 1L)) <= 0))
- return (i);
+ if (b->callback != NULL || b->callback_ex != NULL) {
+ ret = (int)bio_call_callback(b, BIO_CB_PUTS, buf, 0, 0, 0L, 1L, NULL);
+ if (ret <= 0)
+ return ret;
+ }
if (!b->init) {
BIOerr(BIO_F_BIO_PUTS, BIO_R_UNINITIALIZED);
- return (-2);
+ return -2;
+ }
+
+ ret = b->method->bputs(b, buf);
+
+ if (ret > 0) {
+ b->num_write += (uint64_t)ret;
+ written = ret;
+ ret = 1;
}
- i = b->method->bputs(b, in);
+ if (b->callback != NULL || b->callback_ex != NULL)
+ ret = (int)bio_call_callback(b, BIO_CB_PUTS | BIO_CB_RETURN, buf, 0, 0,
+ 0L, ret, &written);
- if (i > 0)
- b->num_write += (uint64_t)i;
+ if (ret > 0) {
+ if (written > INT_MAX) {
+ BIOerr(BIO_F_BIO_PUTS, BIO_R_LENGTH_TOO_LONG);
+ ret = -1;
+ } else {
+ ret = (int)written;
+ }
+ }
- if (cb != NULL)
- i = (int)cb(b, BIO_CB_PUTS | BIO_CB_RETURN, in, 0, 0L, (long)i);
- return (i);
+ return ret;
}
-int BIO_gets(BIO *b, char *in, int inl)
+int BIO_gets(BIO *b, char *buf, int size)
{
- int i;
- long (*cb) (BIO *, int, const char *, int, long, long);
+ int ret;
+ size_t readbytes = 0;
if ((b == NULL) || (b->method == NULL) || (b->method->bgets == NULL)) {
BIOerr(BIO_F_BIO_GETS, BIO_R_UNSUPPORTED_METHOD);
- return (-2);
+ return -2;
}
- cb = b->callback;
+ if (size < 0) {
+ BIOerr(BIO_F_BIO_GETS, BIO_R_INVALID_ARGUMENT);
+ return 0;
+ }
- if ((cb != NULL) && ((i = (int)cb(b, BIO_CB_GETS, in, inl, 0L, 1L)) <= 0))
- return (i);
+ if (b->callback != NULL || b->callback_ex != NULL) {
+ ret = (int)bio_call_callback(b, BIO_CB_GETS, buf, size, 0, 0L, 1, NULL);
+ if (ret <= 0)
+ return ret;
+ }
if (!b->init) {
BIOerr(BIO_F_BIO_GETS, BIO_R_UNINITIALIZED);
- return (-2);
+ return -2;
+ }
+
+ ret = b->method->bgets(b, buf, size);
+
+ if (ret > 0) {
+ readbytes = ret;
+ ret = 1;
}
- i = b->method->bgets(b, in, inl);
+ if (b->callback != NULL || b->callback_ex != NULL)
+ ret = (int)bio_call_callback(b, BIO_CB_GETS | BIO_CB_RETURN, buf, size,
+ 0, 0L, ret, &readbytes);
+
+ if (ret > 0) {
+ /* Shouldn't happen */
+ if (readbytes > (size_t)size)
+ ret = -1;
+ else
+ ret = (int)readbytes;
+ }
- if (cb != NULL)
- i = (int)cb(b, BIO_CB_GETS | BIO_CB_RETURN, in, inl, 0L, (long)i);
- return (i);
+ return ret;
}
int BIO_indent(BIO *b, int indent, int max)
@@ -313,7 +494,7 @@ long BIO_int_ctrl(BIO *b, int cmd, long larg, int iarg)
int i;
i = iarg;
- return (BIO_ctrl(b, cmd, larg, (char *)&i));
+ return BIO_ctrl(b, cmd, larg, (char *)&i);
}
void *BIO_ptr_ctrl(BIO *b, int cmd, long larg)
@@ -321,61 +502,65 @@ void *BIO_ptr_ctrl(BIO *b, int cmd, long larg)
void *p = NULL;
if (BIO_ctrl(b, cmd, larg, (char *)&p) <= 0)
- return (NULL);
+ return NULL;
else
- return (p);
+ return p;
}
long BIO_ctrl(BIO *b, int cmd, long larg, void *parg)
{
long ret;
- long (*cb) (BIO *, int, const char *, int, long, long);
if (b == NULL)
- return (0);
+ return 0;
if ((b->method == NULL) || (b->method->ctrl == NULL)) {
BIOerr(BIO_F_BIO_CTRL, BIO_R_UNSUPPORTED_METHOD);
- return (-2);
+ return -2;
}
- cb = b->callback;
-
- if ((cb != NULL) &&
- ((ret = cb(b, BIO_CB_CTRL, parg, cmd, larg, 1L)) <= 0))
- return (ret);
+ if (b->callback != NULL || b->callback_ex != NULL) {
+ ret = bio_call_callback(b, BIO_CB_CTRL, parg, 0, cmd, larg, 1L, NULL);
+ if (ret <= 0)
+ return ret;
+ }
ret = b->method->ctrl(b, cmd, larg, parg);
- if (cb != NULL)
- ret = cb(b, BIO_CB_CTRL | BIO_CB_RETURN, parg, cmd, larg, ret);
- return (ret);
+ if (b->callback != NULL || b->callback_ex != NULL)
+ ret = bio_call_callback(b, BIO_CB_CTRL | BIO_CB_RETURN, parg, 0, cmd,
+ larg, ret, NULL);
+
+ return ret;
}
long BIO_callback_ctrl(BIO *b, int cmd, BIO_info_cb *fp)
{
long ret;
- long (*cb) (BIO *, int, const char *, int, long, long);
if (b == NULL)
- return (0);
+ return 0;
- if ((b->method == NULL) || (b->method->callback_ctrl == NULL)) {
+ if ((b->method == NULL) || (b->method->callback_ctrl == NULL)
+ || (cmd != BIO_CTRL_SET_CALLBACK)) {
BIOerr(BIO_F_BIO_CALLBACK_CTRL, BIO_R_UNSUPPORTED_METHOD);
- return (-2);
+ return -2;
}
- cb = b->callback;
-
- if ((cb != NULL) &&
- ((ret = cb(b, BIO_CB_CTRL, (void *)&fp, cmd, 0, 1L)) <= 0))
- return (ret);
+ if (b->callback != NULL || b->callback_ex != NULL) {
+ ret = bio_call_callback(b, BIO_CB_CTRL, (void *)&fp, 0, cmd, 0, 1L,
+ NULL);
+ if (ret <= 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);
+ if (b->callback != NULL || b->callback_ex != NULL)
+ ret = bio_call_callback(b, BIO_CB_CTRL | BIO_CB_RETURN, (void *)&fp, 0,
+ cmd, 0, ret, NULL);
+
+ return ret;
}
/*
@@ -399,7 +584,7 @@ BIO *BIO_push(BIO *b, BIO *bio)
BIO *lb;
if (b == NULL)
- return (bio);
+ return bio;
lb = b;
while (lb->next_bio != NULL)
lb = lb->next_bio;
@@ -408,7 +593,7 @@ BIO *BIO_push(BIO *b, BIO *bio)
bio->prev_bio = lb;
/* called to do internal processing */
BIO_ctrl(b, BIO_CTRL_PUSH, 0, lb);
- return (b);
+ return b;
}
/* Remove the first and return the rest */
@@ -417,7 +602,7 @@ BIO *BIO_pop(BIO *b)
BIO *ret;
if (b == NULL)
- return (NULL);
+ return NULL;
ret = b->next_bio;
BIO_ctrl(b, BIO_CTRL_POP, 0, b);
@@ -429,7 +614,7 @@ BIO *BIO_pop(BIO *b)
b->next_bio = NULL;
b->prev_bio = NULL;
- return (ret);
+ return ret;
}
BIO *BIO_get_retry_BIO(BIO *bio, int *reason)
@@ -447,12 +632,12 @@ BIO *BIO_get_retry_BIO(BIO *bio, int *reason)
}
if (reason != NULL)
*reason = last->retry_reason;
- return (last);
+ return last;
}
int BIO_get_retry_reason(BIO *bio)
{
- return (bio->retry_reason);
+ return bio->retry_reason;
}
void BIO_set_retry_reason(BIO *bio, int reason)
@@ -473,13 +658,13 @@ BIO *BIO_find_type(BIO *bio, int type)
if (!mask) {
if (mt & type)
- return (bio);
+ return bio;
} else if (mt == type)
- return (bio);
+ return bio;
}
bio = bio->next_bio;
} while (bio != NULL);
- return (NULL);
+ return NULL;
}
BIO *BIO_next(BIO *b)
@@ -518,6 +703,7 @@ BIO *BIO_dup_chain(BIO *in)
if ((new_bio = BIO_new(bio->method)) == NULL)
goto err;
new_bio->callback = bio->callback;
+ new_bio->callback_ex = bio->callback_ex;
new_bio->cb_arg = bio->cb_arg;
new_bio->init = bio->init;
new_bio->shutdown = bio->shutdown;
@@ -546,11 +732,11 @@ BIO *BIO_dup_chain(BIO *in)
eoc = new_bio;
}
}
- return (ret);
+ return ret;
err:
BIO_free_all(ret);
- return (NULL);
+ return NULL;
}
void BIO_copy_next_retry(BIO *b)
@@ -561,12 +747,12 @@ void BIO_copy_next_retry(BIO *b)
int BIO_set_ex_data(BIO *bio, int idx, void *data)
{
- return (CRYPTO_set_ex_data(&(bio->ex_data), idx, data));
+ return CRYPTO_set_ex_data(&(bio->ex_data), idx, data);
}
void *BIO_get_ex_data(BIO *bio, int idx)
{
- return (CRYPTO_get_ex_data(&(bio->ex_data), idx));
+ return CRYPTO_get_ex_data(&(bio->ex_data), idx);
}
uint64_t BIO_number_read(BIO *bio)
diff --git a/deps/openssl/openssl/crypto/bio/bio_meth.c b/deps/openssl/openssl/crypto/bio/bio_meth.c
index 63a7cccc82..493ff63a90 100644
--- a/deps/openssl/openssl/crypto/bio/bio_meth.c
+++ b/deps/openssl/openssl/crypto/bio/bio_meth.c
@@ -8,7 +8,7 @@
*/
#include "bio_lcl.h"
-#include <internal/thread_once.h>
+#include "internal/thread_once.h"
CRYPTO_RWLOCK *bio_type_lock = NULL;
static CRYPTO_ONCE bio_type_init = CRYPTO_ONCE_STATIC_INIT;
@@ -19,16 +19,16 @@ DEFINE_RUN_ONCE_STATIC(do_bio_type_init)
return bio_type_lock != NULL;
}
-int BIO_get_new_index()
+int BIO_get_new_index(void)
{
- static int bio_count = BIO_TYPE_START;
+ static CRYPTO_REF_COUNT bio_count = BIO_TYPE_START;
int newval;
if (!RUN_ONCE(&bio_type_init, do_bio_type_init)) {
BIOerr(BIO_F_BIO_GET_NEW_INDEX, ERR_R_MALLOC_FAILURE);
return -1;
}
- if (!CRYPTO_atomic_add(&bio_count, 1, &newval, bio_type_lock))
+ if (!CRYPTO_UP_REF(&bio_count, &newval, bio_type_lock))
return -1;
return newval;
}
@@ -57,24 +57,93 @@ void BIO_meth_free(BIO_METHOD *biom)
int (*BIO_meth_get_write(const BIO_METHOD *biom)) (BIO *, const char *, int)
{
+ return biom->bwrite_old;
+}
+
+int (*BIO_meth_get_write_ex(const BIO_METHOD *biom)) (BIO *, const char *, size_t,
+ size_t *)
+{
return biom->bwrite;
}
+/* Conversion for old style bwrite to new style */
+int bwrite_conv(BIO *bio, const char *data, size_t datal, size_t *written)
+{
+ int ret;
+
+ if (datal > INT_MAX)
+ datal = INT_MAX;
+
+ ret = bio->method->bwrite_old(bio, data, (int)datal);
+
+ if (ret <= 0) {
+ *written = 0;
+ return ret;
+ }
+
+ *written = (size_t)ret;
+
+ return 1;
+}
+
int BIO_meth_set_write(BIO_METHOD *biom,
int (*bwrite) (BIO *, const char *, int))
{
+ biom->bwrite_old = bwrite;
+ biom->bwrite = bwrite_conv;
+ return 1;
+}
+
+int BIO_meth_set_write_ex(BIO_METHOD *biom,
+ int (*bwrite) (BIO *, const char *, size_t, size_t *))
+{
+ biom->bwrite_old = NULL;
biom->bwrite = bwrite;
return 1;
}
int (*BIO_meth_get_read(const BIO_METHOD *biom)) (BIO *, char *, int)
{
+ return biom->bread_old;
+}
+
+int (*BIO_meth_get_read_ex(const BIO_METHOD *biom)) (BIO *, char *, size_t, size_t *)
+{
return biom->bread;
}
+/* Conversion for old style bread to new style */
+int bread_conv(BIO *bio, char *data, size_t datal, size_t *readbytes)
+{
+ int ret;
+
+ if (datal > INT_MAX)
+ datal = INT_MAX;
+
+ ret = bio->method->bread_old(bio, data, (int)datal);
+
+ if (ret <= 0) {
+ *readbytes = 0;
+ return ret;
+ }
+
+ *readbytes = (size_t)ret;
+
+ return 1;
+}
+
int BIO_meth_set_read(BIO_METHOD *biom,
int (*bread) (BIO *, char *, int))
{
+ biom->bread_old = bread;
+ biom->bread = bread_conv;
+ return 1;
+}
+
+int BIO_meth_set_read_ex(BIO_METHOD *biom,
+ int (*bread) (BIO *, char *, size_t, size_t *))
+{
+ biom->bread_old = NULL;
biom->bread = bread;
return 1;
}
diff --git a/deps/openssl/openssl/crypto/bio/bss_acpt.c b/deps/openssl/openssl/crypto/bio/bss_acpt.c
index 21d21c16a9..993e5903a0 100644
--- a/deps/openssl/openssl/crypto/bio/bss_acpt.c
+++ b/deps/openssl/openssl/crypto/bio/bss_acpt.c
@@ -54,7 +54,11 @@ static void BIO_ACCEPT_free(BIO_ACCEPT *a);
static const BIO_METHOD methods_acceptp = {
BIO_TYPE_ACCEPT,
"socket accept",
+ /* TODO: Convert to new style write function */
+ bwrite_conv,
acpt_write,
+ /* TODO: Convert to new style read function */
+ bread_conv,
acpt_read,
acpt_puts,
NULL, /* connect_gets, */
@@ -66,7 +70,7 @@ static const BIO_METHOD methods_acceptp = {
const BIO_METHOD *BIO_s_accept(void)
{
- return (&methods_acceptp);
+ return &methods_acceptp;
}
static int acpt_new(BIO *bi)
@@ -77,29 +81,30 @@ static int acpt_new(BIO *bi)
bi->num = (int)INVALID_SOCKET;
bi->flags = 0;
if ((ba = BIO_ACCEPT_new()) == NULL)
- return (0);
+ return 0;
bi->ptr = (char *)ba;
ba->state = ACPT_S_BEFORE;
bi->shutdown = 1;
- return (1);
+ return 1;
}
static BIO_ACCEPT *BIO_ACCEPT_new(void)
{
BIO_ACCEPT *ret;
- if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL)
- return (NULL);
+ if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL) {
+ BIOerr(BIO_F_BIO_ACCEPT_NEW, ERR_R_MALLOC_FAILURE);
+ return NULL;
+ }
ret->accept_family = BIO_FAMILY_IPANY;
ret->accept_sock = (int)INVALID_SOCKET;
- return (ret);
+ return ret;
}
static void BIO_ACCEPT_free(BIO_ACCEPT *a)
{
if (a == NULL)
return;
-
OPENSSL_free(a->param_addr);
OPENSSL_free(a->param_serv);
BIO_ADDRINFO_free(a->addr_first);
@@ -129,7 +134,7 @@ static int acpt_free(BIO *a)
BIO_ACCEPT *data;
if (a == NULL)
- return (0);
+ return 0;
data = (BIO_ACCEPT *)a->ptr;
if (a->shutdown) {
@@ -139,7 +144,7 @@ static int acpt_free(BIO *a)
a->flags = 0;
a->init = 0;
}
- return (1);
+ return 1;
}
static int acpt_state(BIO *b, BIO_ACCEPT *c)
@@ -360,12 +365,12 @@ static int acpt_read(BIO *b, char *out, int outl)
while (b->next_bio == NULL) {
ret = acpt_state(b, data);
if (ret <= 0)
- return (ret);
+ return ret;
}
ret = BIO_read(b->next_bio, out, outl);
BIO_copy_next_retry(b);
- return (ret);
+ return ret;
}
static int acpt_write(BIO *b, const char *in, int inl)
@@ -379,12 +384,12 @@ static int acpt_write(BIO *b, const char *in, int inl)
while (b->next_bio == NULL) {
ret = acpt_state(b, data);
if (ret <= 0)
- return (ret);
+ return ret;
}
ret = BIO_write(b->next_bio, in, inl);
BIO_copy_next_retry(b);
- return (ret);
+ return ret;
}
static long acpt_ctrl(BIO *b, int cmd, long num, void *ptr)
@@ -451,7 +456,6 @@ static long acpt_ctrl(BIO *b, int cmd, long num, void *ptr)
data->accepted_mode &= ~BIO_SOCK_NONBLOCK;
break;
case BIO_C_SET_FD:
- b->init = 1;
b->num = *((int *)ptr);
data->accept_sock = b->num;
data->state = ACPT_S_ACCEPT;
@@ -522,19 +526,13 @@ static long acpt_ctrl(BIO *b, int cmd, long num, void *ptr)
ret = (long)data->bind_mode;
break;
case BIO_CTRL_DUP:
-/*- dbio=(BIO *)ptr;
- if (data->param_port) EAY EAY
- BIO_set_port(dbio,data->param_port);
- if (data->param_hostname)
- BIO_set_hostname(dbio,data->param_hostname);
- BIO_set_nbio(dbio,data->nbio); */
break;
default:
ret = 0;
break;
}
- return (ret);
+ return ret;
}
static int acpt_puts(BIO *bp, const char *str)
@@ -543,7 +541,7 @@ static int acpt_puts(BIO *bp, const char *str)
n = strlen(str);
ret = acpt_write(bp, str, n);
- return (ret);
+ return ret;
}
BIO *BIO_new_accept(const char *str)
@@ -552,11 +550,11 @@ BIO *BIO_new_accept(const char *str)
ret = BIO_new(BIO_s_accept());
if (ret == NULL)
- return (NULL);
+ return NULL;
if (BIO_set_accept_name(ret, str))
- return (ret);
+ return ret;
BIO_free(ret);
- return (NULL);
+ return NULL;
}
#endif
diff --git a/deps/openssl/openssl/crypto/bio/bss_bio.c b/deps/openssl/openssl/crypto/bio/bss_bio.c
index de34f6bf37..e34382c557 100644
--- a/deps/openssl/openssl/crypto/bio/bss_bio.c
+++ b/deps/openssl/openssl/crypto/bio/bss_bio.c
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1999-2017 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
@@ -15,6 +15,7 @@
* See ssl/ssltest.c for some hints on how this can be used.
*/
+#include "e_os.h"
#include <assert.h>
#include <limits.h>
#include <stdlib.h>
@@ -24,8 +25,6 @@
#include <openssl/err.h>
#include <openssl/crypto.h>
-#include "e_os.h"
-
static int bio_new(BIO *bio);
static int bio_free(BIO *bio);
static int bio_read(BIO *bio, char *buf, int size);
@@ -39,7 +38,11 @@ static void bio_destroy_pair(BIO *bio);
static const BIO_METHOD methods_biop = {
BIO_TYPE_BIO,
"BIO pair",
+ /* TODO: Convert to new style write function */
+ bwrite_conv,
bio_write,
+ /* TODO: Convert to new style read function */
+ bread_conv,
bio_read,
bio_puts,
NULL /* no bio_gets */ ,
diff --git a/deps/openssl/openssl/crypto/bio/bss_conn.c b/deps/openssl/openssl/crypto/bio/bss_conn.c
index e343bcddfa..e9673fe783 100644
--- a/deps/openssl/openssl/crypto/bio/bss_conn.c
+++ b/deps/openssl/openssl/crypto/bio/bss_conn.c
@@ -1,5 +1,5 @@
/*
- * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
@@ -58,7 +58,11 @@ void BIO_CONNECT_free(BIO_CONNECT *a);
static const BIO_METHOD methods_connectp = {
BIO_TYPE_CONNECT,
"socket connect",
+ /* TODO: Convert to new style write function */
+ bwrite_conv,
conn_write,
+ /* TODO: Convert to new style read function */
+ bread_conv,
conn_read,
conn_puts,
NULL, /* conn_gets, */
@@ -212,25 +216,26 @@ static int conn_state(BIO *b, BIO_CONNECT *c)
if (cb != NULL)
ret = cb((BIO *)b, c->state, ret);
end:
- return (ret);
+ return ret;
}
BIO_CONNECT *BIO_CONNECT_new(void)
{
BIO_CONNECT *ret;
- if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL)
- return (NULL);
+ if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL) {
+ BIOerr(BIO_F_BIO_CONNECT_NEW, ERR_R_MALLOC_FAILURE);
+ return NULL;
+ }
ret->state = BIO_CONN_S_BEFORE;
ret->connect_family = BIO_FAMILY_IPANY;
- return (ret);
+ return ret;
}
void BIO_CONNECT_free(BIO_CONNECT *a)
{
if (a == NULL)
return;
-
OPENSSL_free(a->param_hostname);
OPENSSL_free(a->param_service);
BIO_ADDRINFO_free(a->addr_first);
@@ -239,7 +244,7 @@ void BIO_CONNECT_free(BIO_CONNECT *a)
const BIO_METHOD *BIO_s_connect(void)
{
- return (&methods_connectp);
+ return &methods_connectp;
}
static int conn_new(BIO *bi)
@@ -248,9 +253,9 @@ static int conn_new(BIO *bi)
bi->num = (int)INVALID_SOCKET;
bi->flags = 0;
if ((bi->ptr = (char *)BIO_CONNECT_new()) == NULL)
- return (0);
+ return 0;
else
- return (1);
+ return 1;
}
static void conn_close_socket(BIO *bio)
@@ -272,7 +277,7 @@ static int conn_free(BIO *a)
BIO_CONNECT *data;
if (a == NULL)
- return (0);
+ return 0;
data = (BIO_CONNECT *)a->ptr;
if (a->shutdown) {
@@ -282,7 +287,7 @@ static int conn_free(BIO *a)
a->flags = 0;
a->init = 0;
}
- return (1);
+ return 1;
}
static int conn_read(BIO *b, char *out, int outl)
@@ -294,7 +299,7 @@ static int conn_read(BIO *b, char *out, int outl)
if (data->state != BIO_CONN_S_OK) {
ret = conn_state(b, data);
if (ret <= 0)
- return (ret);
+ return ret;
}
if (out != NULL) {
@@ -306,7 +311,7 @@ static int conn_read(BIO *b, char *out, int outl)
BIO_set_retry_read(b);
}
}
- return (ret);
+ return ret;
}
static int conn_write(BIO *b, const char *in, int inl)
@@ -318,7 +323,7 @@ static int conn_write(BIO *b, const char *in, int inl)
if (data->state != BIO_CONN_S_OK) {
ret = conn_state(b, data);
if (ret <= 0)
- return (ret);
+ return ret;
}
clear_socket_error();
@@ -328,7 +333,7 @@ static int conn_write(BIO *b, const char *in, int inl)
if (BIO_sock_should_retry(ret))
BIO_set_retry_write(b);
}
- return (ret);
+ return ret;
}
static long conn_ctrl(BIO *b, int cmd, long num, void *ptr)
@@ -473,15 +478,7 @@ static long conn_ctrl(BIO *b, int cmd, long num, void *ptr)
}
break;
case BIO_CTRL_SET_CALLBACK:
- {
-# 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
- }
+ ret = 0; /* use callback ctrl */
break;
case BIO_CTRL_GET_CALLBACK:
{
@@ -495,7 +492,7 @@ static long conn_ctrl(BIO *b, int cmd, long num, void *ptr)
ret = 0;
break;
}
- return (ret);
+ return ret;
}
static long conn_callback_ctrl(BIO *b, int cmd, BIO_info_cb *fp)
@@ -515,7 +512,7 @@ static long conn_callback_ctrl(BIO *b, int cmd, BIO_info_cb *fp)
ret = 0;
break;
}
- return (ret);
+ return ret;
}
static int conn_puts(BIO *bp, const char *str)
@@ -524,7 +521,7 @@ static int conn_puts(BIO *bp, const char *str)
n = strlen(str);
ret = conn_write(bp, str, n);
- return (ret);
+ return ret;
}
BIO *BIO_new_connect(const char *str)
@@ -533,11 +530,11 @@ BIO *BIO_new_connect(const char *str)
ret = BIO_new(BIO_s_connect());
if (ret == NULL)
- return (NULL);
+ return NULL;
if (BIO_set_conn_hostname(ret, str))
- return (ret);
+ return ret;
BIO_free(ret);
- return (NULL);
+ return NULL;
}
#endif
diff --git a/deps/openssl/openssl/crypto/bio/bss_dgram.c b/deps/openssl/openssl/crypto/bio/bss_dgram.c
index c772d956b8..d5fe5bb5a8 100644
--- a/deps/openssl/openssl/crypto/bio/bss_dgram.c
+++ b/deps/openssl/openssl/crypto/bio/bss_dgram.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2016 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2005-2018 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
@@ -13,13 +13,6 @@
#include "bio_lcl.h"
#ifndef OPENSSL_NO_DGRAM
-# if !(defined(_WIN32) || defined(OPENSSL_SYS_VMS))
-# include <sys/time.h>
-# endif
-# if defined(OPENSSL_SYS_VMS)
-# include <sys/timeb.h>
-# endif
-
# ifndef OPENSSL_NO_SCTP
# include <netinet/sctp.h>
# include <fcntl.h>
@@ -73,7 +66,11 @@ static void get_current_time(struct timeval *t);
static const BIO_METHOD methods_dgramp = {
BIO_TYPE_DGRAM,
"datagram socket",
+ /* TODO: Convert to new style write function */
+ bwrite_conv,
dgram_write,
+ /* TODO: Convert to new style read function */
+ bread_conv,
dgram_read,
dgram_puts,
NULL, /* dgram_gets, */
@@ -87,7 +84,11 @@ static const BIO_METHOD methods_dgramp = {
static const BIO_METHOD methods_dgramp_sctp = {
BIO_TYPE_DGRAM_SCTP,
"datagram sctp socket",
+ /* TODO: Convert to new style write function */
+ bwrite_conv,
dgram_sctp_write,
+ /* TODO: Convert to new style write function */
+ bread_conv,
dgram_sctp_read,
dgram_sctp_puts,
NULL, /* dgram_gets, */
@@ -135,7 +136,7 @@ typedef struct bio_dgram_sctp_data_st {
const BIO_METHOD *BIO_s_datagram(void)
{
- return (&methods_dgramp);
+ return &methods_dgramp;
}
BIO *BIO_new_dgram(int fd, int close_flag)
@@ -144,9 +145,9 @@ BIO *BIO_new_dgram(int fd, int close_flag)
ret = BIO_new(BIO_s_datagram());
if (ret == NULL)
- return (NULL);
+ return NULL;
BIO_set_fd(ret, fd, close_flag);
- return (ret);
+ return ret;
}
static int dgram_new(BIO *bi)
@@ -156,7 +157,7 @@ static int dgram_new(BIO *bi)
if (data == NULL)
return 0;
bi->ptr = data;
- return (1);
+ return 1;
}
static int dgram_free(BIO *a)
@@ -164,20 +165,20 @@ static int dgram_free(BIO *a)
bio_dgram_data *data;
if (a == NULL)
- return (0);
+ return 0;
if (!dgram_clear(a))
return 0;
data = (bio_dgram_data *)a->ptr;
OPENSSL_free(data);
- return (1);
+ return 1;
}
static int dgram_clear(BIO *a)
{
if (a == NULL)
- return (0);
+ return 0;
if (a->shutdown) {
if (a->init) {
BIO_closesocket(a->num);
@@ -185,7 +186,7 @@ static int dgram_clear(BIO *a)
a->init = 0;
a->flags = 0;
}
- return (1);
+ return 1;
}
static void dgram_adjust_rcv_timeout(BIO *b)
@@ -324,7 +325,7 @@ static int dgram_read(BIO *b, char *out, int outl)
dgram_reset_rcv_timeout(b);
}
- return (ret);
+ return ret;
}
static int dgram_write(BIO *b, const char *in, int inl)
@@ -338,13 +339,8 @@ static int dgram_write(BIO *b, const char *in, int inl)
else {
int peerlen = BIO_ADDR_sockaddr_size(&data->peer);
-# if defined(NETWARE_CLIB) && defined(NETWARE_BSDSOCK)
- ret = sendto(b->num, (char *)in, inl, 0,
- BIO_ADDR_sockaddr(&data->peer), peerlen);
-# else
ret = sendto(b->num, in, inl, 0,
BIO_ADDR_sockaddr(&data->peer), peerlen);
-# endif
}
BIO_clear_retry_flags(b);
@@ -354,7 +350,7 @@ static int dgram_write(BIO *b, const char *in, int inl)
data->_errno = get_last_socket_error();
}
}
- return (ret);
+ return ret;
}
static long dgram_get_mtu_overhead(bio_dgram_data *data)
@@ -368,7 +364,7 @@ static long dgram_get_mtu_overhead(bio_dgram_data *data)
*/
ret = 28;
break;
-# ifdef AF_INET6
+# if OPENSSL_USE_IPV6
case AF_INET6:
{
# ifdef IN6_IS_ADDR_V4MAPPED
@@ -798,7 +794,7 @@ static long dgram_ctrl(BIO *b, int cmd, long num, void *ptr)
ret = 0;
break;
}
- return (ret);
+ return ret;
}
static int dgram_puts(BIO *bp, const char *str)
@@ -807,13 +803,13 @@ static int dgram_puts(BIO *bp, const char *str)
n = strlen(str);
ret = dgram_write(bp, str, n);
- return (ret);
+ return ret;
}
# ifndef OPENSSL_NO_SCTP
const BIO_METHOD *BIO_s_datagram_sctp(void)
{
- return (&methods_dgramp_sctp);
+ return &methods_dgramp_sctp;
}
BIO *BIO_new_dgram_sctp(int fd, int close_flag)
@@ -835,7 +831,7 @@ BIO *BIO_new_dgram_sctp(int fd, int close_flag)
bio = BIO_new(BIO_s_datagram_sctp());
if (bio == NULL)
- return (NULL);
+ return NULL;
BIO_set_fd(bio, fd, close_flag);
/* Activate SCTP-AUTH for DATA and FORWARD-TSN chunks */
@@ -845,7 +841,9 @@ BIO *BIO_new_dgram_sctp(int fd, int close_flag)
sizeof(struct sctp_authchunk));
if (ret < 0) {
BIO_vfree(bio);
- return (NULL);
+ BIOerr(BIO_F_BIO_NEW_DGRAM_SCTP, ERR_R_SYS_LIB);
+ ERR_add_error_data(1, "Ensure SCTP AUTH chunks are enabled in kernel");
+ return NULL;
}
auth.sauth_chunk = OPENSSL_SCTP_FORWARD_CUM_TSN_CHUNK_TYPE;
ret =
@@ -853,26 +851,29 @@ BIO *BIO_new_dgram_sctp(int fd, int close_flag)
sizeof(struct sctp_authchunk));
if (ret < 0) {
BIO_vfree(bio);
- return (NULL);
+ BIOerr(BIO_F_BIO_NEW_DGRAM_SCTP, ERR_R_SYS_LIB);
+ ERR_add_error_data(1, "Ensure SCTP AUTH chunks are enabled in kernel");
+ return NULL;
}
/*
* Test if activation was successful. When using accept(), SCTP-AUTH has
* to be activated for the listening socket already, otherwise the
- * connected socket won't use it.
+ * connected socket won't use it. Similarly with connect(): the socket
+ * prior to connection must be activated for SCTP-AUTH
*/
sockopt_len = (socklen_t) (sizeof(sctp_assoc_t) + 256 * sizeof(uint8_t));
authchunks = OPENSSL_zalloc(sockopt_len);
if (authchunks == NULL) {
BIO_vfree(bio);
- return (NULL);
+ return NULL;
}
ret = getsockopt(fd, IPPROTO_SCTP, SCTP_LOCAL_AUTH_CHUNKS, authchunks,
&sockopt_len);
if (ret < 0) {
OPENSSL_free(authchunks);
BIO_vfree(bio);
- return (NULL);
+ return NULL;
}
for (p = (unsigned char *)authchunks->gauth_chunks;
@@ -886,8 +887,14 @@ BIO *BIO_new_dgram_sctp(int fd, int close_flag)
OPENSSL_free(authchunks);
- OPENSSL_assert(auth_data);
- OPENSSL_assert(auth_forward);
+ if (!auth_data || !auth_forward) {
+ BIO_vfree(bio);
+ BIOerr(BIO_F_BIO_NEW_DGRAM_SCTP, ERR_R_SYS_LIB);
+ ERR_add_error_data(1,
+ "Ensure SCTP AUTH chunks are enabled on the "
+ "underlying socket");
+ return NULL;
+ }
# ifdef SCTP_AUTHENTICATION_EVENT
# ifdef SCTP_EVENT
@@ -900,14 +907,14 @@ BIO *BIO_new_dgram_sctp(int fd, int close_flag)
sizeof(struct sctp_event));
if (ret < 0) {
BIO_vfree(bio);
- return (NULL);
+ return NULL;
}
# else
sockopt_len = (socklen_t) sizeof(struct sctp_event_subscribe);
ret = getsockopt(fd, IPPROTO_SCTP, SCTP_EVENTS, &event, &sockopt_len);
if (ret < 0) {
BIO_vfree(bio);
- return (NULL);
+ return NULL;
}
event.sctp_authentication_event = 1;
@@ -917,7 +924,7 @@ BIO *BIO_new_dgram_sctp(int fd, int close_flag)
sizeof(struct sctp_event_subscribe));
if (ret < 0) {
BIO_vfree(bio);
- return (NULL);
+ return NULL;
}
# endif
# endif
@@ -931,10 +938,10 @@ BIO *BIO_new_dgram_sctp(int fd, int close_flag)
sizeof(optval));
if (ret < 0) {
BIO_vfree(bio);
- return (NULL);
+ return NULL;
}
- return (bio);
+ return bio;
}
int BIO_dgram_is_sctp(BIO *bio)
@@ -948,16 +955,17 @@ static int dgram_sctp_new(BIO *bi)
bi->init = 0;
bi->num = 0;
- data = OPENSSL_zalloc(sizeof(*data));
- if (data == NULL)
+ if ((data = OPENSSL_zalloc(sizeof(*data))) == NULL) {
+ BIOerr(BIO_F_DGRAM_SCTP_NEW, ERR_R_MALLOC_FAILURE);
return 0;
+ }
# ifdef SCTP_PR_SCTP_NONE
data->prinfo.pr_policy = SCTP_PR_SCTP_NONE;
# endif
bi->ptr = data;
bi->flags = 0;
- return (1);
+ return 1;
}
static int dgram_sctp_free(BIO *a)
@@ -965,7 +973,7 @@ static int dgram_sctp_free(BIO *a)
bio_dgram_sctp_data *data;
if (a == NULL)
- return (0);
+ return 0;
if (!dgram_clear(a))
return 0;
@@ -973,7 +981,7 @@ static int dgram_sctp_free(BIO *a)
if (data != NULL)
OPENSSL_free(data);
- return (1);
+ return 1;
}
# ifdef SCTP_AUTHENTICATION_EVENT
@@ -1210,7 +1218,7 @@ static int dgram_sctp_read(BIO *b, char *out, int outl)
data->peer_auth_tested = 1;
}
}
- return (ret);
+ return ret;
}
/*
@@ -1326,7 +1334,7 @@ static int dgram_sctp_write(BIO *b, const char *in, int inl)
data->_errno = get_last_socket_error();
}
}
- return (ret);
+ return ret;
}
static long dgram_sctp_ctrl(BIO *b, int cmd, long num, void *ptr)
@@ -1562,7 +1570,7 @@ static long dgram_sctp_ctrl(BIO *b, int cmd, long num, void *ptr)
ret = dgram_ctrl(b, cmd, num, ptr);
break;
}
- return (ret);
+ return ret;
}
int BIO_dgram_sctp_notification_cb(BIO *b,
@@ -1819,7 +1827,7 @@ static int dgram_sctp_puts(BIO *bp, const char *str)
n = strlen(str);
ret = dgram_sctp_write(bp, str, n);
- return (ret);
+ return ret;
}
# endif
@@ -1838,9 +1846,9 @@ static int BIO_dgram_should_retry(int i)
*/
# endif
- return (BIO_dgram_non_fatal_error(err));
+ return BIO_dgram_non_fatal_error(err);
}
- return (0);
+ return 0;
}
int BIO_dgram_non_fatal_error(int err)
@@ -1884,12 +1892,11 @@ int BIO_dgram_non_fatal_error(int err)
case EALREADY:
# endif
- return (1);
- /* break; */
+ return 1;
default:
break;
}
- return (0);
+ return 0;
}
static void get_current_time(struct timeval *t)
@@ -1910,11 +1917,6 @@ static void get_current_time(struct timeval *t)
# endif
t->tv_sec = (long)(now.ul / 10000000);
t->tv_usec = ((int)(now.ul % 10000000)) / 10;
-# elif defined(OPENSSL_SYS_VMS)
- struct timeb tb;
- ftime(&tb);
- t->tv_sec = (long)tb.time;
- t->tv_usec = (long)tb.millitm * 1000;
# else
gettimeofday(t, NULL);
# endif
diff --git a/deps/openssl/openssl/crypto/bio/bss_fd.c b/deps/openssl/openssl/crypto/bio/bss_fd.c
index 2bd3517dfd..5bc539c90b 100644
--- a/deps/openssl/openssl/crypto/bio/bss_fd.c
+++ b/deps/openssl/openssl/crypto/bio/bss_fd.c
@@ -60,7 +60,11 @@ int BIO_fd_should_retry(int s);
static const BIO_METHOD methods_fdp = {
BIO_TYPE_FD,
"file descriptor",
+ /* TODO: Convert to new style write function */
+ bwrite_conv,
fd_write,
+ /* TODO: Convert to new style read function */
+ bread_conv,
fd_read,
fd_puts,
fd_gets,
@@ -72,7 +76,7 @@ static const BIO_METHOD methods_fdp = {
const BIO_METHOD *BIO_s_fd(void)
{
- return (&methods_fdp);
+ return &methods_fdp;
}
BIO *BIO_new_fd(int fd, int close_flag)
@@ -80,9 +84,9 @@ BIO *BIO_new_fd(int fd, int close_flag)
BIO *ret;
ret = BIO_new(BIO_s_fd());
if (ret == NULL)
- return (NULL);
+ return NULL;
BIO_set_fd(ret, fd, close_flag);
- return (ret);
+ return ret;
}
static int fd_new(BIO *bi)
@@ -91,13 +95,13 @@ static int fd_new(BIO *bi)
bi->num = -1;
bi->ptr = NULL;
bi->flags = BIO_FLAGS_UPLINK; /* essentially redundant */
- return (1);
+ return 1;
}
static int fd_free(BIO *a)
{
if (a == NULL)
- return (0);
+ return 0;
if (a->shutdown) {
if (a->init) {
UP_close(a->num);
@@ -105,7 +109,7 @@ static int fd_free(BIO *a)
a->init = 0;
a->flags = BIO_FLAGS_UPLINK;
}
- return (1);
+ return 1;
}
static int fd_read(BIO *b, char *out, int outl)
@@ -121,7 +125,7 @@ static int fd_read(BIO *b, char *out, int outl)
BIO_set_retry_read(b);
}
}
- return (ret);
+ return ret;
}
static int fd_write(BIO *b, const char *in, int inl)
@@ -134,7 +138,7 @@ static int fd_write(BIO *b, const char *in, int inl)
if (BIO_fd_should_retry(ret))
BIO_set_retry_write(b);
}
- return (ret);
+ return ret;
}
static long fd_ctrl(BIO *b, int cmd, long num, void *ptr)
@@ -186,7 +190,7 @@ static long fd_ctrl(BIO *b, int cmd, long num, void *ptr)
ret = 0;
break;
}
- return (ret);
+ return ret;
}
static int fd_puts(BIO *bp, const char *str)
@@ -195,7 +199,7 @@ static int fd_puts(BIO *bp, const char *str)
n = strlen(str);
ret = fd_write(bp, str, n);
- return (ret);
+ return ret;
}
static int fd_gets(BIO *bp, char *buf, int size)
@@ -204,14 +208,16 @@ static int fd_gets(BIO *bp, char *buf, int size)
char *ptr = buf;
char *end = buf + size - 1;
- while ((ptr < end) && (fd_read(bp, ptr, 1) > 0) && (ptr[0] != '\n'))
- ptr++;
+ while (ptr < end && fd_read(bp, ptr, 1) > 0) {
+ if (*ptr++ == '\n')
+ break;
+ }
ptr[0] = '\0';
if (buf[0] != '\0')
ret = strlen(buf);
- return (ret);
+ return ret;
}
int BIO_fd_should_retry(int i)
@@ -221,9 +227,9 @@ int BIO_fd_should_retry(int i)
if ((i == 0) || (i == -1)) {
err = get_last_sys_error();
- return (BIO_fd_non_fatal_error(err));
+ return BIO_fd_non_fatal_error(err);
}
- return (0);
+ return 0;
}
int BIO_fd_non_fatal_error(int err)
@@ -265,11 +271,10 @@ int BIO_fd_non_fatal_error(int err)
# ifdef EALREADY
case EALREADY:
# endif
- return (1);
- /* break; */
+ return 1;
default:
break;
}
- return (0);
+ return 0;
}
#endif
diff --git a/deps/openssl/openssl/crypto/bio/bss_file.c b/deps/openssl/openssl/crypto/bio/bss_file.c
index 2edf244835..8de2391267 100644
--- a/deps/openssl/openssl/crypto/bio/bss_file.c
+++ b/deps/openssl/openssl/crypto/bio/bss_file.c
@@ -1,5 +1,5 @@
/*
- * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
@@ -7,12 +7,6 @@
* https://www.openssl.org/source/license.html
*/
-/*-
- * 03-Dec-1997 rdenny@dc3.com Fix bug preventing use of stdin/stdout
- * with binary data (e.g. asn1parse -inform DER < xxx) under
- * Windows
- */
-
#ifndef HEADER_BSS_FILE_C
# define HEADER_BSS_FILE_C
@@ -51,7 +45,11 @@ static int file_free(BIO *data);
static const BIO_METHOD methods_filep = {
BIO_TYPE_FILE,
"FILE pointer",
+ /* TODO: Convert to new style write function */
+ bwrite_conv,
file_write,
+ /* TODO: Convert to new style read function */
+ bread_conv,
file_read,
file_puts,
file_gets,
@@ -81,17 +79,17 @@ BIO *BIO_new_file(const char *filename, const char *mode)
BIOerr(BIO_F_BIO_NEW_FILE, BIO_R_NO_SUCH_FILE);
else
BIOerr(BIO_F_BIO_NEW_FILE, ERR_R_SYS_LIB);
- return (NULL);
+ return NULL;
}
if ((ret = BIO_new(BIO_s_file())) == NULL) {
fclose(file);
- return (NULL);
+ return NULL;
}
BIO_clear_flags(ret, BIO_FLAGS_UPLINK); /* we did fopen -> we disengage
* UPLINK */
BIO_set_fp(ret, file, fp_flags);
- return (ret);
+ return ret;
}
BIO *BIO_new_fp(FILE *stream, int close_flag)
@@ -99,17 +97,17 @@ BIO *BIO_new_fp(FILE *stream, int close_flag)
BIO *ret;
if ((ret = BIO_new(BIO_s_file())) == NULL)
- return (NULL);
+ return NULL;
/* redundant flag, left for documentation purposes */
BIO_set_flags(ret, BIO_FLAGS_UPLINK);
BIO_set_fp(ret, stream, close_flag);
- return (ret);
+ return ret;
}
const BIO_METHOD *BIO_s_file(void)
{
- return (&methods_filep);
+ return &methods_filep;
}
static int file_new(BIO *bi)
@@ -118,13 +116,13 @@ static int file_new(BIO *bi)
bi->num = 0;
bi->ptr = NULL;
bi->flags = BIO_FLAGS_UPLINK; /* default to UPLINK */
- return (1);
+ return 1;
}
static int file_free(BIO *a)
{
if (a == NULL)
- return (0);
+ return 0;
if (a->shutdown) {
if ((a->init) && (a->ptr != NULL)) {
if (a->flags & BIO_FLAGS_UPLINK)
@@ -136,7 +134,7 @@ static int file_free(BIO *a)
}
a->init = 0;
}
- return (1);
+ return 1;
}
static int file_read(BIO *b, char *out, int outl)
@@ -156,7 +154,7 @@ static int file_read(BIO *b, char *out, int outl)
ret = -1;
}
}
- return (ret);
+ return ret;
}
static int file_write(BIO *b, const char *in, int inl)
@@ -172,12 +170,12 @@ static int file_write(BIO *b, const char *in, int inl)
ret = inl;
/* ret=fwrite(in,1,(int)inl,(FILE *)b->ptr); */
/*
- * according to Tim Hudson <tjh@cryptsoft.com>, the commented out
+ * according to Tim Hudson <tjh@openssl.org>, the commented out
* version above can cause 'inl' write calls under some stupid stdio
* implementations (VMS)
*/
}
- return (ret);
+ return ret;
}
static long file_ctrl(BIO *b, int cmd, long num, void *ptr)
@@ -283,9 +281,9 @@ static long file_ctrl(BIO *b, int cmd, long num, void *ptr)
}
# if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32_CYGWIN)
if (!(num & BIO_FP_TEXT))
- strcat(p, "b");
+ OPENSSL_strlcat(p, "b", sizeof(p));
else
- strcat(p, "t");
+ OPENSSL_strlcat(p, "t", sizeof(p));
# endif
fp = openssl_fopen(ptr, p);
if (fp == NULL) {
@@ -335,7 +333,7 @@ static long file_ctrl(BIO *b, int cmd, long num, void *ptr)
ret = 0;
break;
}
- return (ret);
+ return ret;
}
static int file_gets(BIO *bp, char *buf, int size)
@@ -353,7 +351,7 @@ static int file_gets(BIO *bp, char *buf, int size)
if (buf[0] != '\0')
ret = strlen(buf);
err:
- return (ret);
+ return ret;
}
static int file_puts(BIO *bp, const char *str)
@@ -362,7 +360,7 @@ static int file_puts(BIO *bp, const char *str)
n = strlen(str);
ret = file_write(bp, str, n);
- return (ret);
+ return ret;
}
#else
@@ -399,7 +397,11 @@ static int file_free(BIO *a)
static const BIO_METHOD methods_filep = {
BIO_TYPE_FILE,
"FILE pointer",
+ /* TODO: Convert to new style write function */
+ bwrite_conv,
file_write,
+ /* TODO: Convert to new style read function */
+ bread_conv,
file_read,
file_puts,
file_gets,
@@ -411,7 +413,7 @@ static const BIO_METHOD methods_filep = {
const BIO_METHOD *BIO_s_file(void)
{
- return (&methods_filep);
+ return &methods_filep;
}
BIO *BIO_new_file(const char *filename, const char *mode)
diff --git a/deps/openssl/openssl/crypto/bio/bss_log.c b/deps/openssl/openssl/crypto/bio/bss_log.c
index f090e8214b..e9ab932ec2 100644
--- a/deps/openssl/openssl/crypto/bio/bss_log.c
+++ b/deps/openssl/openssl/crypto/bio/bss_log.c
@@ -39,7 +39,7 @@ void *_malloc32(__size_t);
# endif /* __INITIAL_POINTER_SIZE == 64 */
# endif /* __INITIAL_POINTER_SIZE && defined
* _ANSI_C_SOURCE */
-#elif defined(OPENSSL_SYS_NETWARE)
+#elif defined(__DJGPP__) && defined(OPENSSL_NO_SOCK)
# define NO_SYSLOG
#elif (!defined(MSDOS) || defined(WATT32)) && !defined(OPENSSL_SYS_VXWORKS) && !defined(NO_SYSLOG)
# include <syslog.h>
@@ -87,10 +87,13 @@ static void xcloselog(BIO *bp);
static const BIO_METHOD methods_slg = {
BIO_TYPE_MEM,
"syslog",
+ /* TODO: Convert to new style write function */
+ bwrite_conv,
slg_write,
+ NULL, /* slg_write_old, */
NULL, /* slg_read, */
slg_puts,
- NULL, /* slg_gets, */
+ NULL,
slg_ctrl,
slg_new,
slg_free,
@@ -99,7 +102,7 @@ static const BIO_METHOD methods_slg = {
const BIO_METHOD *BIO_s_log(void)
{
- return (&methods_slg);
+ return &methods_slg;
}
static int slg_new(BIO *bi)
@@ -108,15 +111,15 @@ static int slg_new(BIO *bi)
bi->num = 0;
bi->ptr = NULL;
xopenlog(bi, "application", LOG_DAEMON);
- return (1);
+ return 1;
}
static int slg_free(BIO *a)
{
if (a == NULL)
- return (0);
+ return 0;
xcloselog(a);
- return (1);
+ return 1;
}
static int slg_write(BIO *b, const char *in, int inl)
@@ -194,7 +197,8 @@ static int slg_write(BIO *b, const char *in, int inl)
};
if ((buf = OPENSSL_malloc(inl + 1)) == NULL) {
- return (0);
+ BIOerr(BIO_F_SLG_WRITE, ERR_R_MALLOC_FAILURE);
+ return 0;
}
memcpy(buf, in, inl);
buf[inl] = '\0';
@@ -208,7 +212,7 @@ static int slg_write(BIO *b, const char *in, int inl)
xsyslog(b, priority, pp);
OPENSSL_free(buf);
- return (ret);
+ return ret;
}
static long slg_ctrl(BIO *b, int cmd, long num, void *ptr)
@@ -221,7 +225,7 @@ static long slg_ctrl(BIO *b, int cmd, long num, void *ptr)
default:
break;
}
- return (0);
+ return 0;
}
static int slg_puts(BIO *bp, const char *str)
@@ -230,7 +234,7 @@ static int slg_puts(BIO *bp, const char *str)
n = strlen(str);
ret = slg_write(bp, str, n);
- return (ret);
+ return ret;
}
# if defined(OPENSSL_SYS_WIN32)
diff --git a/deps/openssl/openssl/crypto/bio/bss_mem.c b/deps/openssl/openssl/crypto/bio/bss_mem.c
index 4c0e4d7412..e0a97c3b43 100644
--- a/deps/openssl/openssl/crypto/bio/bss_mem.c
+++ b/deps/openssl/openssl/crypto/bio/bss_mem.c
@@ -26,7 +26,11 @@ static int mem_buf_sync(BIO *h);
static const BIO_METHOD mem_method = {
BIO_TYPE_MEM,
"memory buffer",
+ /* TODO: Convert to new style write function */
+ bwrite_conv,
mem_write,
+ /* TODO: Convert to new style read function */
+ bread_conv,
mem_read,
mem_puts,
mem_gets,
@@ -39,7 +43,11 @@ static const BIO_METHOD mem_method = {
static const BIO_METHOD secmem_method = {
BIO_TYPE_MEM,
"secure memory buffer",
+ /* TODO: Convert to new style write function */
+ bwrite_conv,
mem_write,
+ /* TODO: Convert to new style read function */
+ bread_conv,
mem_read,
mem_puts,
mem_gets,
@@ -62,7 +70,7 @@ typedef struct bio_buf_mem_st {
const BIO_METHOD *BIO_s_mem(void)
{
- return (&mem_method);
+ return &mem_method;
}
const BIO_METHOD *BIO_s_secmem(void)
@@ -122,42 +130,38 @@ static int mem_init(BIO *bi, unsigned long flags)
static int mem_new(BIO *bi)
{
- return (mem_init(bi, 0L));
+ return mem_init(bi, 0L);
}
static int secmem_new(BIO *bi)
{
- return (mem_init(bi, BUF_MEM_FLAG_SECURE));
+ return mem_init(bi, BUF_MEM_FLAG_SECURE);
}
static int mem_free(BIO *a)
{
- return (mem_buf_free(a, 1));
+ return mem_buf_free(a, 1);
}
static int mem_buf_free(BIO *a, int free_all)
{
if (a == NULL)
- return (0);
- if (a->shutdown) {
- if ((a->init) && (a->ptr != NULL)) {
- BUF_MEM *b;
- BIO_BUF_MEM *bb = (BIO_BUF_MEM *)a->ptr;
-
- if (bb != NULL) {
- b = bb->buf;
- if (a->flags & BIO_FLAGS_MEM_RDONLY)
- b->data = NULL;
- BUF_MEM_free(b);
- if (free_all) {
- OPENSSL_free(bb->readp);
- OPENSSL_free(bb);
- }
- }
- a->ptr = NULL;
+ return 0;
+
+ if (a->shutdown && a->init && a->ptr != NULL) {
+ BIO_BUF_MEM *bb = (BIO_BUF_MEM *)a->ptr;
+ BUF_MEM *b = bb->buf;
+
+ if (a->flags & BIO_FLAGS_MEM_RDONLY)
+ b->data = NULL;
+ BUF_MEM_free(b);
+ if (free_all) {
+ OPENSSL_free(bb->readp);
+ OPENSSL_free(bb);
}
+ a->ptr = NULL;
}
- return (1);
+ return 1;
}
/*
@@ -174,7 +178,7 @@ static int mem_buf_sync(BIO *b)
bbm->readp->data = bbm->buf->data;
}
}
- return (0);
+ return 0;
}
static int mem_read(BIO *b, char *out, int outl)
@@ -194,7 +198,7 @@ static int mem_read(BIO *b, char *out, int outl)
if (ret != 0)
BIO_set_retry_read(b);
}
- return (ret);
+ return ret;
}
static int mem_write(BIO *b, const char *in, int inl)
@@ -222,7 +226,7 @@ static int mem_write(BIO *b, const char *in, int inl)
*bbm->readp = *bbm->buf;
ret = inl;
end:
- return (ret);
+ return ret;
}
static long mem_ctrl(BIO *b, int cmd, long num, void *ptr)
@@ -299,7 +303,7 @@ static long mem_ctrl(BIO *b, int cmd, long num, void *ptr)
ret = 0;
break;
}
- return (ret);
+ return ret;
}
static int mem_gets(BIO *bp, char *buf, int size)
@@ -335,7 +339,7 @@ static int mem_gets(BIO *bp, char *buf, int size)
if (i > 0)
buf[i] = '\0';
ret = i;
- return (ret);
+ return ret;
}
static int mem_puts(BIO *bp, const char *str)
@@ -345,5 +349,5 @@ static int mem_puts(BIO *bp, const char *str)
n = strlen(str);
ret = mem_write(bp, str, n);
/* memory semantics is that it will always work */
- return (ret);
+ return ret;
}
diff --git a/deps/openssl/openssl/crypto/bio/bss_null.c b/deps/openssl/openssl/crypto/bio/bss_null.c
index 56f95f9fc2..08f1d2bc98 100644
--- a/deps/openssl/openssl/crypto/bio/bss_null.c
+++ b/deps/openssl/openssl/crypto/bio/bss_null.c
@@ -20,7 +20,11 @@ static long null_ctrl(BIO *h, int cmd, long arg1, void *arg2);
static const BIO_METHOD null_method = {
BIO_TYPE_NULL,
"NULL",
+ /* TODO: Convert to new style write function */
+ bwrite_conv,
null_write,
+ /* TODO: Convert to new style read function */
+ bread_conv,
null_read,
null_puts,
null_gets,
@@ -32,17 +36,17 @@ static const BIO_METHOD null_method = {
const BIO_METHOD *BIO_s_null(void)
{
- return (&null_method);
+ return &null_method;
}
static int null_read(BIO *b, char *out, int outl)
{
- return (0);
+ return 0;
}
static int null_write(BIO *b, const char *in, int inl)
{
- return (inl);
+ return inl;
}
static long null_ctrl(BIO *b, int cmd, long num, void *ptr)
@@ -67,17 +71,17 @@ static long null_ctrl(BIO *b, int cmd, long num, void *ptr)
ret = 0;
break;
}
- return (ret);
+ return ret;
}
static int null_gets(BIO *bp, char *buf, int size)
{
- return (0);
+ return 0;
}
static int null_puts(BIO *bp, const char *str)
{
if (str == NULL)
- return (0);
- return (strlen(str));
+ return 0;
+ return strlen(str);
}
diff --git a/deps/openssl/openssl/crypto/bio/bss_sock.c b/deps/openssl/openssl/crypto/bio/bss_sock.c
index 992266dc24..ad38453201 100644
--- a/deps/openssl/openssl/crypto/bio/bss_sock.c
+++ b/deps/openssl/openssl/crypto/bio/bss_sock.c
@@ -9,7 +9,6 @@
#include <stdio.h>
#include <errno.h>
-#define USE_SOCKETS
#include "bio_lcl.h"
#include "internal/cryptlib.h"
@@ -38,7 +37,11 @@ int BIO_sock_should_retry(int s);
static const BIO_METHOD methods_sockp = {
BIO_TYPE_SOCKET,
"socket",
+ /* TODO: Convert to new style write function */
+ bwrite_conv,
sock_write,
+ /* TODO: Convert to new style read function */
+ bread_conv,
sock_read,
sock_puts,
NULL, /* sock_gets, */
@@ -50,7 +53,7 @@ static const BIO_METHOD methods_sockp = {
const BIO_METHOD *BIO_s_socket(void)
{
- return (&methods_sockp);
+ return &methods_sockp;
}
BIO *BIO_new_socket(int fd, int close_flag)
@@ -59,9 +62,9 @@ BIO *BIO_new_socket(int fd, int close_flag)
ret = BIO_new(BIO_s_socket());
if (ret == NULL)
- return (NULL);
+ return NULL;
BIO_set_fd(ret, fd, close_flag);
- return (ret);
+ return ret;
}
static int sock_new(BIO *bi)
@@ -70,13 +73,13 @@ static int sock_new(BIO *bi)
bi->num = 0;
bi->ptr = NULL;
bi->flags = 0;
- return (1);
+ return 1;
}
static int sock_free(BIO *a)
{
if (a == NULL)
- return (0);
+ return 0;
if (a->shutdown) {
if (a->init) {
BIO_closesocket(a->num);
@@ -84,7 +87,7 @@ static int sock_free(BIO *a)
a->init = 0;
a->flags = 0;
}
- return (1);
+ return 1;
}
static int sock_read(BIO *b, char *out, int outl)
@@ -100,7 +103,7 @@ static int sock_read(BIO *b, char *out, int outl)
BIO_set_retry_read(b);
}
}
- return (ret);
+ return ret;
}
static int sock_write(BIO *b, const char *in, int inl)
@@ -114,7 +117,7 @@ static int sock_write(BIO *b, const char *in, int inl)
if (BIO_sock_should_retry(ret))
BIO_set_retry_write(b);
}
- return (ret);
+ return ret;
}
static long sock_ctrl(BIO *b, int cmd, long num, void *ptr)
@@ -152,7 +155,7 @@ static long sock_ctrl(BIO *b, int cmd, long num, void *ptr)
ret = 0;
break;
}
- return (ret);
+ return ret;
}
static int sock_puts(BIO *bp, const char *str)
@@ -161,7 +164,7 @@ static int sock_puts(BIO *bp, const char *str)
n = strlen(str);
ret = sock_write(bp, str, n);
- return (ret);
+ return ret;
}
int BIO_sock_should_retry(int i)
@@ -171,9 +174,9 @@ int BIO_sock_should_retry(int i)
if ((i == 0) || (i == -1)) {
err = get_last_socket_error();
- return (BIO_sock_non_fatal_error(err));
+ return BIO_sock_non_fatal_error(err);
}
- return (0);
+ return 0;
}
int BIO_sock_non_fatal_error(int err)
@@ -220,12 +223,11 @@ int BIO_sock_non_fatal_error(int err)
# ifdef EALREADY
case EALREADY:
# endif
- return (1);
- /* break; */
+ return 1;
default:
break;
}
- return (0);
+ return 0;
}
#endif /* #ifndef OPENSSL_NO_SOCK */