From 24e788fc4ce97ff643eac815cef3847a7a82bd70 Mon Sep 17 00:00:00 2001 From: reimar Date: Wed, 2 Sep 2009 10:10:42 +0000 Subject: Change real_setup_and_get_header to use goto a single exit path to simplify proper freeing of allocated data. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29619 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/realrtsp/real.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'stream') diff --git a/stream/realrtsp/real.c b/stream/realrtsp/real.c index 5b9fabe7f7..ed3ad2d365 100644 --- a/stream/realrtsp/real.c +++ b/stream/realrtsp/real.c @@ -427,11 +427,11 @@ rmff_header_t *real_setup_and_get_header(rtsp_t *rtsp_session, uint32_t bandwidt char *description=NULL; char *session_id=NULL; - rmff_header_t *h; + rmff_header_t *h = NULL; char *challenge1; char challenge2[41]; char checksum[9]; - char *subscribe; + char *subscribe = NULL; char *buf = xbuffer_init(256); char *mrl=rtsp_get_mrl(rtsp_session); unsigned int size; @@ -513,8 +513,7 @@ autherr: alert); } rtsp_send_ok(rtsp_session); - buf = xbuffer_free(buf); - return NULL; + goto out; } /* receive description */ @@ -528,8 +527,7 @@ autherr: if (size > MAX_DESC_BUF) { mp_msg(MSGT_STREAM, MSGL_ERR, "realrtsp: Content-length for description too big (> %uMB)!\n", MAX_DESC_BUF/(1024*1024) ); - xbuffer_free(buf); - return NULL; + goto out; } if (!rtsp_search_answers(rtsp_session,"ETag")) @@ -544,8 +542,7 @@ autherr: description=malloc(size+1); if( rtsp_read_data(rtsp_session, description, size) <= 0) { - buf = xbuffer_free(buf); - return NULL; + goto out; } description[size]=0; @@ -554,9 +551,7 @@ autherr: strcpy(subscribe, "Subscribe: "); h=real_parse_sdp(description, &subscribe, bandwidth); if (!h) { - subscribe = xbuffer_free(subscribe); - buf = xbuffer_free(buf); - return NULL; + goto out; } rmff_fix_header(h); @@ -619,6 +614,7 @@ autherr: /* and finally send a play request */ rtsp_request_play(rtsp_session,NULL); +out: subscribe = xbuffer_free(subscribe); buf = xbuffer_free(buf); return h; -- cgit v1.2.3 From 5c4a06530d13948b68e1acb34868bf80021be1aa Mon Sep 17 00:00:00 2001 From: reimar Date: Wed, 2 Sep 2009 10:20:45 +0000 Subject: Fix several memleaks in real_setup_and_get_header git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29620 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/realrtsp/real.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'stream') diff --git a/stream/realrtsp/real.c b/stream/realrtsp/real.c index ed3ad2d365..dd0f5d4461 100644 --- a/stream/realrtsp/real.c +++ b/stream/realrtsp/real.c @@ -428,7 +428,7 @@ rmff_header_t *real_setup_and_get_header(rtsp_t *rtsp_session, uint32_t bandwidt char *description=NULL; char *session_id=NULL; rmff_header_t *h = NULL; - char *challenge1; + char *challenge1 = NULL; char challenge2[41]; char checksum[9]; char *subscribe = NULL; @@ -617,6 +617,9 @@ autherr: out: subscribe = xbuffer_free(subscribe); buf = xbuffer_free(buf); + free(description); + free(session_id); + free(challenge1); return h; } -- cgit v1.2.3 From 079a64ae8d93cb30adedbd1ebd4a40b36e805a99 Mon Sep 17 00:00:00 2001 From: reimar Date: Wed, 2 Sep 2009 10:22:08 +0000 Subject: Make sure we do not strdup(NULL), avoids a crash with non-real streams. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29621 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/realrtsp/real.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'stream') diff --git a/stream/realrtsp/real.c b/stream/realrtsp/real.c index dd0f5d4461..a5b37f6e34 100644 --- a/stream/realrtsp/real.c +++ b/stream/realrtsp/real.c @@ -441,7 +441,10 @@ rmff_header_t *real_setup_and_get_header(rtsp_t *rtsp_session, uint32_t bandwidt int i; /* get challenge */ - challenge1=strdup(rtsp_search_answers(rtsp_session,"RealChallenge1")); + challenge1=rtsp_search_answers(rtsp_session,"RealChallenge1"); + if (!challenge1) + goto out; + challenge1=strdup(challenge1); #ifdef LOG printf("real: Challenge1: %s\n", challenge1); #endif -- cgit v1.2.3 From 3351bc2d1807ad88d9871933819f8220d0f9d365 Mon Sep 17 00:00:00 2001 From: reimar Date: Wed, 2 Sep 2009 10:28:08 +0000 Subject: Move variable declaration to where it is used. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29622 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/librtsp/rtsp_session.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'stream') diff --git a/stream/librtsp/rtsp_session.c b/stream/librtsp/rtsp_session.c index 8b87d7fb41..72734e8776 100644 --- a/stream/librtsp/rtsp_session.c +++ b/stream/librtsp/rtsp_session.c @@ -106,7 +106,6 @@ rtsp_session_t *rtsp_session_start(int fd, char **mrl, char *path, char *host, rtsp_session_t *rtsp_session = NULL; char *server; char *mrl_line = NULL; - rmff_header_t *h; rtsp_session = malloc (sizeof (rtsp_session_t)); rtsp_session->s = NULL; @@ -138,7 +137,7 @@ rtsp_session_t *rtsp_session_start(int fd, char **mrl, char *path, char *host, { /* we are talking to a real server ... */ - h=real_setup_and_get_header(rtsp_session->s, bandwidth, user, pass); + rmff_header_t *h=real_setup_and_get_header(rtsp_session->s, bandwidth, user, pass); if (!h) { /* got an redirect? */ if (rtsp_search_answers(rtsp_session->s, RTSP_OPTIONS_LOCATION)) -- cgit v1.2.3 From 2726fe03ec8e0474c77765a53548fdc6b06926c4 Mon Sep 17 00:00:00 2001 From: reimar Date: Wed, 2 Sep 2009 10:35:06 +0000 Subject: Use calloc to ensure rmff_new_mdpr returns fully initialized data. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29623 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/realrtsp/rmff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'stream') diff --git a/stream/realrtsp/rmff.c b/stream/realrtsp/rmff.c index c4430de145..3221df9dad 100644 --- a/stream/realrtsp/rmff.c +++ b/stream/realrtsp/rmff.c @@ -570,7 +570,7 @@ rmff_mdpr_t *rmff_new_mdpr( uint32_t type_specific_len, const char *type_specific_data ) { - rmff_mdpr_t *mdpr=malloc(sizeof(rmff_mdpr_t)); + rmff_mdpr_t *mdpr=calloc(sizeof(rmff_mdpr_t),1); mdpr->object_id=MDPR_TAG; mdpr->object_version=0; -- cgit v1.2.3 From 70a247b26dac9e2153b62b8aab78799cd2996af6 Mon Sep 17 00:00:00 2001 From: reimar Date: Wed, 2 Sep 2009 10:37:32 +0000 Subject: Fix asmrp_dispose to also free the buffer. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29624 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/realrtsp/asmrp.c | 1 + 1 file changed, 1 insertion(+) (limited to 'stream') diff --git a/stream/realrtsp/asmrp.c b/stream/realrtsp/asmrp.c index d4f7ce8267..699f14c159 100644 --- a/stream/realrtsp/asmrp.c +++ b/stream/realrtsp/asmrp.c @@ -116,6 +116,7 @@ static void asmrp_dispose (asmrp_t *p) { for (i=0; isym_tab_num; i++) free (p->sym_tab[i].id); + free(p->buf); free (p); } -- cgit v1.2.3 From ac11b35a6a90fd121fb51ac4b808523f7dc7871a Mon Sep 17 00:00:00 2001 From: reimar Date: Wed, 2 Sep 2009 10:44:26 +0000 Subject: Fix several more rtsp-related memleaks. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29625 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/librtsp/rtsp_session.c | 2 ++ stream/realrtsp/real.c | 2 +- stream/realrtsp/sdpplin.c | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) (limited to 'stream') diff --git a/stream/librtsp/rtsp_session.c b/stream/librtsp/rtsp_session.c index 72734e8776..72b8a2a607 100644 --- a/stream/librtsp/rtsp_session.c +++ b/stream/librtsp/rtsp_session.c @@ -94,6 +94,7 @@ static void rtsp_close(rtsp_t *s) { if (s->mrl) free(s->mrl); if (s->session) free(s->session); if (s->user_agent) free(s->user_agent); + free(s->server); rtsp_free_answers(s); rtsp_unschedule_all(s); free(s); @@ -194,6 +195,7 @@ rtsp_session_t *rtsp_session_start(int fd, char **mrl, char *path, char *host, rtsp_session->real_session->header_len; } rtsp_session->real_session->recv_read = 0; + rmff_free_header(h); } else /* not a Real server : try RTP instead */ { char *public = NULL; diff --git a/stream/realrtsp/real.c b/stream/realrtsp/real.c index a5b37f6e34..29c88335be 100644 --- a/stream/realrtsp/real.c +++ b/stream/realrtsp/real.c @@ -249,7 +249,7 @@ static rmff_header_t *real_parse_sdp(char *data, char **stream_rules, uint32_t b if (!desc->stream[i]->mlti_data) { len = 0; - buf = NULL; + buf = xbuffer_free(buf); } else len=select_mlti_data(desc->stream[i]->mlti_data, desc->stream[i]->mlti_data_size, rulematches[0], &buf); diff --git a/stream/realrtsp/sdpplin.c b/stream/realrtsp/sdpplin.c index c4104fb00c..9669b085fd 100644 --- a/stream/realrtsp/sdpplin.c +++ b/stream/realrtsp/sdpplin.c @@ -376,6 +376,7 @@ void sdpplin_free(sdpplin_t *description) { free(description->stream[i]->mlti_data); if (description->stream[i]->asm_rule_book) free(description->stream[i]->asm_rule_book); + free(description->stream[i]->id); free(description->stream[i]); } } -- cgit v1.2.3 From d1e7b4dc6f7dedea721e699827ae41d23d9d0e97 Mon Sep 17 00:00:00 2001 From: reimar Date: Wed, 2 Sep 2009 10:55:36 +0000 Subject: Fix possible crashes with invalid SDPs that result in stream descriptions not being initialized. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@29626 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/librtsp/rtsp_session.c | 3 ++- stream/realrtsp/real.c | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'stream') diff --git a/stream/librtsp/rtsp_session.c b/stream/librtsp/rtsp_session.c index 72b8a2a607..33c36f15b9 100644 --- a/stream/librtsp/rtsp_session.c +++ b/stream/librtsp/rtsp_session.c @@ -139,7 +139,8 @@ rtsp_session_t *rtsp_session_start(int fd, char **mrl, char *path, char *host, /* we are talking to a real server ... */ rmff_header_t *h=real_setup_and_get_header(rtsp_session->s, bandwidth, user, pass); - if (!h) { + if (!h || !h->streams[0]) { + rmff_free_header(h); /* got an redirect? */ if (rtsp_search_answers(rtsp_session->s, RTSP_OPTIONS_LOCATION)) { diff --git a/stream/realrtsp/real.c b/stream/realrtsp/real.c index 29c88335be..0206833301 100644 --- a/stream/realrtsp/real.c +++ b/stream/realrtsp/real.c @@ -235,6 +235,8 @@ static rmff_header_t *real_parse_sdp(char *data, char **stream_rules, uint32_t b char b[64]; int rulematches[MAX_RULEMATCHES]; + if (!desc->stream[i]) + continue; #ifdef LOG printf("calling asmrp_match with:\n%s\n%u\n", desc->stream[i]->asm_rule_book, bandwidth); #endif -- cgit v1.2.3