* \retval -1 Failed to read data
* \retval 0 Succeeded in reading data
*/
-static int sip_tls_read(struct sip_request *req, struct ast_tcptls_session_instance *tcptls_session, int authenticated, time_t start, struct sip_threadinfo *me)
+static int sip_tls_read(struct sip_request *req, struct sip_request *reqcpy, struct ast_tcptls_session_instance *tcptls_session,
+ int authenticated, time_t start, struct sip_threadinfo *me)
{
int res, content_length, after_poll = 1, need_poll = 1;
- struct sip_request reqcpy = { 0, };
char buf[1024] = "";
int timeout = -1;
}
ast_str_append(&req->data, 0, "%s", buf);
}
- copy_request(&reqcpy, req);
- parse_request(&reqcpy);
+ copy_request(reqcpy, req);
+ parse_request(reqcpy);
/* In order to know how much to read, we need the content-length header */
- if (sscanf(sip_get_header(&reqcpy, "Content-Length"), "%30d", &content_length)) {
+ if (sscanf(sip_get_header(reqcpy, "Content-Length"), "%30d", &content_length)) {
while (content_length > 0) {
size_t bytes_read;
if (!tcptls_session->client && !authenticated) {
}
req.socket.fd = tcptls_session->fd;
if (tcptls_session->ssl) {
- res = sip_tls_read(&req, tcptls_session, authenticated, start, me);
+ res = sip_tls_read(&req, &reqcpy, tcptls_session, authenticated, start, me);
} else {
res = sip_tcp_read(&req, tcptls_session, authenticated, start);
}
retry++;
ao2_iterator_destroy(&it);
goto tryagain;
+ } else {
+ srtp->session = NULL;
}
ao2_t_ref(policy, -1, "Unreffing first policy after srtp_create failed");
}
/* Any failures after this point can use ast_srtp_destroy to destroy the instance */
if (srtp_create(&temp->session, &policy->sp) != err_status_ok) {
+ /* Session either wasn't created or was created and dealloced. */
+ temp->session = NULL;
ast_srtp_destroy(temp);
return -1;
}