diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-05-20 19:54:14 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-05-20 19:54:14 +0000 |
commit | eb4fd3a539bd3268e93a2c51977e57f355e57395 (patch) | |
tree | 3bf6e3c0c6af058f36304691eb7b02bfc2fffe99 | |
parent | e92fd1991763436e32eb2ab5642eba6bfc51d185 (diff) |
fix the possibility of writing one byte past the end of a buffer.
(issue #7189, Mithraen)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@29053 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r-- | channels/chan_sip.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 50cf13fab..856fe2403 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -12121,10 +12121,11 @@ static int sipsock_read(int *id, int fd, short events, void *ignore) ast_log(LOG_WARNING, "Recv error: %s\n", strerror(errno)); return 1; } - if (option_debug && res == sizeof(req.data)) + if (option_debug && res == sizeof(req.data)) { ast_log(LOG_DEBUG, "Received packet exceeds buffer. Data is possibly lost\n"); - - req.data[res] = '\0'; + req.data[sizeof(req.data) - 1] = '\0'; + } else + req.data[res] = '\0'; req.len = res; if(sip_debug_test_addr(&sin)) /* Set the debug flag early on packet level */ ast_set_flag(&req, SIP_PKT_DEBUG); |