From fa0aba61e8916a28508f14da8e78921d953429c1 Mon Sep 17 00:00:00 2001 From: Automerge Script Date: Wed, 2 May 2007 18:18:44 +0000 Subject: [PATCH] automerge commit git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2-netsec@62733 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- channels/chan_iax2.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index 95fede0710..d11b0b4b8e 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -6732,6 +6732,13 @@ static int socket_read(int *id, int fd, short events, void *cbdata) ast_mutex_unlock(&iaxsl[fr->callno]); return 1; } + /* Ensure text frames are NULL-terminated */ + if (f.frametype == AST_FRAME_TEXT && buf[res - 1] != '\0') { + if (res < sizeof(buf)) + buf[res++] = '\0'; + else /* Trims one character from the text message, but that's better than overwriting the end of the buffer. */ + buf[res - 1] = '\0'; + } f.datalen = res - sizeof(*fh); /* Handle implicit ACKing unless this is an INVAL, and only if this is