]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Fixes segfault occuring in chan_sip.c at __set_address_from_contact
authorJonathan Rose <jrose@digium.com>
Mon, 23 May 2011 14:33:20 +0000 (14:33 +0000)
committerJonathan Rose <jrose@digium.com>
Mon, 23 May 2011 14:33:20 +0000 (14:33 +0000)
Checks to see if domain contains anything before sending it off to ast_sockaddr_resolve
which is where the segfault was occuring due to null str.

(closes issue #18857)
Reported by: sybasesql

Review: https://reviewboard.asterisk.org/r/1225/

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@320504 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index 331427f5c9e11fe11e1a5ec0c82d85f557b9faca..c25b3742544281173ef2428a5e3c280607aa1288 100644 (file)
@@ -13326,6 +13326,13 @@ static int __set_address_from_contact(const char *fullcontact, struct ast_sockad
                assume that the domain part is a host name and only look for an A/AAAA record in DNS.
        */
 
+       /* If we took in an invalid URI, domain may not have been initialized */
+       /* ast_sockaddr_resolve requires an initialized domain string. */
+       if (ast_strlen_zero(domain)) {
+               ast_log(LOG_WARNING, "Invalid URI: parse_uri failed to acquire domain\n");
+               return -1;
+       }
+
        if (ast_sockaddr_resolve_first(addr, domain, 0)) {
                ast_log(LOG_WARNING, "Invalid host name in Contact: (can't "
                        "resolve in DNS) : '%s'\n", domain);