From: Mark Michelson Date: Tue, 15 Sep 2009 15:42:29 +0000 (+0000) Subject: Merged revisions 218566 via svnmerge from X-Git-Tag: 1.6.1.7-rc1~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b885ba2f761635414fe1a0f1d9ace95b4b01e193;p=thirdparty%2Fasterisk.git Merged revisions 218566 via svnmerge from https://origsvn.digium.com/svn/asterisk/trunk ........ r218566 | mmichelson | 2009-09-15 10:40:14 -0500 (Tue, 15 Sep 2009) | 4 lines Use a better method of ensuring null-termination of the buffer while reading the SDP when using TCP. ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.1@218574 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 5a07d782e0..f87fe8af85 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -2448,12 +2448,13 @@ static void *_sip_tcp_helper_thread(struct sip_pvt *pvt, struct ast_tcptls_sessi parse_request(&reqcpy); if (sscanf(get_header(&reqcpy, "Content-Length"), "%30d", &cl)) { while (cl > 0) { + size_t bytes_read; ast_mutex_lock(&tcptls_session->lock); - if (!fread(buf, MIN(sizeof(buf) - 1, cl), 1, tcptls_session->f)) { + if (!(bytes_read = fread(buf, MIN(sizeof(buf) - 1, cl), 1, tcptls_session->f))) { ast_mutex_unlock(&tcptls_session->lock); goto cleanup; } - buf[sizeof(buf)-1] = '\0'; + buf[bytes_read] = '\0'; ast_mutex_unlock(&tcptls_session->lock); if (me->stop) goto cleanup;