aboutsummaryrefslogtreecommitdiffstats
path: root/channels/chan_sip.c
diff options
context:
space:
mode:
Diffstat (limited to 'channels/chan_sip.c')
-rw-r--r--channels/chan_sip.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index d7072dee1..58ba06f06 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -2818,10 +2818,11 @@ static void *_sip_tcp_helper_thread(struct sip_pvt *pvt, struct ast_tcptls_sessi
if (sscanf(get_header(&reqcpy, "Content-Length"), "%30d", &cl)) {
while (cl > 0) {
ast_mutex_lock(&tcptls_session->lock);
- if (!fread(buf, (cl < sizeof(buf)) ? cl : sizeof(buf), 1, tcptls_session->f)) {
+ if (!fread(buf, MIN(sizeof(buf) - 1, cl), 1, tcptls_session->f)) {
ast_mutex_unlock(&tcptls_session->lock);
goto cleanup;
}
+ buf[sizeof(buf)-1] = '\0';
ast_mutex_unlock(&tcptls_session->lock);
if (me->stop)
goto cleanup;