Commit 7def93cf authored by Youness Alaoui's avatar Youness Alaoui

use socklen_t where needed, and cast it to size_t as it defined as an int in...

use socklen_t where needed, and cast it to size_t as it defined as an int in mingw and as an uint on linux systems
parent 7e4bf0ee
...@@ -80,7 +80,7 @@ socket_recv ( ...@@ -80,7 +80,7 @@ socket_recv (
{ {
gint recvd; gint recvd;
struct sockaddr_storage sa; struct sockaddr_storage sa;
guint from_len = sizeof (sa); socklen_t from_len = sizeof (sa);
recvd = recvfrom (sock->fileno, buf, len, 0, (struct sockaddr *) &sa, recvd = recvfrom (sock->fileno, buf, len, 0, (struct sockaddr *) &sa,
&from_len); &from_len);
...@@ -132,7 +132,7 @@ nice_udp_bsd_socket_new (NiceAddress *addr) ...@@ -132,7 +132,7 @@ nice_udp_bsd_socket_new (NiceAddress *addr)
{ {
int sockfd = -1; int sockfd = -1;
struct sockaddr_storage name; struct sockaddr_storage name;
guint name_len = sizeof (name); socklen_t name_len = sizeof (name);
NiceSocket *sock = g_slice_new0 (NiceSocket); NiceSocket *sock = g_slice_new0 (NiceSocket);
if (!sock) { if (!sock) {
......
...@@ -375,7 +375,7 @@ nice_udp_turn_socket_parse_recv ( ...@@ -375,7 +375,7 @@ nice_udp_turn_socket_parse_recv (
StunValidationStatus valid; StunValidationStatus valid;
StunMessage msg; StunMessage msg;
struct sockaddr_storage sa; struct sockaddr_storage sa;
guint from_len = sizeof (sa); socklen_t from_len = sizeof (sa);
GList *i = priv->channels; GList *i = priv->channels;
ChannelBinding *binding = NULL; ChannelBinding *binding = NULL;
......
...@@ -217,7 +217,7 @@ stun_message_find_addr (const StunMessage *msg, stun_attr_type_t type, ...@@ -217,7 +217,7 @@ stun_message_find_addr (const StunMessage *msg, stun_attr_type_t type,
case 1: case 1:
{ {
struct sockaddr_in *ip4 = (struct sockaddr_in *)addr; struct sockaddr_in *ip4 = (struct sockaddr_in *)addr;
if ((*addrlen < sizeof (*ip4)) || (len != 8)) if (((size_t) *addrlen < sizeof (*ip4)) || (len != 8))
{ {
*addrlen = sizeof (*ip4); *addrlen = sizeof (*ip4);
return EINVAL; return EINVAL;
...@@ -237,7 +237,7 @@ stun_message_find_addr (const StunMessage *msg, stun_attr_type_t type, ...@@ -237,7 +237,7 @@ stun_message_find_addr (const StunMessage *msg, stun_attr_type_t type,
case 2: case 2:
{ {
struct sockaddr_in6 *ip6 = (struct sockaddr_in6 *)addr; struct sockaddr_in6 *ip6 = (struct sockaddr_in6 *)addr;
if ((*addrlen < sizeof (*ip6)) || (len != 20)) if (((size_t) *addrlen < sizeof (*ip6)) || (len != 20))
{ {
*addrlen = sizeof (*ip6); *addrlen = sizeof (*ip6);
return EINVAL; return EINVAL;
...@@ -402,7 +402,7 @@ stun_message_append_addr (StunMessage *msg, stun_attr_type_t type, ...@@ -402,7 +402,7 @@ stun_message_append_addr (StunMessage *msg, stun_attr_type_t type,
uint16_t alen, port; uint16_t alen, port;
uint8_t family; uint8_t family;
if (addrlen < sizeof (struct sockaddr)) if ((size_t) addrlen < sizeof (struct sockaddr))
return EINVAL; return EINVAL;
switch (addr->sa_family) switch (addr->sa_family)
...@@ -420,7 +420,7 @@ stun_message_append_addr (StunMessage *msg, stun_attr_type_t type, ...@@ -420,7 +420,7 @@ stun_message_append_addr (StunMessage *msg, stun_attr_type_t type,
case AF_INET6: case AF_INET6:
{ {
const struct sockaddr_in6 *ip6 = (const struct sockaddr_in6 *)addr; const struct sockaddr_in6 *ip6 = (const struct sockaddr_in6 *)addr;
if (addrlen < sizeof (*ip6)) if ((size_t) addrlen < sizeof (*ip6))
return EINVAL; return EINVAL;
family = 2; family = 2;
...@@ -453,7 +453,7 @@ int stun_message_append_xor_addr (StunMessage *msg, stun_attr_type_t type, ...@@ -453,7 +453,7 @@ int stun_message_append_xor_addr (StunMessage *msg, stun_attr_type_t type,
/* Must be big enough to hold any supported address: */ /* Must be big enough to hold any supported address: */
struct sockaddr_storage xor; struct sockaddr_storage xor;
if (addrlen > sizeof (xor)) if ((size_t) addrlen > sizeof (xor))
addrlen = sizeof (xor); addrlen = sizeof (xor);
memcpy (&xor, addr, addrlen); memcpy (&xor, addr, addrlen);
...@@ -474,7 +474,7 @@ int stun_message_append_xor_addr_full (StunMessage *msg, stun_attr_type_t type, ...@@ -474,7 +474,7 @@ int stun_message_append_xor_addr_full (StunMessage *msg, stun_attr_type_t type,
/* Must be big enough to hold any supported address: */ /* Must be big enough to hold any supported address: */
struct sockaddr_storage xor; struct sockaddr_storage xor;
if (addrlen > sizeof (xor)) if ((size_t) addrlen > sizeof (xor))
addrlen = sizeof (xor); addrlen = sizeof (xor);
memcpy (&xor, addr, addrlen); memcpy (&xor, addr, addrlen);
......
...@@ -70,7 +70,7 @@ int stun_trans_init (stun_trans_t *tr, int fd, ...@@ -70,7 +70,7 @@ int stun_trans_init (stun_trans_t *tr, int fd,
{ {
assert (fd != -1); assert (fd != -1);
if (srvlen > sizeof (tr->dst)) if ((size_t) srvlen > sizeof (tr->dst))
return ENOBUFS; return ENOBUFS;
tr->own_fd = -1; tr->own_fd = -1;
...@@ -126,7 +126,7 @@ int stun_trans_create (stun_trans_t *restrict tr, int type, int proto, ...@@ -126,7 +126,7 @@ int stun_trans_create (stun_trans_t *restrict tr, int type, int proto,
{ {
int val, fd; int val, fd;
if (srvlen < sizeof(*srv)) if ((size_t) srvlen < sizeof(*srv))
return EINVAL; return EINVAL;
fd = stun_socket (srv->sa_family, type, proto); fd = stun_socket (srv->sa_family, type, proto);
......
...@@ -176,7 +176,7 @@ int stun_xor_address (const StunMessage *msg, ...@@ -176,7 +176,7 @@ int stun_xor_address (const StunMessage *msg,
case AF_INET: case AF_INET:
{ {
struct sockaddr_in *ip4 = (struct sockaddr_in *)addr; struct sockaddr_in *ip4 = (struct sockaddr_in *)addr;
if (addrlen < sizeof (*ip4)) if ((size_t) addrlen < sizeof (*ip4))
return EINVAL; return EINVAL;
ip4->sin_port ^= htons (magic_cookie >> 16); ip4->sin_port ^= htons (magic_cookie >> 16);
...@@ -189,7 +189,7 @@ int stun_xor_address (const StunMessage *msg, ...@@ -189,7 +189,7 @@ int stun_xor_address (const StunMessage *msg,
struct sockaddr_in6 *ip6 = (struct sockaddr_in6 *)addr; struct sockaddr_in6 *ip6 = (struct sockaddr_in6 *)addr;
unsigned short i; unsigned short i;
if (addrlen < sizeof (*ip6)) if ((size_t) addrlen < sizeof (*ip6))
return EINVAL; return EINVAL;
ip6->sin6_port ^= htons (magic_cookie >> 16); ip6->sin6_port ^= htons (magic_cookie >> 16);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment