[libdvdnav-devel] [PATCH] src/dvd_reader.c: Fix a potential NULL dereference

Jean-Baptiste Kempf jb at videolan.org
Fri Oct 24 04:06:16 CEST 2014


Hello,

On what platform does this crash?

Because printf of NULL usually displays (null) on most platfomrs.

On 24 Oct, Andrew Clayton wrote :
> In DVDOpen() one of the first things that is done is
> 
>     path = strdup(ppath);
> 
> path is then checked for NULL, if it is we jump to DVDOpen_error; where
> the first thing done is to print en error message using path. This bit
> of code is used as a general fall back so we don't want to stop
> displaying path in the cases where it isn't NULL.
> 
> The simplest solution is to simply put a guard on it in the fprintf
> statement, in the case that path is NULL use "" instead of path.
> 
> Signed-off-by: Andrew Clayton <andrew at digital-domain.net>
> ---
>  src/dvd_reader.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/dvd_reader.c b/src/dvd_reader.c
> index fb045b3..80b567d 100644
> --- a/src/dvd_reader.c
> +++ b/src/dvd_reader.c
> @@ -603,7 +603,7 @@ dvd_reader_t *DVDOpen( const char *ppath )
>  
>  DVDOpen_error:
>    /* If it's none of the above, screw it. */
> -  fprintf( stderr, "libdvdread: Could not open %s\n", path );
> +  fprintf( stderr, "libdvdread: Could not open %s\n", (path) ? path : "");
>    free( path );
>    free( path_copy );
>    if ( cdir >= 0 )
> -- 
> 1.9.3
> 
> _______________________________________________
> libdvdnav-devel mailing list
> libdvdnav-devel at videolan.org
> https://mailman.videolan.org/listinfo/libdvdnav-devel

-- 
With my kindest regards,

-- 
Jean-Baptiste Kempf
http://www.jbkempf.com/ - +33 672 704 734
Sent from my Electronic Device


More information about the libdvdnav-devel mailing list