diff --git a/libs/sofia-sip/.update b/libs/sofia-sip/.update index 17253549d1..4dc866b6d6 100644 --- a/libs/sofia-sip/.update +++ b/libs/sofia-sip/.update @@ -1 +1 @@ -Thu Jul 11 17:38:06 CDT 2013 +Fri Jul 26 11:26:00 CDT 2013 diff --git a/libs/sofia-sip/libsofia-sip-ua/tport/tport.c b/libs/sofia-sip/libsofia-sip-ua/tport/tport.c index 6cbb4336ce..50050e2289 100644 --- a/libs/sofia-sip/libsofia-sip-ua/tport/tport.c +++ b/libs/sofia-sip/libsofia-sip-ua/tport/tport.c @@ -885,12 +885,16 @@ tport_t *tport_alloc_secondary(tport_primary_t *pri, self->tp_stime = self->tp_ktime = self->tp_rtime = su_now(); if (pri->pri_vtable->vtp_init_secondary && - pri->pri_vtable->vtp_init_secondary(self, socket, accepted, - return_reason) < 0) { - if (pri->pri_vtable->vtp_deinit_secondary) - pri->pri_vtable->vtp_deinit_secondary(self); - su_home_zap(self->tp_home); - return NULL; + + pri->pri_vtable->vtp_init_secondary(self, socket, accepted, return_reason) < 0) { + + if (pri->pri_vtable->vtp_deinit_secondary) { + pri->pri_vtable->vtp_deinit_secondary(self); + } + su_timer_destroy(self->tp_timer); + su_home_zap(self->tp_home); + + return NULL; } /* Set IP TOS if it is set in primary */ diff --git a/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_ws.c b/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_ws.c index 22c56ef07f..67f78148fb 100644 --- a/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_ws.c +++ b/libs/sofia-sip/libsofia-sip-ua/tport/tport_type_ws.c @@ -456,13 +456,17 @@ int tport_ws_init_secondary(tport_t *self, int socket, int accepted, if ( wspri->ws_secure ) wstp->ws_secure = 1; memset(&wstp->ws, 0, sizeof(wstp->ws)); - + if (ws_init(&wstp->ws, socket, wstp->ws_secure ? wspri->ssl_ctx : NULL, 0) < 0) { + ws_destroy(&wstp->ws); + su_close(socket); + wstp->ws_initialized = -1; return *return_reason = "WS_INIT", -1; } wstp->ws_initialized = 1; self->tp_pre_framed = 1; + return 0; diff --git a/libs/sofia-sip/libsofia-sip-ua/tport/ws.c b/libs/sofia-sip/libsofia-sip-ua/tport/ws.c index 33d984a9d5..35fb4c0f22 100644 --- a/libs/sofia-sip/libsofia-sip-ua/tport/ws.c +++ b/libs/sofia-sip/libsofia-sip-ua/tport/ws.c @@ -242,6 +242,10 @@ int ws_handshake(wsh_t *wsh) } } + if (bytes > sizeof(wsh->buffer)) { + goto err; + } + *(wsh->buffer+bytes) = '\0'; if (strncasecmp(wsh->buffer, "GET ", 4)) { @@ -325,7 +329,8 @@ issize_t ws_raw_read(wsh_t *wsh, void *data, size_t bytes) #else if (x++) Sleep(10); #endif - } while (r == -1 && (errno == EAGAIN || errno == EINTR) && x < 100); + } while (r == -1 && (errno == EAGAIN || errno == EINTR || errno == EWOULDBLOCK || + errno == 35 || errno == 730035 || errno == 2 || errno == 60) && x < 100); if (x >= 100) { r = -1; @@ -462,7 +467,12 @@ int ws_init(wsh_t *wsh, ws_socket_t sock, SSL_CTX *ssl_ctx, int close_sock) } while (!wsh->down && !wsh->handshake) { - ws_handshake(wsh); + int r = ws_handshake(wsh); + + if (r < 0) { + wsh->down = 1; + return -1; + } } if (wsh->down) {