]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Merged revisions 62691 via svnmerge from
authorTilghman Lesher <tilghman@meg.abyt.es>
Wed, 2 May 2007 17:43:48 +0000 (17:43 +0000)
committerTilghman Lesher <tilghman@meg.abyt.es>
Wed, 2 May 2007 17:43:48 +0000 (17:43 +0000)
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r62691 | tilghman | 2007-05-02 12:38:16 -0500 (Wed, 02 May 2007) | 4 lines

Issue 9638 - if a text frame is sent with no terminating NULL through a bridged
IAX connection, the remote end will receive garbage characters tacked onto the
end.

........

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

channels/chan_iax2.c

index 0730e63fedda428a76000c4f311911fcff891351..b2f44f1846a00389e30a2fdeca074f645c69924f 100644 (file)
@@ -6570,6 +6570,13 @@ static int socket_process(struct iax2_thread *thread)
                        ast_mutex_unlock(&iaxsl[fr->callno]);
                        return 1;
                }
+               /* Ensure text frames are NULL-terminated */
+               if (f.frametype == AST_FRAME_TEXT && thread->buf[res - 1] != '\0') {
+                       if (res < sizeof(thread->buf))
+                               thread->buf[res++] = '\0';
+                       else /* Trims one character from the text message, but that's better than overwriting the end of the buffer. */
+                               thread->buf[res - 1] = '\0';
+               }
                f.datalen = res - sizeof(*fh);
 
                /* Handle implicit ACKing unless this is an INVAL, and only if this is