Commit 36c3c83f authored by Pekka Pessi's avatar Pekka Pessi
Browse files

Checking that we have got valid server address as parameter.

darcs-hash:20051018175545-65a35-2e0b63294a71b4cc97ebbbba29fb15b023255257.gz
parent ffcbc6e9
...@@ -137,6 +137,7 @@ stun_engine_t *stun_engine_tcreate(tag_type_t tag, tag_value_t value, ...) ...@@ -137,6 +137,7 @@ stun_engine_t *stun_engine_tcreate(tag_type_t tag, tag_value_t value, ...)
char const *server = NULL; char const *server = NULL;
int msg_integrity = 1; int msg_integrity = 1;
ta_list ta; ta_list ta;
su_sockaddr_t su[1];
SU_DEBUG_5(("%s(\"%s\"): called\n", SU_DEBUG_5(("%s(\"%s\"): called\n",
"stun_engine_tcreate", server)); "stun_engine_tcreate", server));
...@@ -153,7 +154,14 @@ stun_engine_t *stun_engine_tcreate(tag_type_t tag, tag_value_t value, ...) ...@@ -153,7 +154,14 @@ stun_engine_t *stun_engine_tcreate(tag_type_t tag, tag_value_t value, ...)
server = getenv("STUN_SERVER"); server = getenv("STUN_SERVER");
SU_DEBUG_5(("stun: using STUN_SERVER=%s\n", server)); SU_DEBUG_5(("stun: using STUN_SERVER=%s\n", server));
} }
memset(su, 0, (sizeof su));
if (server) {
if (stun_atoaddr(&su->su_sin, server) != 0)
return NULL;
}
stun = su_home_clone(NULL, sizeof(*stun)); stun = su_home_clone(NULL, sizeof(*stun));
if (stun) { if (stun) {
...@@ -161,11 +169,11 @@ stun_engine_t *stun_engine_tcreate(tag_type_t tag, tag_value_t value, ...) ...@@ -161,11 +169,11 @@ stun_engine_t *stun_engine_tcreate(tag_type_t tag, tag_value_t value, ...)
* I suppose this may block for the moment * I suppose this may block for the moment
*/ */
memset(&stun->stun_srvr4[0], 0, sizeof(stun->stun_srvr4[0])); memset(&stun->stun_srvr4[0], 0, sizeof(stun->stun_srvr4[0]));
if(server) {
stun_atoaddr((struct sockaddr_in *)&(stun->stun_srvr4[0]), server); if (server) {
if(stun->stun_srvr4[0].su_sin.sin_port == 0) { if (su->su_sin.sin_port == 0)
stun->stun_srvr4[0].su_sin.sin_port = htons(STUN_DEFAULT_PORT); su->su_sin.sin_port = htons(STUN_DEFAULT_PORT);
} stun->stun_srvr4[0] = su[0];
} }
/* alternative address set to 0 */ /* alternative address set to 0 */
......
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