提交 4b72d5f8 编写于 作者: R Richard Levitte

Have BIO_get_conn_int_port use BIO_ctrl instead BIO_int_ctrl

BIO_int_ctrl isn't made for the purpose BIO_get_conn_int_port used it
for.

This also changes BIO_C_GET_CONNECT to actually return the port
instead of assigning it to a pointer that was never returned back to
the caller.
Reviewed-by: NAndy Polyakov <appro@openssl.org>
上级 f89ee71b
...@@ -403,7 +403,7 @@ static long conn_ctrl(BIO *b, int cmd, long num, void *ptr) ...@@ -403,7 +403,7 @@ static long conn_ctrl(BIO *b, int cmd, long num, void *ptr)
{ {
BIO *dbio; BIO *dbio;
int *ip; int *ip;
const char **pptr; const char **pptr = NULL;
long ret = 1; long ret = 1;
BIO_CONNECT *data; BIO_CONNECT *data;
...@@ -426,19 +426,28 @@ static long conn_ctrl(BIO *b, int cmd, long num, void *ptr) ...@@ -426,19 +426,28 @@ static long conn_ctrl(BIO *b, int cmd, long num, void *ptr)
case BIO_C_GET_CONNECT: case BIO_C_GET_CONNECT:
if (ptr != NULL) { if (ptr != NULL) {
pptr = (const char **)ptr; pptr = (const char **)ptr;
}
if (b->init) {
if (pptr != NULL) {
ret = 1;
if (num == 0) { if (num == 0) {
*pptr = data->param_hostname; *pptr = data->param_hostname;
} else if (num == 1) { } else if (num == 1) {
*pptr = data->param_port; *pptr = data->param_port;
} else if (num == 2) { } else if (num == 2) {
*pptr = (char *)&(data->ip[0]); *pptr = (char *)&(data->ip[0]);
} else if (num == 3) { } else {
*((int *)ptr) = data->port; ret = 0;
}
}
if (num == 3) {
ret = data->port;
} }
if ((!b->init) || (ptr == NULL)) } else {
if (pptr != NULL)
*pptr = "not initialized"; *pptr = "not initialized";
ret = 1; ret = 0;
} }
break; break;
case BIO_C_SET_CONNECT: case BIO_C_SET_CONNECT:
......
...@@ -466,7 +466,7 @@ struct bio_dgram_sctp_prinfo { ...@@ -466,7 +466,7 @@ struct bio_dgram_sctp_prinfo {
# define BIO_get_conn_hostname(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0) # define BIO_get_conn_hostname(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0)
# define BIO_get_conn_port(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1) # define BIO_get_conn_port(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1)
# define BIO_get_conn_ip(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,2) # define BIO_get_conn_ip(b) BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,2)
# define BIO_get_conn_int_port(b) BIO_int_ctrl(b,BIO_C_GET_CONNECT,3,0) # define BIO_get_conn_int_port(b) BIO_ctrl(b,BIO_C_GET_CONNECT,3,0,NULL)
# define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) # define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册