* util.c (mc_mkstemps): Don't prepend $TMPDIR if prefix contains

path separator.
This commit is contained in:
Pavel Roskin 2001-07-27 19:27:09 +00:00
parent e447c7e10e
commit b4be52ba78
2 changed files with 19 additions and 8 deletions

View File

@ -1,3 +1,8 @@
2001-07-27 Pavel Roskin <proski@gnu.org>
* util.c (mc_mkstemps): Don't prepend $TMPDIR if prefix contains
path separator.
2001-07-26 Pavel Roskin <proski@gnu.org>
* cmd.c (do_link): Append filename to the default symlink

View File

@ -1316,7 +1316,8 @@ concat_dir_and_file (const char *dir, const char *file)
* Arguments:
* pname (output) - pointer to the name of the temp file (needs g_free).
* NULL if the function fails.
* prefix - part of the filename before the random part (without directory).
* prefix - part of the filename before the random part.
* Prepend $TMPDIR or /tmp if there are no path separators.
* suffix - if not NULL, part of the filename after the random part.
*
* Result:
@ -1328,12 +1329,14 @@ int mc_mkstemps(char **pname, const char *prefix, const char *suffix)
= "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
static unsigned long value;
struct timeval tv;
char *tmpdir;
char *tmpbase;
char *tmpname;
char *XXXXXX;
int count;
if (strchr(prefix, PATH_SEP) == NULL) {
char *tmpdir;
tmpdir = getenv("TMPDIR");
if (!tmpdir) {
tmpdir = TMPDIR_DEFAULT;
@ -1341,6 +1344,9 @@ int mc_mkstemps(char **pname, const char *prefix, const char *suffix)
/* Add prefix first to find the position of XXXXXX */
tmpbase = concat_dir_and_file (tmpdir, prefix);
} else {
tmpbase = g_strdup (prefix);
}
tmpname = g_strconcat (tmpbase, "XXXXXX", suffix, NULL);
*pname = tmpname;