mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-15 04:32:24 +00:00
dtsession/SmGlobals: fixup 17 coverity issues.
This commit is contained in:
parent
85f6b1d7f3
commit
881b0e1ed0
1 changed files with 77 additions and 40 deletions
|
@ -476,7 +476,7 @@ InitSMGlobals( void )
|
||||||
/*
|
/*
|
||||||
* Pull screen saver resources from Dtsession*<name>.
|
* Pull screen saver resources from Dtsession*<name>.
|
||||||
*/
|
*/
|
||||||
smGD.SmNextension = smGD.SmNextension = smGD.extensionSpec = "";
|
smGD.SmNextension = smGD.SmCextension = smGD.extensionSpec = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
XtGetSubresources(smGD.topLevelWid, (XtPointer) &smSaverRes,
|
XtGetSubresources(smGD.topLevelWid, (XtPointer) &smSaverRes,
|
||||||
|
@ -703,7 +703,7 @@ SetRestorePath(
|
||||||
|
|
||||||
pch = strdup ((char *) GETMESSAGE (40, 15,
|
pch = strdup ((char *) GETMESSAGE (40, 15,
|
||||||
" No session name was provided for the -session command line option."));
|
" No session name was provided for the -session command line option."));
|
||||||
if (!pch)
|
if (pch)
|
||||||
{
|
{
|
||||||
DtMsgLogMessage (argv[0], DtMsgLogWarning, pch);
|
DtMsgLogMessage (argv[0], DtMsgLogWarning, pch);
|
||||||
free (pch);
|
free (pch);
|
||||||
|
@ -1109,22 +1109,26 @@ SetSavePath(
|
||||||
if(status == 0)
|
if(status == 0)
|
||||||
{
|
{
|
||||||
char * tmpName;
|
char * tmpName;
|
||||||
char * tmpDir;
|
int len, tfd;
|
||||||
|
|
||||||
strcpy (savedOldDir, smGD.etcPath);
|
strcpy(savedOldDir, smGD.etcPath);
|
||||||
|
|
||||||
tmpName = (char *) XtMalloc (strlen (smGD.restoreSession) + 2);
|
len = strlen(smGD.restoreSession) + strlen("XXXXXX") + 2;
|
||||||
sprintf (tmpName, "%s.", smGD.restoreSession);
|
tmpName = (char *) XtCalloc(1, len);
|
||||||
if (strlen (tmpName) > 5) {
|
|
||||||
tmpName[4] = '.';
|
sprintf(tmpName, "%s.XXXXXX", smGD.restoreSession);
|
||||||
tmpName[5] = '\000';
|
if ((tfd = mkstemp(tmpName)) == -1)
|
||||||
|
{
|
||||||
|
PrintErrnoError(DtError, smNLS.cantCreateDirsString);
|
||||||
}
|
}
|
||||||
tmpDir = (char *) tempnam (smGD.savePath, tmpName);
|
else
|
||||||
MoveDirectory (smGD.etcPath, tmpDir, False);
|
{
|
||||||
|
close(tfd);
|
||||||
|
MoveDirectory(smGD.etcPath, tmpName, False);
|
||||||
|
|
||||||
strcpy (savedTmpDir, tmpDir);
|
strncpy(savedTmpDir, tmpName, len - 1);
|
||||||
free (tmpDir);
|
}
|
||||||
XtFree ((char *) tmpName);
|
XtFree((char *) tmpName);
|
||||||
}
|
}
|
||||||
MoveDirectory(smGD.clientPath, smGD.etcPath, False);
|
MoveDirectory(smGD.clientPath, smGD.etcPath, False);
|
||||||
}
|
}
|
||||||
|
@ -1165,25 +1169,31 @@ SetSavePath(
|
||||||
* save is complete.
|
* save is complete.
|
||||||
*/
|
*/
|
||||||
char * tmpName;
|
char * tmpName;
|
||||||
char * tmpDir;
|
|
||||||
|
|
||||||
sprintf(smGD.etcPath, "%s.%s", smGD.clientPath, SM_OLD_EXTENSION);
|
sprintf(smGD.etcPath, "%s.%s", smGD.clientPath, SM_OLD_EXTENSION);
|
||||||
status = stat(smGD.etcPath, &buf);
|
status = stat(smGD.etcPath, &buf);
|
||||||
if(status == 0)
|
if(status == 0)
|
||||||
{
|
{
|
||||||
tmpName = (char *) XtMalloc (strlen (smGD.restoreSession) + 2);
|
int len, tfd;
|
||||||
sprintf (tmpName, "%s.", smGD.restoreSession);
|
|
||||||
strcpy (savedOldDir, smGD.etcPath);
|
|
||||||
if (strlen (tmpName) > 5) {
|
|
||||||
tmpName[4] = '.';
|
|
||||||
tmpName[5] = '\000';
|
|
||||||
}
|
|
||||||
tmpDir = (char *) tempnam (smGD.savePath, tmpName);
|
|
||||||
MoveDirectory (smGD.etcPath, tmpDir, False);
|
|
||||||
|
|
||||||
strcpy (savedTmpDir, tmpDir);
|
len = strlen(smGD.restoreSession) + strlen("XXXXXX") + 2;
|
||||||
free (tmpDir);
|
tmpName = (char *) XtCalloc(1, len);
|
||||||
XtFree ((char *) tmpName);
|
sprintf(tmpName, "%s.XXXXXX", smGD.restoreSession);
|
||||||
|
|
||||||
|
strcpy (savedOldDir, smGD.etcPath);
|
||||||
|
|
||||||
|
if ((tfd = mkstemp(tmpName)) == -1)
|
||||||
|
{
|
||||||
|
PrintErrnoError(DtError, smNLS.cantCreateDirsString);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
close(tfd);
|
||||||
|
MoveDirectory (smGD.etcPath, tmpName, False);
|
||||||
|
|
||||||
|
strcpy (savedTmpDir, tmpName);
|
||||||
|
}
|
||||||
|
XtFree((char *) tmpName);
|
||||||
}
|
}
|
||||||
|
|
||||||
MoveDirectory(smGD.clientPath, smGD.etcPath, False);
|
MoveDirectory(smGD.clientPath, smGD.etcPath, False);
|
||||||
|
@ -1200,7 +1210,15 @@ SetSavePath(
|
||||||
smGD.resourcePath[0] = 0;
|
smGD.resourcePath[0] = 0;
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
chmod(smGD.clientPath, 0755);
|
status = chmod(smGD.clientPath, 0755);
|
||||||
|
if(status == -1)
|
||||||
|
{
|
||||||
|
PrintErrnoError(DtError, smNLS.cantCreateDirsString);
|
||||||
|
smGD.clientPath[0] = 0;
|
||||||
|
smGD.settingPath[0] = 0;
|
||||||
|
smGD.resourcePath[0] = 0;
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
strcat(smGD.clientPath, "/");
|
strcat(smGD.clientPath, "/");
|
||||||
|
@ -1284,7 +1302,13 @@ SetFontSavePath(char *langPtr)
|
||||||
smGD.fontPath[0] = 0;
|
smGD.fontPath[0] = 0;
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
chmod(smGD.fontPath, 0755);
|
status = chmod(smGD.fontPath, 0755);
|
||||||
|
if(status == -1)
|
||||||
|
{
|
||||||
|
PrintErrnoError(DtError, smNLS.cantCreateDirsString);
|
||||||
|
smGD.fontPath[0] = 0;
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
|
@ -1632,7 +1656,7 @@ TrimErrorlog( void )
|
||||||
|
|
||||||
len = strlen(home) + strlen(DtPERSONAL_CONFIG_DIRECTORY) + 2;
|
len = strlen(home) + strlen(DtPERSONAL_CONFIG_DIRECTORY) + 2;
|
||||||
if (len > MAXPATHLEN) savePath = SM_REALLOC(savePath, len);
|
if (len > MAXPATHLEN) savePath = SM_REALLOC(savePath, len);
|
||||||
sprintf(savePath, "%s/%s", home, DtPERSONAL_CONFIG_DIRECTORY);
|
snprintf(savePath, len - 1, "%s/%s", home, DtPERSONAL_CONFIG_DIRECTORY);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If errorlog.old exists and it is not empty, delete
|
* If errorlog.old exists and it is not empty, delete
|
||||||
|
@ -2352,7 +2376,7 @@ InitializeSpecificSession (
|
||||||
if (len > MAXPATHLEN)
|
if (len > MAXPATHLEN)
|
||||||
alt_dir = XtRealloc(alt_dir, len + 1);
|
alt_dir = XtRealloc(alt_dir, len + 1);
|
||||||
|
|
||||||
(void) sprintf (alt_dir, "%s/%s/%s/%s",
|
snprintf(alt_dir, len, "%s/%s/%s/%s",
|
||||||
home,
|
home,
|
||||||
DtPERSONAL_CONFIG_DIRECTORY,
|
DtPERSONAL_CONFIG_DIRECTORY,
|
||||||
DtSM_SESSION_DIRECTORY,
|
DtSM_SESSION_DIRECTORY,
|
||||||
|
@ -2412,6 +2436,12 @@ InitializePaths (
|
||||||
char *db_file = (char *) XtMalloc(MAXPATHLEN);
|
char *db_file = (char *) XtMalloc(MAXPATHLEN);
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
|
|
||||||
|
if (!db_file)
|
||||||
|
{
|
||||||
|
PrintError(DtError, smNLS.cantMallocErrorString);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
smGD.savePath = _DtCreateDtDirs(disp);
|
smGD.savePath = _DtCreateDtDirs(disp);
|
||||||
|
|
||||||
(void) sprintf (smGD.settingPath, "%s/%s/%s",
|
(void) sprintf (smGD.settingPath, "%s/%s/%s",
|
||||||
|
@ -2434,7 +2464,7 @@ InitializePaths (
|
||||||
if ((stat(db_file, &buf)) == 0)
|
if ((stat(db_file, &buf)) == 0)
|
||||||
(void) strcpy (smGD.clientPath, db_file);
|
(void) strcpy (smGD.clientPath, db_file);
|
||||||
}
|
}
|
||||||
if (db_file) XtFree(db_file);
|
XtFree(db_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2472,6 +2502,13 @@ SetAlternateSession (
|
||||||
char *db_file2 = (char *) XtMalloc(MAXPATHLEN);
|
char *db_file2 = (char *) XtMalloc(MAXPATHLEN);
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
|
|
||||||
|
if (!db_file1 || !db_file2)
|
||||||
|
{
|
||||||
|
PrintError(DtError, smNLS.cantMallocErrorString);
|
||||||
|
return False;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if ((stat (session_dir, &buf)) != 0) {
|
if ((stat (session_dir, &buf)) != 0) {
|
||||||
/*
|
/*
|
||||||
* The requested dir does not exist, create it
|
* The requested dir does not exist, create it
|
||||||
|
@ -2560,8 +2597,8 @@ SetAlternateSession (
|
||||||
SetSysDefaults ();
|
SetSysDefaults ();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (db_file1) XtFree(db_file1);
|
XtFree(db_file1);
|
||||||
if (db_file2) XtFree(db_file2);
|
XtFree(db_file2);
|
||||||
return (True);
|
return (True);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue