]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Merged revisions 218566 via svnmerge from
authorMark Michelson <mmichelson@digium.com>
Tue, 15 Sep 2009 15:42:03 +0000 (15:42 +0000)
committerMark Michelson <mmichelson@digium.com>
Tue, 15 Sep 2009 15:42:03 +0000 (15:42 +0000)
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.0@218573 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index ae63f7c3d3273989d7af392f0691f58d3b24c413..0b562693b173d32b72f76e411710374d461c29b1 100644 (file)
@@ -2275,12 +2275,13 @@ static void *_sip_tcp_helper_thread(struct sip_pvt *pvt, struct ast_tcptls_sessi
                parse_copy(&reqcpy, &req);
                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;