[vlc-devel] commit: Don't dereference strrchr without check (CID 185) ( Rémi Duraffort )
git version control
git at videolan.org
Fri Oct 10 23:20:30 CEST 2008
vlc | branch: 0.9-bugfix | Rémi Duraffort <ivoire at videolan.org> | Fri Oct 10 21:27:43 2008 +0200| [b07d67fff2a3425bfda3a025598398c8d72b1be4] | committer: Derk-Jan Hartman
Don't dereference strrchr without check (CID 185)
(cherry picked from commit eeaa54cf2c5d1dca043b6d655d5786d138b83503)
Signed-off-by: Derk-Jan Hartman <hartman at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b07d67fff2a3425bfda3a025598398c8d72b1be4
---
modules/access/rtmp/access.c | 5 ++++-
modules/access_output/rtmp.c | 5 ++++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/modules/access/rtmp/access.c b/modules/access/rtmp/access.c
index c0bf347..166262b 100644
--- a/modules/access/rtmp/access.c
+++ b/modules/access/rtmp/access.c
@@ -115,7 +115,10 @@ static int Open( vlc_object_t *p_this )
}
length_path = strlen( p_sys->p_thread->url.psz_path );
- length_media_name = strlen( strrchr( p_sys->p_thread->url.psz_path, '/' ) ) - 1;
+ char* psz_tmp = strrchr( p_sys->p_thread->url.psz_path, '/' );
+ if( !psz_tmp )
+ goto error;
+ length_media_name = strlen( psz_tmp ) - 1;
p_sys->p_thread->psz_application = strndup( p_sys->p_thread->url.psz_path + 1, length_path - length_media_name - 2 );
p_sys->p_thread->psz_media = strdup( p_sys->p_thread->url.psz_path + ( length_path - length_media_name ) );
diff --git a/modules/access_output/rtmp.c b/modules/access_output/rtmp.c
index ebf7175..c4aeeba 100644
--- a/modules/access_output/rtmp.c
+++ b/modules/access_output/rtmp.c
@@ -129,7 +129,10 @@ static int Open( vlc_object_t *p_this )
}
length_path = strlen( p_sys->p_thread->url.psz_path );
- length_media_name = strlen( strrchr( p_sys->p_thread->url.psz_path, '/' ) ) - 1;
+ char* psz_tmp = strrchr( p_sys->p_thread->url.psz_path, '/' );
+ if( !psz_tmp )
+ goto error;
+ length_media_name = strlen( psz_tmp ) - 1;
p_sys->p_thread->psz_application = strndup( p_sys->p_thread->url.psz_path + 1, length_path - length_media_name - 2 );
p_sys->p_thread->psz_media = strdup( p_sys->p_thread->url.psz_path + ( length_path - length_media_name ) );
More information about the vlc-devel
mailing list