Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/boringssl.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Benjamin <davidben@chromium.org>2014-07-18 01:23:22 +0400
committerAdam Langley <agl@google.com>2014-07-18 04:56:04 +0400
commite77dff61bd47e2d7ed8072f7fba001681914a817 (patch)
treee798422b415ad917e629af675bd85fcd5bcd7ae9 /crypto/bio
parent13f2710c37291c40e6149f7f1d31384d2c9f25a0 (diff)
Preserve the address length in bio/connect.c.
On OS X, the length must be the length of the address and not of sockaddr_storage. Change-Id: Id962f2f3268f07327724b9867a83c15ec50cb9fd Reviewed-on: https://boringssl-review.googlesource.com/1251 Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'crypto/bio')
-rw-r--r--crypto/bio/connect.c6
-rw-r--r--crypto/bio/internal.h5
-rw-r--r--crypto/bio/socket_helper.c2
3 files changed, 9 insertions, 4 deletions
diff --git a/crypto/bio/connect.c b/crypto/bio/connect.c
index 3798a1ca..26c63541 100644
--- a/crypto/bio/connect.c
+++ b/crypto/bio/connect.c
@@ -91,6 +91,7 @@ typedef struct bio_connect_st {
unsigned short port;
struct sockaddr_storage them;
+ socklen_t them_length;
/* the file descriptor is kept in bio->num in order to match the socket
* BIO. */
@@ -162,7 +163,8 @@ static int conn_state(BIO *bio, BIO_CONNECT *c) {
}
if (!bio_ip_and_port_to_socket_and_addr(
- &bio->num, &c->them, c->param_hostname, c->param_port)) {
+ &bio->num, &c->them, &c->them_length, c->param_hostname,
+ c->param_port)) {
OPENSSL_PUT_ERROR(BIO, conn_state, BIO_R_UNABLE_TO_CREATE_SOCKET);
ERR_add_error_data(4, "host=", c->param_hostname, ":", c->param_port);
goto exit_loop;
@@ -191,7 +193,7 @@ static int conn_state(BIO *bio, BIO_CONNECT *c) {
}
BIO_clear_retry_flags(bio);
- ret = connect(bio->num, (struct sockaddr*) &c->them, sizeof(c->them));
+ ret = connect(bio->num, (struct sockaddr*) &c->them, c->them_length);
if (ret < 0) {
if (bio_fd_should_retry(ret)) {
BIO_set_flags(bio, (BIO_FLAGS_IO_SPECIAL | BIO_FLAGS_SHOULD_RETRY));
diff --git a/crypto/bio/internal.h b/crypto/bio/internal.h
index 2eb28754..b0c9c316 100644
--- a/crypto/bio/internal.h
+++ b/crypto/bio/internal.h
@@ -76,10 +76,11 @@ extern "C" {
/* BIO_ip_and_port_to_socket_and_addr creates a socket and fills in |*out_addr|
- * with the correct values for connecting to |hostname| on |port_str|. It
- * returns one on success or zero on error. */
+ * and |*out_addr_length| with the correct values for connecting to |hostname|
+ * on |port_str|. It returns one on success or zero on error. */
int bio_ip_and_port_to_socket_and_addr(int *out_sock,
struct sockaddr_storage *out_addr,
+ socklen_t *out_addr_length,
const char *hostname,
const char *port_str);
diff --git a/crypto/bio/socket_helper.c b/crypto/bio/socket_helper.c
index d304e12b..0d7d21a6 100644
--- a/crypto/bio/socket_helper.c
+++ b/crypto/bio/socket_helper.c
@@ -34,6 +34,7 @@ typedef int socklen_t;
int bio_ip_and_port_to_socket_and_addr(int *out_sock,
struct sockaddr_storage *out_addr,
+ socklen_t *out_addr_length,
const char *hostname,
const char *port_str) {
struct addrinfo hint, *result, *cur;
@@ -60,6 +61,7 @@ int bio_ip_and_port_to_socket_and_addr(int *out_sock,
}
memset(out_addr, 0, sizeof(struct sockaddr_storage));
memcpy(out_addr, cur->ai_addr, cur->ai_addrlen);
+ *out_addr_length = cur->ai_addrlen;
*out_sock = socket(cur->ai_family, cur->ai_socktype, cur->ai_protocol);
if (*out_sock < 0) {