diff options
Diffstat (limited to 'channels/chan_sip.c')
-rw-r--r-- | channels/chan_sip.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index d967bde59..5a07d782e 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -2449,10 +2449,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; |