1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-13 11:42:21 +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:
Jon Trulson 2012-08-07 16:52:26 -06:00
parent f42fa885be
commit 04b366b09c

View file

@ -680,13 +680,25 @@ write_db(DtDtsMMHeader *header, void *index, int size, const char *CacheFile)
/* unique file name instead. */
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) +
sizeof(_DTDTSMMTEMPFILE) + L_tmpnam + 3);
tmpnam(tmpnam_buf);
sprintf(tmpfile, "%s/%s%s", _DTDTSMMTEMPDIR, _DTDTSMMTEMPFILE,
basename(tmpnam_buf));
fd = open(tmpfile, O_RDWR|O_CREAT, 0600);
*/
umask(cmask);
if(fd == -1)