[svn-commits] twilson: trunk r311000 - in /trunk: ./ main/manager.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Mar 16 14:51:08 CDT 2011


Author: twilson
Date: Wed Mar 16 14:51:04 2011
New Revision: 311000

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=311000
Log:
Merged revisions 310993 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.8

................
  r310993 | twilson | 2011-03-16 14:26:57 -0500 (Wed, 16 Mar 2011) | 11 lines
  
  Merged revisions 310992 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.6.2
  
  ........
    r310992 | twilson | 2011-03-16 14:23:03 -0500 (Wed, 16 Mar 2011) | 4 lines
    
    Don't keep trying to write to a closed connection
    
    See security advisory AST-2011-003.
  ........
................

Modified:
    trunk/   (props changed)
    trunk/main/manager.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.

Modified: trunk/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/manager.c?view=diff&rev=311000&r1=310999&r2=311000
==============================================================================
--- trunk/main/manager.c (original)
+++ trunk/main/manager.c Wed Mar 16 14:51:04 2011
@@ -962,6 +962,7 @@
 	struct ast_tcptls_session_instance *tcptls_session;
 	FILE *f;
 	int fd;
+	int write_error:1;
 	struct manager_custom_hook *hook;
 	ast_mutex_t lock;
 };
@@ -1835,6 +1836,7 @@
  */
 static int send_string(struct mansession *s, char *string)
 {
+	int res;
 	/* It's a result from one of the hook's action invocation */
 	if (s->hook) {
 		/*
@@ -1843,11 +1845,13 @@
 		 */
 		s->hook->helper(EVENT_FLAG_HOOKRESPONSE, "HookResponse", string);
 		return 0;
-	} else if (s->f) {
-		return ast_careful_fwrite(s->f, s->fd, string, strlen(string), s->session->writetimeout);
-	} else {
-		return ast_careful_fwrite(s->session->f, s->session->fd, string, strlen(string), s->session->writetimeout);
-	}
+	}	else if (s->f && (res = ast_careful_fwrite(s->f, s->fd, string, strlen(string), s->session->writetimeout))) {
+		s->write_error = 1;
+	} else if ((res = ast_careful_fwrite(s->session->f, s->session->fd, string, strlen(string), s->session->writetimeout))) {
+		s->write_error = 1;
+	}
+
+	return res;
 }
 
 /*!
@@ -4686,7 +4690,7 @@
 	ao2_unlock(session);
 	astman_append(&s, "Asterisk Call Manager/%s\r\n", AMI_VERSION);	/* welcome prompt */
 	for (;;) {
-		if ((res = do_message(&s)) < 0) {
+		if ((res = do_message(&s)) < 0 || s.write_error) {
 			break;
 		}
 	}




More information about the svn-commits mailing list