[vlc-devel] [PATCH] record: use vlc_mkstemp instead of tempnam

Alexandre Janniaux ajanni at videolabs.io
Mon Sep 28 09:11:37 CEST 2020


Hi,

On Mon, Sep 28, 2020 at 07:48:37AM +0200, Steve Lhomme wrote:
> 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.

I'm not sure hardcoding path is a good idea either on POSIX.
There's no concept of the OS cleaning up the temporary files
but there are either allocated on memory-backed filesystem and
thus not persistent or cleaned up by a service like systemd.

> >               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
> >
> _______________________________________________
> 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