From 3aa5055bf12994c674bdf306c38470b01f90aa8c Mon Sep 17 00:00:00 2001 From: Jeff Lenk Date: Fri, 30 Oct 2009 04:07:49 +0000 Subject: [PATCH] windows compiler fixes and switch_mprintf overflow(32bit only) git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15286 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/endpoints/mod_sofia/sofia_reg.c | 7 ++++++- src/switch_utils.c | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/sofia_reg.c b/src/mod/endpoints/mod_sofia/sofia_reg.c index 1e9e7920a1..9a0625e272 100644 --- a/src/mod/endpoints/mod_sofia/sofia_reg.c +++ b/src/mod/endpoints/mod_sofia/sofia_reg.c @@ -2083,7 +2083,12 @@ auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, char *sql; x = get_nc(nc, sip); - sql = switch_mprintf("update sip_authentication set expires='%ld',last_nc=%lu where nonce='%s'", +#ifdef _WIN32 && !_WIN64 +#define LL_FMT "ll" +#else +#define LL_FMT "l" +#endif + sql = switch_mprintf("update sip_authentication set expires='%"LL_FMT"u',last_nc=%lu where nonce='%s'", switch_epoch_time_now(NULL) + (profile->nonce_ttl ? profile->nonce_ttl : exptime + 10), x, nonce); switch_assert(sql != NULL); diff --git a/src/switch_utils.c b/src/switch_utils.c index 80356d0886..1db491232d 100644 --- a/src/switch_utils.c +++ b/src/switch_utils.c @@ -1342,7 +1342,7 @@ SWITCH_DECLARE(int) get_addr_int(switch_sockaddr_t *sa) { struct sockaddr_in *s = (struct sockaddr_in *)&sa->sa; - return ntohs(s->sin_addr.s_addr); + return ntohs((unsigned short)s->sin_addr.s_addr); } @@ -1351,7 +1351,7 @@ SWITCH_DECLARE(int) switch_cmp_addr(switch_sockaddr_t *sa1, switch_sockaddr_t *s struct sockaddr_in *s1 = (struct sockaddr_in *)&sa1->sa; struct sockaddr_in *s2 = (struct sockaddr_in *)&sa2->sa; - return (ntohs(s1->sin_addr.s_addr) == ntohs(s2->sin_addr.s_addr) && ntohs(s1->sin_port) == ntohs(s2->sin_port)); + return (ntohs((unsigned short)s1->sin_addr.s_addr) == ntohs((unsigned short)s2->sin_addr.s_addr) && ntohs(s1->sin_port) == ntohs(s2->sin_port)); }