diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-01-25 19:14:43 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-01-25 19:14:43 +0000 |
commit | 9840532e7a1a602f491d4bd9b10a5f10818d9976 (patch) | |
tree | b9642ee8db27388a205c0bd97bb1052b29d3171a /channels/chan_sip.c | |
parent | 40bbd46160d822ea58474bac68c08417bcfd0bab (diff) |
don't call ast_update_realtime with uninitialized variables if we get a
registration with an expirey of 0 seconds (issue #6173)
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.2@8677 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_sip.c')
-rw-r--r-- | channels/chan_sip.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 701d695de..80c2df5ce 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -1590,16 +1590,15 @@ static void realtime_update_peer(const char *peername, struct sockaddr_in *sin, { char port[10]; char ipaddr[20]; - char regseconds[20] = "0"; + char regseconds[20]; + time_t nowtime; + + time(&nowtime); + nowtime += expirey; + snprintf(regseconds, sizeof(regseconds), "%d", (int)nowtime); /* Expiration time */ + ast_inet_ntoa(ipaddr, sizeof(ipaddr), sin->sin_addr); + snprintf(port, sizeof(port), "%d", ntohs(sin->sin_port)); - if (expirey) { /* Registration */ - time_t nowtime; - time(&nowtime); - nowtime += expirey; - snprintf(regseconds, sizeof(regseconds), "%d", (int)nowtime); /* Expiration time */ - ast_inet_ntoa(ipaddr, sizeof(ipaddr), sin->sin_addr); - snprintf(port, sizeof(port), "%d", ntohs(sin->sin_port)); - } if (fullcontact) ast_update_realtime("sippeers", "name", peername, "ipaddr", ipaddr, "port", port, "regseconds", regseconds, "username", username, "fullcontact", fullcontact, NULL); else |