Commit 07460358 authored by Pekka Pessi's avatar Pekka Pessi

Fixes for using size_t/ssize_t/su_socket_t and isize_t/usize_t/issize_t.

su, sip, msg, http, url, sdp, soa, etc..

darcs-hash:20060919133329-65a35-62b9f9819398d39e889315e8bd1b24ba0b8a9b23.gz
parent 9a052bd7
......@@ -57,8 +57,9 @@
/** Complete a HTTP request. */
int http_request_complete(msg_t *msg)
{
usize_t len;
size_t len = 0;
http_t *http = http_object(msg);
http_payload_t const *pl;
su_home_t *home = msg_home(msg);
if (!http)
......@@ -68,17 +69,18 @@ int http_request_complete(msg_t *msg)
if (!http->http_host)
return -1;
if (http->http_payload)
len = http->http_payload->pl_len;
else
len = 0;
for (pl = http->http_payload; pl; pl = pl->pl_next)
len += pl->pl_len;
if (len > UINT32_MAX)
return -1;
if (!http->http_content_length) {
http->http_content_length = http_content_length_create(home, len);
http->http_content_length = http_content_length_create(home, (uint32_t)len);
}
else {
if (http->http_content_length->l_length != len) {
http->http_content_length->l_length = len;
http->http_content_length->l_length = (uint32_t)len;
msg_fragment_clear(http->http_content_length->l_common);
}
}
......@@ -117,12 +119,15 @@ int http_message_complete(msg_t *msg, http_t *http)
if (!http->http_content_length) {
http_content_length_t *l;
http_payload_t *pl;
usize_t len = 0;
size_t len = 0;
for (pl = http->http_payload; pl; pl = pl->pl_next)
len += pl->pl_len;
l = http_content_length_create(msg_home(msg), len);
if (len > UINT32_MAX)
return -1;
l = http_content_length_create(msg_home(msg), (uint32_t)len);
if (msg_header_insert(msg, http, (http_header_t *)l) < 0)
return -1;
......
......@@ -78,8 +78,9 @@ char const auth_internal_server_error[] = "Internal server error";
static void auth_md5_hmac_key(auth_mod_t *am);
HTABLE_PROTOS(auth_htable, aht, auth_passwd_t);
HTABLE_BODIES(auth_htable, aht, auth_passwd_t, APW_HASH);
HTABLE_PROTOS_WITH(auth_htable, aht, auth_passwd_t, usize_t, unsigned);
HTABLE_BODIES_WITH(auth_htable, aht, auth_passwd_t, APW_HASH,
usize_t, unsigned);
/**Allocate an authentication module instance.
*
......@@ -306,7 +307,7 @@ auth_status_t *auth_status_init_with(void *p,
if (size > INT_MAX) size = INT_MAX;
as = memset(p, 0, size);
as->as_home->suh_size = size;
as->as_home->suh_size = (int)size;
/* su_home_init(as->as_home); */
......@@ -833,17 +834,17 @@ auth_passwd_t *auth_mod_getpass(auth_mod_t *am,
char const *realm)
{
auth_passwd_t *apw, **slot;
unsigned index;
unsigned hash;
if (am == NULL || user == NULL)
return NULL;
index = msg_hash_string(user);
hash = msg_hash_string(user);
for (slot = auth_htable_hash(am->am_users, index);
for (slot = auth_htable_hash(am->am_users, hash);
(apw = *slot);
slot = auth_htable_next(am->am_users, slot)) {
if (index != apw->apw_index)
if (hash != apw->apw_index)
continue;
if (strcmp(user, apw->apw_user))
continue;
......@@ -909,7 +910,8 @@ auth_passwd_t *auth_mod_addpass(auth_mod_t *am,
return apw;
}
static int readfile(su_home_t *, FILE *, void **contents, int add_trailing_lf);
static ssize_t readfile(su_home_t *, FILE *,
void **contents, int add_trailing_lf);
static int auth_readdb_internal(auth_mod_t *am, int always);
/** Read authentication database */
......@@ -1157,25 +1159,29 @@ auth_htable_append_local(auth_htable_t *aht, auth_passwd_t *apw)
}
static
int readfile(su_home_t *home, FILE *f, void **contents, int add_trailing_lf)
ssize_t readfile(su_home_t *home,
FILE *f,
void **contents,
int add_trailing_lf)
{
/* Read in whole (binary!) file */
char *buffer = NULL;
long size;
int len = -1;
size_t len;
/* Read whole file in */
if (fseek(f, 0, SEEK_END) < 0 ||
(size = ftell(f)) < 0 ||
fseek(f, 0, SEEK_SET) < 0 ||
(long)(len = size) != size) {
(long)(len = (size_t)size) != size ||
size + 2 > SSIZE_MAX) {
SU_DEBUG_1(("%s: unable to determine file size (%s)\n",
__func__, strerror(errno)));
return -1;
}
if (!(buffer = su_alloc(home, len + 2)) ||
fread(buffer, 1, len, f) != (unsigned)len) {
fread(buffer, 1, len, f) != len) {
SU_DEBUG_1(("%s: unable to read file (%s)\n", __func__, strerror(errno)));
if (buffer)
su_free(home, buffer);
......@@ -1350,11 +1356,11 @@ msg_auth_t *auth_digest_credentials(msg_auth_t *auth,
* @param nextnonce true if this is a "nextnonce" [IN]
* @param now current time [IN]
*/
int auth_generate_digest_nonce(auth_mod_t *am,
char buffer[],
size_t bsize,
int nextnonce,
msg_time_t now)
isize_t auth_generate_digest_nonce(auth_mod_t *am,
char buffer[],
size_t bsize,
int nextnonce,
msg_time_t now)
{
struct nonce nonce[1] = {{ 0 }};
su_md5_t md5[1];
......
......@@ -116,7 +116,7 @@ typedef struct
} auth_passwd_t;
HTABLE_DECLARE(auth_htable, aht, auth_passwd_t);
HTABLE_DECLARE_WITH(auth_htable, aht, auth_passwd_t, usize_t, unsigned);
struct stat;
......@@ -242,11 +242,11 @@ void auth_challenge_digest(auth_mod_t *am,
auth_challenger_t const *ach);
SOFIAPUBFUN
int auth_generate_digest_nonce(auth_mod_t *am,
char buffer[],
size_t buffer_len,
int nextnonce,
msg_time_t now);
isize_t auth_generate_digest_nonce(auth_mod_t *am,
char buffer[],
size_t buffer_len,
int nextnonce,
msg_time_t now);
SOFIAPUBFUN
int auth_validate_digest_nonce(auth_mod_t *am,
......
......@@ -312,21 +312,23 @@ msg_href_t const *msg_find_hclass(msg_mclass_t const *mc,
isize_t *return_start_of_content)
{
msg_href_t const *hr;
short i, N;
isize_t m;
short i, N, m;
isize_t len;
assert(mc);
N = mc->mc_hash_size;
i = msg_header_name_hash(s, &m) % N;
i = msg_header_name_hash(s, &len) % N;
if (m == 0) {
if (len == 0 || len > HC_LEN_MAX) {
if (return_start_of_content)
*return_start_of_content = 0;
return mc->mc_error;
}
m = (short)len;
if (m == 1 && mc->mc_short) {
short c = s[0];
if (c >= 'a' && c <= 'z')
......@@ -342,9 +344,9 @@ msg_href_t const *msg_find_hclass(msg_mclass_t const *mc,
else {
msg_hclass_t *hc;
/* long form */
for (hr = NULL; (hc = mc->mc_hash[i].hr_class); i = (i + 1) % N) {
/* long form */
if (m == (isize_t)(hc->hc_len) && strncasecmp(s, hc->hc_name, m) == 0) {
if (m == hc->hc_len && strncasecmp(s, hc->hc_name, m) == 0) {
hr = &mc->mc_hash[i];
break;
}
......@@ -357,24 +359,24 @@ msg_href_t const *msg_find_hclass(msg_mclass_t const *mc,
if (!return_start_of_content) /* Just header name */
return hr;
if (s[m] == ':') { /* Fast path */
*return_start_of_content = ++m;
if (s[len] == ':') { /* Fast path */
*return_start_of_content = ++len;
return hr;
}
if (IS_LWS(s[m])) {
if (IS_LWS(s[len])) {
int crlf = 0;
do {
m += span_ws(s + m + crlf) + crlf; /* Skip lws before colon */
crlf = CRLF_TEST(s[m], s[m + 1]);
len += span_ws(s + len + crlf) + crlf; /* Skip lws before colon */
crlf = CRLF_TEST(s[len], s[len + 1]);
}
while (IS_WS(s[m + crlf]));
while (IS_WS(s[len + crlf]));
}
if (s[m++] != ':') /* Colon is required in header */
m = 0;
if (s[len++] != ':') /* Colon is required in header */
len = 0;
*return_start_of_content = m;
*return_start_of_content = len;
return hr;
}
......@@ -357,10 +357,15 @@ issize_t msg_recv_iovec(msg_t *msg, msg_iovec_t vec[], isize_t veclen,
if (!buf)
break;
#if SU_HAVE_WINSOCK
/* WSABUF has u_long */
if (len > SU_IOVECLEN_MAX)
len = SU_IOVECLEN_MAX;
#endif
if (len > n)
len = n;
if (vec)
vec[i].mv_base = buf, vec[i].mv_len = len;
vec[i].mv_base = buf, vec[i].mv_len = (su_ioveclen_t)len;
i++;
if (len == n)
return i;
......@@ -396,7 +401,7 @@ issize_t msg_recv_iovec(msg_t *msg, msg_iovec_t vec[], isize_t veclen,
return -1;
if (vec)
vec[i].mv_base = buf, vec[i].mv_len = n;
vec[i].mv_base = buf, vec[i].mv_len = (su_ioveclen_t)n;
if (chunk) {
assert(chunk->pl_data == NULL); assert(chunk->pl_common->h_len == 0);
......@@ -1910,7 +1915,7 @@ isize_t msg_iovec(msg_t *msg, msg_iovec_t vec[], isize_t veclen)
if (vec && n != veclen)
/* new iovec entry */
vec[n].mv_base = (void *)p, vec[n].mv_len = len;
vec[n].mv_base = (void *)p, vec[n].mv_len = (su_ioveclen_t)len;
else
vec = NULL;
......@@ -2613,7 +2618,8 @@ int msg_header_add_str(msg_t *msg,
* inserted first and replaces the existing request (or status). Other
* headers are inserted after the request or status.
*
* If the header is a singleton, existing headers with the same class are
* If there can be only one header field of this type (hc_kind is
* msg_kind_single), existing header objects with the same class are
* removed.
*
* @param msg message object owning the fragment chain
......
......@@ -281,6 +281,8 @@ struct msg_hclass_s
unsigned /*pad*/:0;
};
#define HC_LEN_MAX SHRT_MAX
SOFIA_END_DECLS
#endif /* !defined MSG_TYPES_H */
......@@ -4018,7 +4018,7 @@ int leg_route(nta_leg_t *leg,
#else
if (r && r->r_url->url_params)
leg->leg_loose_route = url_param(r->r_url->url_params, "lr", NULL, 0);
leg->leg_loose_route = url_has_param(r->r_url->url_params, "lr");
if (contact) {
sip_contact_t m[1], *m0;
......@@ -8177,14 +8177,13 @@ struct sipdns_query
{
struct sipdns_query *sq_next;
int32_t sq_priority; /* priority or preference */
uint16_t sq_weight; /* preference or weight */
uint16_t sq_type;
char const *sq_proto;
char const *sq_domain;
char sq_port[6]; /* port number */
uint16_t sq_type;
uint16_t sq_priority; /* priority or preference */
uint16_t sq_weight; /* preference or weight */
};
static int outgoing_resolve_next(nta_outgoing_t *orq);
......@@ -8809,7 +8808,7 @@ outgoing_answer_srv(sres_context_t *orq, sres_query_t *q,
while (selected) {
unsigned long weight = 0;
unsigned N = 0;
int32_t priority = selected->sq_priority;
uint16_t priority = selected->sq_priority;
/* Total weight of entries with same priority */
for (sq = selected; sq && priority == sq->sq_priority; sq = sq->sq_next) {
......@@ -8823,7 +8822,7 @@ outgoing_answer_srv(sres_context_t *orq, sres_query_t *q,
if (N > 1 && weight > 0) {
unsigned rand = su_randint(0, weight - 1);
while (weight > 0 && rand >= (*tail)->sq_weight) {
while (rand >= (*tail)->sq_weight) {
rand -= (*tail)->sq_weight;
tail = &(*tail)->sq_next;
}
......@@ -8837,7 +8836,7 @@ outgoing_answer_srv(sres_context_t *orq, sres_query_t *q,
SU_DEBUG_5(("nta: %s IN SRV %u %u %s %s (%s)\n",
sq0->sq_domain,
sq->sq_priority, sq->sq_weight,
(unsigned)sq->sq_priority, (unsigned)sq->sq_weight,
sq->sq_port, sq->sq_domain, sq->sq_proto));
}
......@@ -9638,7 +9637,7 @@ nta_outgoing_t *nta_outgoing_tagged(nta_outgoing_t *orq,
* The function nta_outgoing_prack() creates and sends a PRACK request used
* to acknowledge a provisional response.
*
* The request is sent using the route of the original request @a orq.
* The request is sent using the route of the original request @a oorq.
*
* When NTA receives response to the prack request, it invokes the @a
* callback function.
......
......@@ -181,11 +181,11 @@ int main(int argc, char *argv[])
s = su_socket(sa->sa_family = af, types[n], protos[n]);
#if HAVE_SIN6
if (s == SOCKET_ERROR && af == AF_INET6 && !o_ip6)
if (s == INVALID_SOCKET && af == AF_INET6 && !o_ip6)
s = su_socket(sa->sa_family = af = AF_INET, types[n], protos[n]);
#endif
if (s == SOCKET_ERROR) {
if (s == INVALID_SOCKET) {
fprintf(stderr, "%s: socket(AF_INET%s, 0, %s): %s\n",
name, af == AF_INET ? "" : "6", names[n], strerror(errno));
exit(1);
......
......@@ -114,7 +114,7 @@ void sl_message_log(FILE *stream,
* The function sl_from_print() returns number of bytes printed,
* or -1 upon an error.
*/
int sl_from_print(FILE *stream, char const *fmt, sip_from_t const *from)
issize_t sl_from_print(FILE *stream, char const *fmt, sip_from_t const *from)
{
char s[1024];
......@@ -127,7 +127,7 @@ int sl_from_print(FILE *stream, char const *fmt, sip_from_t const *from)
if (fmt && strcmp(fmt, "%s"))
return fprintf(stream, fmt, s);
if (fputs(s, stream) >= 0)
return strlen(s);
return (issize_t)strlen(s);
return -1;
}
......@@ -146,7 +146,7 @@ int sl_from_print(FILE *stream, char const *fmt, sip_from_t const *from)
* The function sl_to_print() returns number of bytes printed,
* or -1 upon an error.
*/
int sl_to_print(FILE *stream, char const *fmt, sip_to_t const *to)
issize_t sl_to_print(FILE *stream, char const *fmt, sip_to_t const *to)
{
return sl_from_print(stream, fmt, (sip_from_t const *)to);
}
......@@ -166,7 +166,7 @@ int sl_to_print(FILE *stream, char const *fmt, sip_to_t const *to)
* The function sl_contact_print() returns number of bytes printed,
* or -1 upon an error.
*/
int sl_contact_print(FILE *stream, char const *fmt, sip_contact_t const *m)
issize_t sl_contact_print(FILE *stream, char const *fmt, sip_contact_t const *m)
{
return sl_from_print(stream, fmt, (sip_from_t const *)m);
}
......@@ -186,7 +186,7 @@ int sl_contact_print(FILE *stream, char const *fmt, sip_contact_t const *m)
* The function sl_allow_print() returns number of bytes printed,
* or -1 upon an error.
*/
int sl_allow_print(FILE *stream, char const *fmt, sip_allow_t const *allow)
issize_t sl_allow_print(FILE *stream, char const *fmt, sip_allow_t const *allow)
{
char *s, b[1024], *end = b + sizeof(b) - 1;
msg_param_t const *p;
......@@ -205,7 +205,7 @@ int sl_allow_print(FILE *stream, char const *fmt, sip_allow_t const *allow)
if (fmt && strcmp(fmt, "%s"))
return fprintf(stream, fmt, b);
if (fputs(b, stream) >= 0)
return strlen(b);
return (issize_t)strlen(b);
return -1;
}
......@@ -225,7 +225,7 @@ int sl_allow_print(FILE *stream, char const *fmt, sip_allow_t const *allow)
* The function sl_payload_print() returns number of bytes printed,
* or -1 upon an error.
*/
int sl_payload_print(FILE *stream, char const *prefix, sip_payload_t const *pl)
issize_t sl_payload_print(FILE *stream, char const *prefix, sip_payload_t const *pl)
{
char *s = pl->pl_data, *end = pl->pl_data + pl->pl_len;
size_t n, total = 0, crlf = 1;
......@@ -242,7 +242,7 @@ int sl_payload_print(FILE *stream, char const *prefix, sip_payload_t const *pl)
if (crlf == 0)
fputs("\n", stream), total++;
return total;
return (issize_t)total;
}
/** Print @Via header.
......@@ -260,7 +260,7 @@ int sl_payload_print(FILE *stream, char const *prefix, sip_payload_t const *pl)
* The function sl_via_print() returns number of bytes printed,
* or -1 upon an error.
*/
int sl_via_print(FILE *stream, char const *fmt, sip_via_t const *v)
issize_t sl_via_print(FILE *stream, char const *fmt, sip_via_t const *v)
{
char s[1024];
......@@ -270,7 +270,7 @@ int sl_via_print(FILE *stream, char const *fmt, sip_via_t const *v)
if (fmt && strcmp(fmt, "%s"))
return fprintf(stream, fmt, s);
if (fputs(s, stream) >= 0)
return strlen(s);
return (issize_t)strlen(s);
return -1;
}
......@@ -289,7 +289,7 @@ int sl_via_print(FILE *stream, char const *fmt, sip_via_t const *v)
* The function sl_header_print() returns number of bytes printed,
* or -1 upon an error.
*/
int sl_header_print(FILE *stream, char const *fmt, sip_header_t const *h)
issize_t sl_header_print(FILE *stream, char const *fmt, sip_header_t const *h)
{
char s[1024];
......@@ -299,6 +299,6 @@ int sl_header_print(FILE *stream, char const *fmt, sip_header_t const *h)
if (fmt && strcmp(fmt, "%s"))
return fprintf(stream, fmt, s);
if (fputs(s, stream) >= 0)
return strlen(s);
return (issize_t)strlen(s);
return -1;
}
......@@ -59,7 +59,7 @@ SOFIAPUBFUN sip_payload_t *sl_fread_payload(su_home_t *home, FILE *);
/* Printing functions */
SOFIAPUBFUN void
sl_message_log(FILE *, char const *prefix, sip_t const *, int details);
SOFIAPUBFUN int
SOFIAPUBFUN issize_t
sl_header_print(FILE *, char const *fmt, sip_header_t const *h),
sl_from_print(FILE *, char const *fmt, sip_from_t const *from),
sl_to_print(FILE *, char const *fmt, sip_to_t const *to),
......
......@@ -454,7 +454,7 @@ int test_init(agent_t *ag, char const *resolv_conf)
contact = getenv("SIPCONTACT");
/* Sink server */
s = socket(af, SOCK_DGRAM, 0); TEST_1(s != SOCKET_ERROR);
s = socket(af, SOCK_DGRAM, 0); TEST_1(s != INVALID_SOCKET);
memset(&su, 0, sulen = sulen0);
su.su_family = af;
if (getenv("sink")) {
......@@ -467,7 +467,7 @@ int test_init(agent_t *ag, char const *resolv_conf)
ag->ag_sink_socket = s;
/* Down server */
s = socket(af, SOCK_STREAM, 0); TEST_1(s != SOCKET_ERROR);
s = socket(af, SOCK_STREAM, 0); TEST_1(s != INVALID_SOCKET);
memset(&su, 0, sulen = sulen0);
su.su_family = af;
if (getenv("down")) {
......
......@@ -899,12 +899,15 @@ int nth_request_treply(nth_request_t *req,
if (http->http_payload && !http->http_content_length) {
http_content_length_t *l;
http_payload_t *pl;
usize_t len = 0;
size_t len = 0;
for (pl = http->http_payload; pl; pl = pl->pl_next)
len += pl->pl_len;
l = http_content_length_create(msg_home(response), len);
if (len > UINT32_MAX)
goto fail;
l = http_content_length_create(msg_home(response), (uint32_t)len);
msg_header_insert(response, (msg_pub_t *)http, (msg_header_t *)l);
}
......@@ -947,6 +950,7 @@ int nth_request_treply(nth_request_t *req,
TAG_IF(close, TPTAG_CLOSE_AFTER(1)),
ta_tags(ta));
fail:
ta_end(ta);
if (retval == 0)
......
......@@ -162,7 +162,7 @@ static int init_test(tester_t *t)
t->t_addr->su_len = (sizeof t->t_addr->su_sin);
s = su_socket(t->t_addr->su_family = AF_INET, SOCK_STREAM, 0);
TEST_1(s != SOCKET_ERROR);
TEST_1(s != INVALID_SOCKET);
TEST_1(inet_pton(AF_INET, "127.0.0.1", &t->t_addr->su_sin.sin_addr) >= 0);
TEST_1(bind(s, &t->t_addr->su_sa,
t->t_addrlen = (sizeof t->t_addr->su_sin)) != -1);
......@@ -450,13 +450,13 @@ static int send_request(tester_t *t, char const *req, size_t reqlen,
char reply[], int rlen,
int *return_len)
{
static su_socket_t c = SOCKET_ERROR;
static su_socket_t c = INVALID_SOCKET;
int m, r;
su_wait_t w[1];
BEGIN();
if (c == SOCKET_ERROR) {
if (c == INVALID_SOCKET) {
c = su_socket(t->t_addr->su_family, SOCK_STREAM, 0); TEST_1(c != SOCK_STREAM);
TEST_1(connect(c, &t->t_addr->su_sa, t->t_addrlen) != -1);
......
......@@ -165,7 +165,7 @@ test_nat_init(su_root_t *root, struct nat *nat)
su_wait_t wait[1];
nat->root = root;
nat->udp_socket = SOCKET_ERROR, nat->tcp_socket = SOCKET_ERROR;
nat->udp_socket = INVALID_SOCKET, nat->tcp_socket = INVALID_SOCKET;
tl_gets(nat->tags,
TESTNATTAG_SYMMETRIC_REF(nat->symmetric),
......@@ -201,7 +201,7 @@ test_nat_init(su_root_t *root, struct nat *nat)
/* Bind TCP and UDP to same port */
for (;;) {
nat->udp_socket = su_socket(li->li_family, SOCK_DGRAM, IPPROTO_UDP);
if (nat->udp_socket == SOCKET_ERROR)
if (nat->udp_socket == INVALID_SOCKET)
return -1;
if (bind(nat->udp_socket, (void *)su, sulen) < 0) {
......@@ -214,7 +214,7 @@ test_nat_init(su_root_t *root, struct nat *nat)
port, su_strerror(su_errno()));
su_close(nat->udp_socket);
nat->udp_socket = SOCKET_ERROR;
nat->udp_socket = INVALID_SOCKET;
if (++port > 65535)
port = 1024;
......@@ -240,12 +240,12 @@ test_nat_init(su_root_t *root, struct nat *nat)
}
nat->tcp_socket = su_socket(li->li_family, SOCK_STREAM, IPPROTO_TCP);
if (nat->tcp_socket == SOCKET_ERROR)
if (nat->tcp_socket == INVALID_SOCKET)
return -1;
if (bind(nat->tcp_socket, (void *)su, sulen) < 0) {
su_close(nat->tcp_socket);
nat->tcp_socket = SOCKET_ERROR;
nat->tcp_socket = INVALID_SOCKET;
fprintf(stderr, "test_nat: port %u: %s\n",
port, su_strerror(su_errno()));
......@@ -311,9 +311,9 @@ test_nat_deinit(su_root_t *root, struct nat *nat)
if (nat->udp_register)
su_root_deregister(root, nat->udp_register);
if (nat->udp_socket != SOCKET_ERROR)
if (nat->udp_socket != INVALID_SOCKET)
su_close(nat->udp_socket);
if (nat->tcp_socket != SOCKET_ERROR)
if (nat->tcp_socket != INVALID_SOCKET)
su_close(nat->tcp_socket);
su_freelocalinfo(nat->localinfo);
......@@ -478,11 +478,11 @@ static int binding_init(struct binding *b,
else
in_to_out = udp_in_to_out, out_to_in = udp_out_to_in;
if (b->in_socket == SOCKET_ERROR) {
if (b->in_socket == INVALID_SOCKET) {
int in_socket;
in_socket = su_socket(from->su_family, b->socktype, b->protocol);
if (in_socket == SOCKET_ERROR) {
if (in_socket == INVALID_SOCKET) {
su_perror("nat_binding_new: socket");
return -1;
}
......@@ -502,7 +502,7 @@ static int binding_init(struct binding *b,
}
out_socket = su_socket(li->li_family, b->socktype, b->protocol);
if (out_socket == SOCKET_ERROR) {
if (out_socket == INVALID_SOCKET) {
su_perror("nat_binding_new: socket");
return -1;
}
......@@ -725,7 +725,7 @@ static int new_tcp(struct nat *nat, su_wait_t *wait, struct binding *dummy)
events = su_wait_events(wait, nat->tcp_socket);
in_socket = accept(nat->tcp_socket, (void *)from, &fromlen);
if (in_socket == SOCKET_ERROR) {
if (in_socket == INVALID_SOCKET) {
su_perror("new_tcp: accept");
return 0;
}
......@@ -828,7 +828,7 @@ static int invalidate_binding(struct binding *b)
char name[64];
out = su_socket(nat->fake->li_family, b->socktype, 0);
if (out == SOCKET_ERROR) {
if (out == INVALID_SOCKET) {
su_perror("new_udp: socket");
return -1;
}
......
......@@ -34,17 +34,18 @@
#include "config.h"
#include <sofia-sip/su_alloc.h>
#include "sofia-sip/sdp.h"
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <limits.h>
#include <assert.h>
#include <sofia-sip/su_alloc.h>
#include "sofia-sip/sdp.h"
/** @typedef struct sdp_parser_s sdp_parser_t;
*
* SDP parser handle.
......@@ -130,20 +131,13 @@ static void parsing_error(sdp_parser_t *p, char const *fmt, ...);
* @todo Parser accepts some non-conforming SDP even with #sdp_f_strict.
*/
sdp_parser_t *
sdp_parse(su_home_t *home, char const msg[], int msgsize, int flags)
sdp_parse(su_home_t *home, char const msg[], issize_t msgsize, int flags)
{
sdp_parser_t *p;
char *b;
size_t len;
if (msgsize == -1 && msg) {
if ((len = strlen(msg)) > ISSIZE_MAX)
len = ISSIZE_MAX;
} else {
len = msgsize;
}
if (len < 0 || msg == NULL) {