[asterisk-commits] bbryant: branch 1.2 r71064 - /branches/1.2/asterisk.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jun 22 09:39:34 CDT 2007


Author: bbryant
Date: Fri Jun 22 09:39:34 2007
New Revision: 71064

URL: http://svn.digium.com/view/asterisk?view=rev&rev=71064
Log:
Fixed infinite loop when controlling terminal was lost
and return value of input function wasn't checked for
errors. This would cause 100% cpu to be taken up.

(closes issue #9654, issue #10010)
Reported by: mnicholson, and eserra

Idea for the patch from mnicholson, patched by me


Modified:
    branches/1.2/asterisk.c

Modified: branches/1.2/asterisk.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/asterisk.c?view=diff&rev=71064&r1=71063&r2=71064
==============================================================================
--- branches/1.2/asterisk.c (original)
+++ branches/1.2/asterisk.c Fri Jun 22 09:39:34 2007
@@ -1816,6 +1816,9 @@
 	for(;;) {
 		ebuf = (char *)el_gets(el, &num);
 
+		if (!ebuf)
+			break;
+
 		if (!ast_strlen_zero(ebuf)) {
 			if (ebuf[strlen(ebuf)-1] == '\n')
 				ebuf[strlen(ebuf)-1] = '\0';
@@ -2457,12 +2460,15 @@
 
 		for (;;) {
 			buf = (char *)el_gets(el, &num);
-			if (buf) {
-				if (buf[strlen(buf)-1] == '\n')
-					buf[strlen(buf)-1] = '\0';
-
-				consolehandler((char *)buf);
-			} else if (option_remote) {
+
+			if (!buf)
+				break;
+
+			if (buf[strlen(buf)-1] == '\n')
+				buf[strlen(buf)-1] = '\0';
+
+			consolehandler((char *)buf);
+			if (!buf && option_remote) {
 				if (write(STDOUT_FILENO, "\nUse EXIT or QUIT to exit the asterisk console\n",
 					  strlen("\nUse EXIT or QUIT to exit the asterisk console\n")) < 0) {
 					/* Whoa, stdout disappeared from under us... Make /dev/null's */




More information about the asterisk-commits mailing list