[vlc-devel] [PATCH] record: use vlc_mkstemp instead of tempnam
Steve Lhomme
robux4 at ycbcr.xyz
Mon Sep 28 07:48:37 CEST 2020
On 2020-09-27 22:30, Lyndon Brown wrote:
> attached. preview:
>
> From: Lyndon Brown <jnqnfe at gmail.com>
> Date: Fri, 29 Mar 2019 14:31:38 +0000
> Subject: record: use vlc_mkstemp instead of tempnam
>
> resolves compile warning about insecure function
>
> diff --git a/modules/stream_out/record.c b/modules/stream_out/record.c
> index ce2ce958e7..f205c610f6 100644
> --- a/modules/stream_out/record.c
> +++ b/modules/stream_out/record.c
> @@ -465,10 +465,20 @@ static void OutputStart( sout_stream_t *p_stream )
> char *psz_file;
> int i_es;
>
> - psz_file = tempnam( NULL, "vlc" );
> + psz_file = strdup( DIR_SEP"tmp"DIR_SEP"vlc-recording.XXXXXX" );
I'm pretty sure /tmp doesn't exist on Windows. And it will definitely
not be cleaned by the system when the user tells the OS to clean the
temporary files.
> if( !psz_file )
> continue;
>
> + int fd = vlc_mkstemp( psz_file );
> +
> + if( fd == -1 )
> + continue;
> +
> + /* FIXME: unlink after creation, we only want to create it here,
> + not hold it open since sout takes a path to open not an FD of
> + an already open file */
> + vlc_unlink( psz_file );
> +
> msg_Dbg( p_stream, "probing muxer %s", ppsz_muxers[i][0] );
> i_es = OutputNew( p_stream, ppsz_muxers[i][0], psz_file, NULL );
>
>
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
>
More information about the vlc-devel
mailing list