]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Merged revisions 218499,218504 via svnmerge from
authorMark Michelson <mmichelson@digium.com>
Tue, 15 Sep 2009 15:12:35 +0000 (15:12 +0000)
committerMark Michelson <mmichelson@digium.com>
Tue, 15 Sep 2009 15:12:35 +0000 (15:12 +0000)
https://origsvn.digium.com/svn/asterisk/trunk

........
  r218499 | mmichelson | 2009-09-15 09:59:50 -0500 (Tue, 15 Sep 2009) | 3 lines

  Fix off-by-one error when reading SDP sent over TCP.
........
  r218504 | mmichelson | 2009-09-15 10:05:53 -0500 (Tue, 15 Sep 2009) | 3 lines

  Ensure that SDP read from TCP socket is null-terminated.
........

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.1@218506 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index d967bde59191e1c8249bc05a2a83c9917d0e2770..5a07d782e0479b531e3a9996973ec13a6466421c 100644 (file)
@@ -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;