[asterisk-commits] rmudgett: branch certified-13.1 r433059 - in /certified/branches/13.1: ./ app...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Mar 17 16:56:25 CDT 2015


Author: rmudgett
Date: Tue Mar 17 16:56:23 2015
New Revision: 433059

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=433059
Log:
Audit ast_sockaddr_resolve() usage for memory leaks.

Valgrind found some memory leaks associated with ast_sockaddr_resolve().
Most of the leaks had already been fixed by earlier memory leak hunt
patches.  This patch performs an audit of ast_sockaddr_resolve() and found
one more.

* Fix ast_sockaddr_resolve() memory leak in
apps/app_externalivr.c:app_exec().

* Made main/netsock2.c:ast_sockaddr_resolve() always set the addrs
parameter for safety so the pointer will never be uninitialized on return.
The same goes for res/res_pjsip_acl.c:extract_contact_addr().

* Made functions that call ast_sockaddr_resolve() with RAII_VAR()
controlling the addrs variable use ast_free instead of ast_free_ptr to
provide better MALLOC_DEBUG information.

Review: https://reviewboard.asterisk.org/r/4509/
........

Merged revisions 433056 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 433057 from http://svn.asterisk.org/svn/asterisk/branches/13

Modified:
    certified/branches/13.1/   (props changed)
    certified/branches/13.1/apps/app_externalivr.c
    certified/branches/13.1/main/netsock2.c
    certified/branches/13.1/res/res_pjsip_acl.c
    certified/branches/13.1/res/res_pjsip_sdp_rtp.c
    certified/branches/13.1/res/res_pjsip_t38.c

Propchange: certified/branches/13.1/
------------------------------------------------------------------------------
Binary property 'branch-13-merged' - no diff available.

Modified: certified/branches/13.1/apps/app_externalivr.c
URL: http://svnview.digium.com/svn/asterisk/certified/branches/13.1/apps/app_externalivr.c?view=diff&rev=433059&r1=433058&r2=433059
==============================================================================
--- certified/branches/13.1/apps/app_externalivr.c (original)
+++ certified/branches/13.1/apps/app_externalivr.c Tue Mar 17 16:56:23 2015
@@ -519,6 +519,8 @@
 			}
 			break;
 		}
+
+		ast_free(addrs);
 
 		if (i == num_addrs) {
 			ast_chan_log(LOG_ERROR, chan, "Could not connect to any host.  ExternalIVR failed.\n");

Modified: certified/branches/13.1/main/netsock2.c
URL: http://svnview.digium.com/svn/asterisk/certified/branches/13.1/main/netsock2.c?view=diff&rev=433059&r1=433058&r2=433059
==============================================================================
--- certified/branches/13.1/main/netsock2.c (original)
+++ certified/branches/13.1/main/netsock2.c Tue Mar 17 16:56:23 2015
@@ -287,11 +287,13 @@
 	int	e, i, res_cnt;
 
 	if (!str) {
+		*addrs = NULL;
 		return 0;
 	}
 
 	s = ast_strdupa(str);
 	if (!ast_sockaddr_split_hostport(s, &host, &port, flags)) {
+		*addrs = NULL;
 		return 0;
 	}
 
@@ -302,6 +304,7 @@
 	if ((e = getaddrinfo(host, port, &hints, &res))) {
 		ast_log(LOG_ERROR, "getaddrinfo(\"%s\", \"%s\", ...): %s\n",
 			host, S_OR(port, "(null)"), gai_strerror(e));
+		*addrs = NULL;
 		return 0;
 	}
 
@@ -311,6 +314,7 @@
 	}
 
 	if (res_cnt == 0) {
+		*addrs = NULL;
 		goto cleanup;
 	}
 

Modified: certified/branches/13.1/res/res_pjsip_acl.c
URL: http://svnview.digium.com/svn/asterisk/certified/branches/13.1/res/res_pjsip_acl.c?view=diff&rev=433059&r1=433058&r2=433059
==============================================================================
--- certified/branches/13.1/res/res_pjsip_acl.c (original)
+++ certified/branches/13.1/res/res_pjsip_acl.c Tue Mar 17 16:56:23 2015
@@ -139,9 +139,11 @@
 	char host[256];
 
 	if (!contact || contact->star) {
+		*addrs = NULL;
 		return 0;
 	}
 	if (!PJSIP_URI_SCHEME_IS_SIP(contact->uri) && !PJSIP_URI_SCHEME_IS_SIPS(contact->uri)) {
+		*addrs = NULL;
 		return 0;
 	}
 	sip_uri = pjsip_uri_get_uri(contact->uri);

Modified: certified/branches/13.1/res/res_pjsip_sdp_rtp.c
URL: http://svnview.digium.com/svn/asterisk/certified/branches/13.1/res/res_pjsip_sdp_rtp.c?view=diff&rev=433059&r1=433058&r2=433059
==============================================================================
--- certified/branches/13.1/res/res_pjsip_sdp_rtp.c (original)
+++ certified/branches/13.1/res/res_pjsip_sdp_rtp.c Tue Mar 17 16:56:23 2015
@@ -760,7 +760,7 @@
 					 const struct pjmedia_sdp_session *sdp, const struct pjmedia_sdp_media *stream)
 {
 	char host[NI_MAXHOST];
-	RAII_VAR(struct ast_sockaddr *, addrs, NULL, ast_free_ptr);
+	RAII_VAR(struct ast_sockaddr *, addrs, NULL, ast_free);
 	enum ast_media_type media_type = stream_to_media_type(session_media->stream_type);
 	enum ast_sip_session_media_encryption encryption = AST_SIP_MEDIA_ENCRYPT_NONE;
 	int res;
@@ -1117,7 +1117,7 @@
 				       const struct pjmedia_sdp_session *local, const struct pjmedia_sdp_media *local_stream,
 				       const struct pjmedia_sdp_session *remote, const struct pjmedia_sdp_media *remote_stream)
 {
-	RAII_VAR(struct ast_sockaddr *, addrs, NULL, ast_free_ptr);
+	RAII_VAR(struct ast_sockaddr *, addrs, NULL, ast_free);
 	enum ast_media_type media_type = stream_to_media_type(session_media->stream_type);
 	char host[NI_MAXHOST];
 	int fdno, res;

Modified: certified/branches/13.1/res/res_pjsip_t38.c
URL: http://svnview.digium.com/svn/asterisk/certified/branches/13.1/res/res_pjsip_t38.c?view=diff&rev=433059&r1=433058&r2=433059
==============================================================================
--- certified/branches/13.1/res/res_pjsip_t38.c (original)
+++ certified/branches/13.1/res/res_pjsip_t38.c Tue Mar 17 16:56:23 2015
@@ -617,7 +617,7 @@
 {
 	struct t38_state *state;
 	char host[NI_MAXHOST];
-	RAII_VAR(struct ast_sockaddr *, addrs, NULL, ast_free_ptr);
+	RAII_VAR(struct ast_sockaddr *, addrs, NULL, ast_free);
 
 	if (!session->endpoint->media.t38.enabled) {
 		return -1;
@@ -760,7 +760,7 @@
 				       const struct pjmedia_sdp_session *local, const struct pjmedia_sdp_media *local_stream,
 				       const struct pjmedia_sdp_session *remote, const struct pjmedia_sdp_media *remote_stream)
 {
-	RAII_VAR(struct ast_sockaddr *, addrs, NULL, ast_free_ptr);
+	RAII_VAR(struct ast_sockaddr *, addrs, NULL, ast_free);
 	char host[NI_MAXHOST];
 	struct t38_state *state;
 




More information about the asterisk-commits mailing list