diff options
author | Richard Mudgett <rmudgett@digium.com> | 2015-03-17 21:49:30 +0000 |
---|---|---|
committer | Richard Mudgett <rmudgett@digium.com> | 2015-03-17 21:49:30 +0000 |
commit | 2122c205e677a0da93b582b148b6495b660e1e6d (patch) | |
tree | 7c8b7db988c167cc9b15006a010be15b64211082 /res | |
parent | 94fe4a91781e8f21936cb382c8ecedf1bead44c1 (diff) |
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
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@433057 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res')
-rw-r--r-- | res/res_pjsip_acl.c | 2 | ||||
-rw-r--r-- | res/res_pjsip_sdp_rtp.c | 4 | ||||
-rw-r--r-- | res/res_pjsip_t38.c | 4 |
3 files changed, 6 insertions, 4 deletions
diff --git a/res/res_pjsip_acl.c b/res/res_pjsip_acl.c index ec9f3ae27..a04f2b422 100644 --- a/res/res_pjsip_acl.c +++ b/res/res_pjsip_acl.c @@ -139,9 +139,11 @@ static int extract_contact_addr(pjsip_contact_hdr *contact, struct ast_sockaddr 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); diff --git a/res/res_pjsip_sdp_rtp.c b/res/res_pjsip_sdp_rtp.c index 63a78caa8..e55e255c4 100644 --- a/res/res_pjsip_sdp_rtp.c +++ b/res/res_pjsip_sdp_rtp.c @@ -758,7 +758,7 @@ static int negotiate_incoming_sdp_stream(struct ast_sip_session *session, struct 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; @@ -1115,7 +1115,7 @@ static int apply_negotiated_sdp_stream(struct ast_sip_session *session, struct a 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; diff --git a/res/res_pjsip_t38.c b/res/res_pjsip_t38.c index d91d370d6..029867137 100644 --- a/res/res_pjsip_t38.c +++ b/res/res_pjsip_t38.c @@ -619,7 +619,7 @@ static int negotiate_incoming_sdp_stream(struct ast_sip_session *session, struct { 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; @@ -762,7 +762,7 @@ static int apply_negotiated_sdp_stream(struct ast_sip_session *session, struct a 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; |