Репозитории ALT
S: | 3.2.8-alt1 |
5.1: | 3.2.1-alt3 |
4.1: | 3.2.1-alt3 |
4.0: | 3.2.1-alt1 |
3.0: | 3.1.6a-alt4 |
Группа :: Звук
Пакет: mikmod
Главная Изменения Спек Патчи Sources Загрузить Gear Bugs and FR Repocop
Патч: mikmod-3.1.6-tmpfile.patch
Скачать
Скачать
--- mikmod-3.1.6-a/src/marchive.c~ Mon Aug 2 07:59:23 1999
+++ mikmod-3.1.6-a/src/marchive.c Fri Jan 19 10:52:39 2001
@@ -341,14 +341,16 @@
/* Extracts the file 'file' from the archive 'arc' */
CHAR* MA_dearchive(CHAR* arc,CHAR* file)
{
- int t;
+ int t, fd;
CHAR *tmp_file;
/* not an archive file... */
if ((!arc)||(!arc[0]))
return strdup(file);
- tmp_file=get_tmp_name();
+ tmp_file = get_tmp_name( &fd );
+ if ( fd < 0 )
+ return 0;
for (t=0;MA_archiver[t].command;t++)
if (MA_identify(arc,MA_archiver[t].location,MA_archiver[t].marker)) {
@@ -388,10 +390,12 @@
/* extracting, the Unix way */
{
pid_t pid;
- int status,fd;
+ int status;
switch (pid=fork()) {
case -1: /* fork failed */
+ close( fd );
+ free( tmp_file );
return NULL;
break;
case 0: /* fork succeeded, child process code */
@@ -422,9 +426,11 @@
exit(0);
break;
default: /* fork succeeded, main process code */
+ close( fd );
waitpid(pid,&status,0);
if (!WIFEXITED(status)) {
unlink(tmp_file);
+ free( tmp_file );
return NULL;
}
break;
--- mikmod-3.1.6-a/src/mutilities.c~ Mon Aug 2 07:59:23 1999
+++ mikmod-3.1.6-a/src/mutilities.c Fri Jan 19 10:49:04 2001
@@ -82,19 +82,27 @@
return (*path!=PATH_SEP);
}
+extern const char *__progname;
+
/* allocate and return a name for a temporary file */
-char *get_tmp_name(void)
+char *get_tmp_name( int *fd )
{
-#if defined(__OS2__) && defined(__WATCOMC__)
- return str_sprintf2("%s" PATH_SEP_STR "%s",getenv("TEMP"),"!MikMod.tmp");
-#else
- CHAR *tmp_file;
+ const char suffix[] = ".XXXXXX";
+ const char *tmp_dir = getenv( "TMPDIR" ) ?: P_tmpdir;
+ unsigned tmp_len = strlen( tmp_dir );
+ unsigned prog_len = strlen( __progname );
+ char buf[ tmp_len + prog_len + sizeof(suffix) + 1 ];
- if (!(tmp_file=tempnam(NULL,".mod")))
- if (!(tmp_file=tempnam(getenv("HOME"),".mod")))
- return NULL;
- return tmp_file;
-#endif
+ memcpy( buf, tmp_dir, tmp_len );
+ buf[ tmp_len ] = '/';
+ memcpy( buf + tmp_len + 1, __progname, prog_len );
+ memcpy( buf + tmp_len + prog_len + 1, suffix, sizeof(suffix) );
+
+ *fd = mkstemp( buf );
+ if ( *fd < 0 )
+ return 0;
+ else
+ return strdup( buf );
}
/* allocate and return a filename including the path for a config file
--- mikmod-3.1.6-a/src/mutilities.h~ Mon Aug 2 07:59:23 1999
+++ mikmod-3.1.6-a/src/mutilities.h Fri Jan 19 10:42:10 2001
@@ -34,7 +34,7 @@
char *str_sprintf(char*,char*);
/* allocate and return a name for a temporary file */
-char *get_tmp_name(void);
+char *get_tmp_name( int *fd );
BOOL file_exist(char*);
/* determines if a given path is absolute or relative */