aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbbryant <bbryant@f38db490-d61c-443f-a65b-d21fe96a405b>2007-06-22 14:39:34 +0000
committerbbryant <bbryant@f38db490-d61c-443f-a65b-d21fe96a405b>2007-06-22 14:39:34 +0000
commit0226a0dbabf9096621aee55cb1e552dc64efbce8 (patch)
tree2198d914b8e0be521216853541efc288593856a5
parente26e3b17ab08d0653eb827e4c09e3190f06e38db (diff)
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 git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.2@71064 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--asterisk.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/asterisk.c b/asterisk.c
index 111dcf53d..83c7ed2c2 100644
--- a/asterisk.c
+++ b/asterisk.c
@@ -1816,6 +1816,9 @@ static void ast_remotecontrol(char * data)
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 @@ int main(int argc, char *argv[])
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 */