]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Prevent a crash when dialing a technology with no destination (ex: Dial(SIP/))
authorJason Parker <jparker@digium.com>
Mon, 31 Jan 2011 22:56:54 +0000 (22:56 +0000)
committerJason Parker <jparker@digium.com>
Mon, 31 Jan 2011 22:56:54 +0000 (22:56 +0000)
chan_iax2 and other channel drivers already had code to prevent this.  The
attempt that app_dial was making to prevent it was not correct, so I fixed that.

(closes issue #18371)
Reported by: gbour
Patches:
      18371.patch uploaded by gbour (license 1162)

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

apps/app_dial.c
channels/chan_sip.c

index 8f77b9c4a9711c4566f98245696012283772ff65..3f0c67082a39acb1c9f0205226a5950ceeda36f8 100644 (file)
@@ -1224,7 +1224,7 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
                struct ast_dialed_interface *di;
                AST_LIST_HEAD(, ast_dialed_interface) *dialed_interfaces;
                num_dialed++;
-               if (!number) {
+               if (ast_strlen_zero(number)) {
                        ast_log(LOG_WARNING, "Dial argument takes format (technology/[device:]number1)\n");
                        goto out;
                }
index 4f60e4369e014e72a9c3bfdc3439716b09ccdd2b..a38297ca2962e58535144d851e47a954015240ad 100644 (file)
@@ -18014,6 +18014,12 @@ static struct ast_channel *sip_request_call(const char *type, int format, void *
        if (option_debug)
                ast_log(LOG_DEBUG, "Asked to create a SIP channel with formats: %s\n", ast_getformatname_multiple(tmp, sizeof(tmp), oldformat));
 
+       if (ast_strlen_zero(dest)) {
+               ast_log(LOG_ERROR, "Unable to create channel with empty destination.\n");
+               *cause = AST_CAUSE_CHANNEL_UNACCEPTABLE;
+               return NULL;
+       }
+
        if (!(p = sip_alloc(NULL, NULL, 0, SIP_INVITE))) {
                ast_log(LOG_ERROR, "Unable to build sip pvt data for '%s' (Out of memory or socket error)\n", (char *)data);
                *cause = AST_CAUSE_SWITCH_CONGESTION;