[asterisk-commits] twilson: tag 1.8.3.1 r310985 - in /tags/1.8.3.1/main: manager.c tcptls.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Mar 16 13:45:46 CDT 2011


Author: twilson
Date: Wed Mar 16 13:45:42 2011
New Revision: 310985

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=310985
Log:
AST-2011-003 and AST-2011-004

Modified:
    tags/1.8.3.1/main/manager.c
    tags/1.8.3.1/main/tcptls.c

Modified: tags/1.8.3.1/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/tags/1.8.3.1/main/manager.c?view=diff&rev=310985&r1=310984&r2=310985
==============================================================================
--- tags/1.8.3.1/main/manager.c (original)
+++ tags/1.8.3.1/main/manager.c Wed Mar 16 13:45:42 2011
@@ -971,6 +971,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;
 };
@@ -1844,6 +1845,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) {
 		/*
@@ -1852,11 +1854,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;
 }
 
 /*!
@@ -4671,7 +4675,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;
 		}
 	}

Modified: tags/1.8.3.1/main/tcptls.c
URL: http://svnview.digium.com/svn/asterisk/tags/1.8.3.1/main/tcptls.c?view=diff&rev=310985&r1=310984&r2=310985
==============================================================================
--- tags/1.8.3.1/main/tcptls.c (original)
+++ tags/1.8.3.1/main/tcptls.c Wed Mar 16 13:45:42 2011
@@ -139,8 +139,12 @@
 	* open a FILE * as appropriate.
 	*/
 	if (!tcptls_session->parent->tls_cfg) {
-		tcptls_session->f = fdopen(tcptls_session->fd, "w+");
-		setvbuf(tcptls_session->f, NULL, _IONBF, 0);
+		if ((tcptls_session->f = fdopen(tcptls_session->fd, "w+"))) {
+			if(setvbuf(tcptls_session->f, NULL, _IONBF, 0)) {
+				fclose(tcptls_session->f);
+				tcptls_session->f = NULL;
+			}
+		}
 	}
 #ifdef DO_SSL
 	else if ( (tcptls_session->ssl = SSL_new(tcptls_session->parent->tls_cfg->ssl_ctx)) ) {




More information about the asterisk-commits mailing list