From: Mark Michelson Date: Tue, 15 Sep 2009 14:59:50 +0000 (+0000) Subject: Fix off-by-one error when reading SDP sent over TCP. X-Git-Tag: 11.0.0-beta1~4171 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b72f28ea01f67fb714fe742d2dabf6d9eab3cb08;p=thirdparty%2Fasterisk.git 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 --- 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; }