1
0
mirror of https://gitlab.xiph.org/xiph/icecast-common.git synced 2024-12-04 14:46:31 -05:00

Update: Only allow getting IO interface for connected sockets

This commit is contained in:
Philipp Schafft 2019-10-02 19:12:15 +00:00
parent 89d90b20e6
commit aa8b84f497

View File

@ -44,6 +44,8 @@ struct igloo_socket_tag {
igloo_socket_action_t action; igloo_socket_action_t action;
int syssock; int syssock;
int connected;
}; };
static void __free(igloo_ro_t self); static void __free(igloo_ro_t self);
@ -191,6 +193,9 @@ static igloo_ro_t __get_interface_t(igloo_ro_t self, const igloo_ro_type_t *type
if (type != igloo_RO_GET_TYPE_BY_SYMBOL(igloo_io_t)) if (type != igloo_RO_GET_TYPE_BY_SYMBOL(igloo_io_t))
return igloo_RO_NULL; return igloo_RO_NULL;
if (!sock->connected)
return igloo_RO_NULL;
return (igloo_ro_t)igloo_io_new(&igloo_socket_io_ifdesc, self, NULL, name, associated, instance); return (igloo_ro_t)igloo_io_new(&igloo_socket_io_ifdesc, self, NULL, name, associated, instance);
} }
@ -291,6 +296,8 @@ static igloo_error_t __bind_or_connect(igloo_socket_t *sock, igloo_socketaddr_t
} }
if (ret == 0) { if (ret == 0) {
if (do_connect)
sock->connected = 1;
return igloo_ERROR_NONE; return igloo_ERROR_NONE;
} else { } else {
return igloo_ERROR_GENERIC; return igloo_ERROR_GENERIC;
@ -603,6 +610,8 @@ igloo_socket_t * igloo_socket_accept(igloo_socket_t *sock, const char *name, igl
return NULL; return NULL;
} }
ret->connected = 1;
if (domain == igloo_socketaddr_get_sysid_domain(sock->domain)) { if (domain == igloo_socketaddr_get_sysid_domain(sock->domain)) {
igloo_socket_alter_address(ret, igloo_SOCKET_ADDRESSOP_REPLACE, igloo_SOCKET_ENDPOINT_LOCAL_PHYSICAL, sock->local_physical); igloo_socket_alter_address(ret, igloo_SOCKET_ADDRESSOP_REPLACE, igloo_SOCKET_ENDPOINT_LOCAL_PHYSICAL, sock->local_physical);
} }
@ -716,6 +725,7 @@ static igloo_error_t igloo_socket_nonblocking__get_return(igloo_socket_t *sock,
} }
igloo_socket_nonblocking(sock, igloo_SOCKET_ACTION_NONE); igloo_socket_nonblocking(sock, igloo_SOCKET_ACTION_NONE);
sock->connected = 1;
return igloo_ERROR_NONE; return igloo_ERROR_NONE;
break; break;
case igloo_SOCKET_ACTION_ACCEPT: case igloo_SOCKET_ACTION_ACCEPT: