mirror of
				https://github.com/asterisk/asterisk.git
				synced 2025-10-31 02:37:10 +00:00 
			
		
		
		
	r346525 | jrose | 2011-11-30 15:10:38 -0600 (Wed, 30 Nov 2011) | 18 lines
Cleaning up chan_sip/tcptls file descriptor closing. This patch attempts to eliminate various possible instances of undefined behavior caused by invoking close/fclose in situations where fclose may have already been issued on a tcptls_session_instance and/or closing file descriptors that don't have a valid index for fd (-1). Thanks for more than a little help from wdoekes. (closes issue ASTERISK-18700) Reported by: Erik Wallin (issue ASTERISK-18345) Reported by: Stephane Cazelas (issue ASTERISK-18342) Reported by: Stephane Chazelas Review: https://reviewboard.asterisk.org/r/1576/ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@346564 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
		| @@ -2793,14 +2793,7 @@ cleanup: | ||||
| 
 | ||||
| 	if (tcptls_session) { | ||||
| 		ast_mutex_lock(&tcptls_session->lock); | ||||
| 		if (tcptls_session->f) { | ||||
| 			fclose(tcptls_session->f); | ||||
| 			tcptls_session->f = NULL; | ||||
| 		} | ||||
| 		if (tcptls_session->fd != -1) { | ||||
| 			close(tcptls_session->fd); | ||||
| 			tcptls_session->fd = -1; | ||||
| 		} | ||||
| 		ast_tcptls_close_session_file(tcptls_session); | ||||
| 		tcptls_session->parent = NULL; | ||||
| 		ast_mutex_unlock(&tcptls_session->lock); | ||||
| 
 | ||||
| @@ -25288,8 +25281,8 @@ create_tcptls_session_fail: | ||||
| 		ao2_t_ref(ca, -1, "failed to create client, getting rid of client tcptls_session arguments"); | ||||
| 	} | ||||
| 	if (s->tcptls_session) { | ||||
| 		close(tcptls_session->fd); | ||||
| 		s->fd = tcptls_session->fd = -1; | ||||
| 		ast_tcptls_close_session_file(tcptls_session); | ||||
| 		s->fd = -1; | ||||
| 		ao2_ref(s->tcptls_session, -1); | ||||
| 		s->tcptls_session = NULL; | ||||
| 	} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user