mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-15 04:32:24 +00:00
dtsession/SmSave: get rid of use of tempnam (CID 89359)
This commit is contained in:
parent
7c702bff6e
commit
e02c703af7
1 changed files with 23 additions and 16 deletions
|
@ -504,29 +504,36 @@ PruneSessionDirectory ()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char * tmpName;
|
char * tmpName;
|
||||||
char * tmp;
|
int len, tfd;
|
||||||
|
|
||||||
tmpName = (char *) XtMalloc (strlen (smGD.restoreSession) + 2);
|
len = strlen(smGD.savePath) + strlen(smGD.restoreSession)
|
||||||
sprintf (tmpName, "%s.", smGD.restoreSession);
|
+ strlen("XXXXXX") + 3;
|
||||||
if (strlen (tmpName) > 5) {
|
tmpName = XtCalloc (1, len);
|
||||||
tmpName[4] = '.';
|
sprintf(tmpName, "%s/%s.XXXXXX", smGD.savePath,
|
||||||
tmpName[5] = '\000';
|
smGD.restoreSession);
|
||||||
}
|
|
||||||
tmp = (char *) tempnam (smGD.savePath, tmpName);
|
|
||||||
|
|
||||||
sprintf (saveDir, "%s/%s", smGD.savePath, smGD.restoreSession);
|
if ((tfd = mkstemp(tmpName)) == -1)
|
||||||
|
{
|
||||||
|
PrintErrnoError(DtError, smNLS.cantCreateDirsString);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
close(tfd);
|
||||||
|
unlink(tmpName);
|
||||||
|
|
||||||
MoveDirectory (saveDir, tmp, False);
|
sprintf (saveDir, "%s/%s",
|
||||||
MoveDirectory (oldestDir, saveDir, False);
|
smGD.savePath, smGD.restoreSession);
|
||||||
|
|
||||||
sprintf (clientDB, "%s/%s/%s", smGD.savePath,
|
MoveDirectory (saveDir, tmpName, False);
|
||||||
smGD.restoreSession, SM_CLIENT_FILE2);
|
MoveDirectory (oldestDir, saveDir, False);
|
||||||
|
|
||||||
ExecuteDiscardCommands (clientDB);
|
sprintf (clientDB, "%s/%s/%s", smGD.savePath,
|
||||||
|
smGD.restoreSession, SM_CLIENT_FILE2);
|
||||||
|
|
||||||
MoveDirectory (tmp, saveDir, True);
|
ExecuteDiscardCommands (clientDB);
|
||||||
|
|
||||||
free (tmp);
|
MoveDirectory (tmpName, saveDir, True);
|
||||||
|
}
|
||||||
XtFree (tmpName);
|
XtFree (tmpName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue