Index: channels/chan_sip.c =================================================================== --- channels/chan_sip.c (Revision 319061) +++ channels/chan_sip.c (Arbeitskopie) @@ -2630,17 +2630,7 @@ timeout = -1; } - res = ast_wait_for_input(tcptls_session->fd, timeout); - if (res < 0) { - ast_debug(2, "SIP %s server :: ast_wait_for_input returned %d\n", tcptls_session->ssl ? "SSL": "TCP", res); - goto cleanup; - } else if (res == 0) { - /* timeout */ - ast_debug(2, "SIP %s server timed out\n", tcptls_session->ssl ? "SSL": "TCP"); - goto cleanup; - } - - ast_mutex_lock(&tcptls_session->lock); + ast_mutex_lock(&tcptls_session->lock); if (!fgets(buf, sizeof(buf), tcptls_session->f)) { ast_mutex_unlock(&tcptls_session->lock); goto cleanup; @@ -2652,8 +2642,12 @@ ast_str_append(&req.data, 0, "%s", buf); req.len = req.data->used; } - copy_request(&reqcpy, &req); - parse_request(&reqcpy); + copy_request(&reqcpy, &req); + if (parse_request(&reqcpy) == -1) { + /* Bad packet */ + continue; + } + /* In order to know how much to read, we need the content-length header */ if (sscanf(get_header(&reqcpy, "Content-Length"), "%30d", &cl)) { while (cl > 0) { @@ -2671,23 +2665,13 @@ timeout = -1; } - res = ast_wait_for_input(tcptls_session->fd, timeout); - if (res < 0) { - ast_debug(2, "SIP %s server :: ast_wait_for_input returned %d\n", tcptls_session->ssl ? "SSL": "TCP", res); - goto cleanup; - } else if (res == 0) { - /* timeout */ - ast_debug(2, "SIP %s server timed out", tcptls_session->ssl ? "SSL": "TCP"); - goto cleanup; - } - ast_mutex_lock(&tcptls_session->lock); if (!(bytes_read = fread(buf, 1, MIN(sizeof(buf) - 1, cl), tcptls_session->f))) { ast_mutex_unlock(&tcptls_session->lock); goto cleanup; } - buf[bytes_read] = '\0'; ast_mutex_unlock(&tcptls_session->lock); + buf[bytes_read] = '\0'; if (me->stop) { goto cleanup; } @@ -24320,7 +24304,7 @@ if (sip_debug_test_addr(addr)) /* Set the debug flag early on packet level */ req->debug = 1; if (sip_cfg.pedanticsipchecking) - req->len = lws2sws(req->data->str, req->len); /* Fix multiline headers */ + req->len = lws2sws(req->data->str, req->len); /* Fix multiline headers */ if (req->debug) { ast_verbose("\n<--- SIP read from %s:%s --->\n%s\n<------------->\n", get_transport(req->socket.type), ast_sockaddr_stringify(addr), req->data->str);