[vlc-devel] [PATCH] record: use vlc_mkstemp instead of tempnam
Lyndon Brown
jnqnfe at gmail.com
Sun Sep 27 22:30:20 CEST 2020
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" );
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 );
-------------- next part --------------
A non-text attachment was scrubbed...
Name: record_mkstemp.patch
Type: text/x-patch
Size: 1229 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20200927/9a79692a/attachment.bin>
More information about the vlc-devel
mailing list