From b72f28ea01f67fb714fe742d2dabf6d9eab3cb08 Mon Sep 17 00:00:00 2001 From: Mark Michelson <mmichelson@digium.com> Date: Tue, 15 Sep 2009 14:59:50 +0000 Subject: [PATCH] Fix off-by-one error when reading SDP sent over TCP. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@218499 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- channels/chan_sip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 672e668da2..bd4653638a 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; } -- GitLab