diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 672e668da214bbde744b516fa3467344caa72514..bd4653638a0b38658da5094912bc905f3090e9d2 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -2963,7 +2963,7 @@ 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; }