diff options
author | Mark Michelson <mmichelson@digium.com> | 2009-09-15 15:40:14 +0000 |
---|---|---|
committer | Mark Michelson <mmichelson@digium.com> | 2009-09-15 15:40:14 +0000 |
commit | 15c7e6dea2a43eeef4569a047a502995cc29ecda (patch) | |
tree | 95aad75abf1aa8ea833467914470d485dd1b7993 /channels | |
parent | 579919e831f53c596d0a1533a235bc936e34b8fc (diff) |
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/trunk@218566 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels')
-rw-r--r-- | channels/chan_sip.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 789b1a7dc..fff09c614 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -2962,12 +2962,13 @@ static void *_sip_tcp_helper_thread(struct sip_pvt *pvt, struct ast_tcptls_sessi /* In order to know how much to read, we need the content-length header */ 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; |