diff options
author | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-05-02 17:38:16 +0000 |
---|---|---|
committer | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-05-02 17:38:16 +0000 |
commit | 873d9efc182d675535045af1111ee4e7d10f18a8 (patch) | |
tree | f32a20fd25175aa674f4ab0c72524066ecedce1e /channels/chan_iax2.c | |
parent | dcefe34be7c1a0e1b33e09f05046b322a1a27eb9 (diff) |
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: http://svn.digium.com/svn/asterisk/branches/1.2@62691 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_iax2.c')
-rw-r--r-- | channels/chan_iax2.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index 95fede071..d11b0b4b8 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 |