[asterisk-commits] mmichelson: branch 1.6.1 r160628 - in /branches/1.6.1: ./ apps/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Dec 3 12:42:02 CST 2008


Author: mmichelson
Date: Wed Dec  3 12:42:01 2008
New Revision: 160628

URL: http://svn.digium.com/view/asterisk?view=rev&rev=160628
Log:
Merged revisions 160626 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

........
r160626 | mmichelson | 2008-12-03 12:37:46 -0600 (Wed, 03 Dec 2008) | 16 lines

Add some safety measures when using gosub, especially when using the options
for app_dial and app_queue to run a gosub when the call is answered.

* Check for the existence of the gosub target in gosub_exec. If it is nonexistent,
  then this will cause errors when we attempt to actually run the gosub, including
  a definite memory leak and potential crashes. Return an error in this situation
* Check the return value of pbx_exec in app_dial and app_queue before attempting
  to actually run the gosub routine. If there was an error, we should not attempt
  to run the gosub.
* Change a '|' to a ',' in app_queue.
* Add some extra curly braces where they had been missing previously.

(closes issue #13548)
Reported by: fiddur


........

Modified:
    branches/1.6.1/   (props changed)
    branches/1.6.1/apps/app_dial.c
    branches/1.6.1/apps/app_queue.c
    branches/1.6.1/apps/app_stack.c

Propchange: branches/1.6.1/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.1/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.1/apps/app_dial.c?view=diff&rev=160628&r1=160627&r2=160628
==============================================================================
--- branches/1.6.1/apps/app_dial.c (original)
+++ branches/1.6.1/apps/app_dial.c Wed Dec  3 12:42:01 2008
@@ -1873,14 +1873,16 @@
 
 				if (gosub_args) {
 					res9 = pbx_exec(peer, theapp, gosub_args);
-					ast_pbx_run(peer);
+					if (!res9) {
+						ast_pbx_run(peer);
+					}
 					ast_free(gosub_args);
 					if (option_debug)
 						ast_log(LOG_DEBUG, "Gosub exited with status %d\n", res9);
-				} else
+				} else {
 					ast_log(LOG_ERROR, "Could not Allocate string for Gosub arguments -- Gosub Call Aborted!\n");
-
-				res9 = 0;
+				}
+
 			} else if (!res9) {
 				ast_log(LOG_ERROR, "Could not find application Gosub\n");
 				res9 = -1;

Modified: branches/1.6.1/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.1/apps/app_queue.c?view=diff&rev=160628&r1=160627&r2=160628
==============================================================================
--- branches/1.6.1/apps/app_queue.c (original)
+++ branches/1.6.1/apps/app_queue.c Wed Dec  3 12:42:01 2008
@@ -3839,7 +3839,7 @@
 						ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
 						gosub_args = NULL;
 					}
-					*gosub_argstart = '|';
+					*gosub_argstart = ',';
 				} else {
 					if (asprintf(&gosub_args, "%s,s,1", gosubexec) < 0) {
 						ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
@@ -3848,13 +3848,14 @@
 				}
 				if (gosub_args) {
 					res = pbx_exec(peer, application, gosub_args);
-					ast_pbx_run(peer);
+					if (!res) {
+						ast_pbx_run(peer);
+					}
 					free(gosub_args);
 					ast_debug(1, "Gosub exited with status %d\n", res);
-				} else
+				} else {
 					ast_log(LOG_ERROR, "Could not Allocate string for Gosub arguments -- Gosub Call Aborted!\n");
-				
-				res = 0;
+				}
 			} else {
 				ast_log(LOG_ERROR, "Could not find application Gosub\n");
 				res = -1;

Modified: branches/1.6.1/apps/app_stack.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.1/apps/app_stack.c?view=diff&rev=160628&r1=160627&r2=160628
==============================================================================
--- branches/1.6.1/apps/app_stack.c (original)
+++ branches/1.6.1/apps/app_stack.c Wed Dec  3 12:42:01 2008
@@ -272,11 +272,22 @@
 	/* Create the return address, but don't save it until we know that the Gosub destination exists */
 	newframe = gosub_allocate_frame(chan->context, chan->exten, chan->priority + 1, args2.argc);
 
-	if (!newframe)
-		return -1;
+	if (!newframe) {
+		return -1;
+	}
 
 	if (ast_parseable_goto(chan, label)) {
 		ast_log(LOG_ERROR, "Gosub address is invalid: '%s'\n", (char *)data);
+		ast_free(newframe);
+		return -1;
+	}
+
+	if (!ast_exists_extension(chan, chan->context, chan->exten, chan->priority, chan->cid.cid_num)) {
+		ast_log(LOG_ERROR, "Attempt to reach a non-existent destination for gosub: (Context:%s, Extension:%s, Priority:%d)\n",
+				chan->context, chan->exten, chan->priority);
+		ast_copy_string(chan->context, newframe->context, sizeof(chan->context));
+		ast_copy_string(chan->exten, newframe->extension, sizeof(chan->exten));
+		chan->priority = newframe->priority;
 		ast_free(newframe);
 		return -1;
 	}




More information about the asterisk-commits mailing list