mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-13 19:52:20 +00:00
dtdbcache: Use mkstemp() instead of tmpnam() to avoid bad interactions
Patch from Aaron W. Hsu <arcfide@sacrideo.us>
This commit is contained in:
parent
f42fa885be
commit
04b366b09c
1 changed files with 12 additions and 0 deletions
|
@ -680,13 +680,25 @@ write_db(DtDtsMMHeader *header, void *index, int size, const char *CacheFile)
|
||||||
/* unique file name instead. */
|
/* unique file name instead. */
|
||||||
char tmpnam_buf[L_tmpnam + 1];
|
char tmpnam_buf[L_tmpnam + 1];
|
||||||
|
|
||||||
|
if ((tmpfile = malloc(sizeof(_DTDTSMMTEMPDIR) +
|
||||||
|
sizeof(_DTDTSMMTEMPFILE) + 7)) == NULL) {
|
||||||
|
_DtSimpleError(DtProgName, DtError, NULL, tmpfile, NULL);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
sprintf(tmpfile, "%s/%sXXXXXX", _DTDTSMMTEMPDIR, _DTDTSMMTEMPFILE);
|
||||||
|
fd = mkstemp(tmpfile);
|
||||||
|
|
||||||
|
/*
|
||||||
tmpfile = (char *)malloc(sizeof(_DTDTSMMTEMPDIR) +
|
tmpfile = (char *)malloc(sizeof(_DTDTSMMTEMPDIR) +
|
||||||
sizeof(_DTDTSMMTEMPFILE) + L_tmpnam + 3);
|
sizeof(_DTDTSMMTEMPFILE) + L_tmpnam + 3);
|
||||||
|
|
||||||
tmpnam(tmpnam_buf);
|
tmpnam(tmpnam_buf);
|
||||||
sprintf(tmpfile, "%s/%s%s", _DTDTSMMTEMPDIR, _DTDTSMMTEMPFILE,
|
sprintf(tmpfile, "%s/%s%s", _DTDTSMMTEMPDIR, _DTDTSMMTEMPFILE,
|
||||||
basename(tmpnam_buf));
|
basename(tmpnam_buf));
|
||||||
|
|
||||||
fd = open(tmpfile, O_RDWR|O_CREAT, 0600);
|
fd = open(tmpfile, O_RDWR|O_CREAT, 0600);
|
||||||
|
*/
|
||||||
umask(cmask);
|
umask(cmask);
|
||||||
|
|
||||||
if(fd == -1)
|
if(fd == -1)
|
||||||
|
|
Loading…
Reference in a new issue