1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-15 04:32:24 +00:00

dtsession: Coverity (memory corruption)

This commit is contained in:
Jon Trulson 2014-12-26 14:22:05 -07:00
parent 2e7ab68300
commit b41a74b595

View file

@ -914,7 +914,9 @@ RestoreResources( Boolean errorHandlerInstalled, ... )
{ {
char clientMessage[MAXPATHLEN + 256]; char clientMessage[MAXPATHLEN + 256];
sprintf(clientMessage, ((char *)GETMESSAGE(16, 1, "Unable to exec process %s. No session resources will be restored.")), pgrm); memset(clientMessage, 0, MAXPATHLEN + 256);
snprintf(clientMessage, (MAXPATHLEN + 256) - 1,
((char *)GETMESSAGE(16, 1, "Unable to exec process %s. No session resources will be restored.")), pgrm);
PrintErrnoError(DtError, clientMessage); PrintErrnoError(DtError, clientMessage);
SM_EXIT(-1); SM_EXIT(-1);
} }
@ -1637,8 +1639,10 @@ RestoreIndependentResources( void )
sessionType = SM_CURRENT_FONT_DIRECTORY; sessionType = SM_CURRENT_FONT_DIRECTORY;
} }
sprintf(fontPath, "%s/%s/%s/%s.%s", smGD.savePath, sessionType, memset(fontPath, 0, MAXPATHLEN + 1);
currentLangPtr, SM_FONT_FILE, sessionRes); snprintf(fontPath, MAXPATHLEN, "%s/%s/%s/%s.%s",
smGD.savePath, sessionType,
currentLangPtr, SM_FONT_FILE, sessionRes);
status = stat(fontPath, &buf); status = stat(fontPath, &buf);
if(status == -1) if(status == -1)
{ {
@ -1646,16 +1650,16 @@ RestoreIndependentResources( void )
* User has nothing there - look in the system defaults * User has nothing there - look in the system defaults
* first in the language dep -then in lang independent * first in the language dep -then in lang independent
*/ */
fontPath[0] = '\0'; memset(fontPath, 0, MAXPATHLEN + 1);
if((currentLangPtr != NULL) && (*currentLangPtr != 0)) if((currentLangPtr != NULL) && (*currentLangPtr != 0))
{ {
strcat(fontPath, "/"); strcat(fontPath, "/");
strcat(fontPath, currentLangPtr); strncat(fontPath, currentLangPtr, MAXPATHLEN);
} }
strcat(fontPath, "/"); strncat(fontPath, "/", MAXPATHLEN);
strcat(fontPath, SM_SYSTEM_FONT_FILE); strncat(fontPath, SM_SYSTEM_FONT_FILE, MAXPATHLEN);
FixPath(fontPath); FixPath(fontPath);
@ -1665,8 +1669,9 @@ RestoreIndependentResources( void )
if((currentLangPtr != NULL) && (*currentLangPtr != 0) && if((currentLangPtr != NULL) && (*currentLangPtr != 0) &&
(strcmp(currentLangPtr, "C"))) (strcmp(currentLangPtr, "C")))
{ {
strcpy(fontPath, "/C/"); memset(fontPath, 0, MAXPATHLEN + 1);
strcat(fontPath, SM_SYSTEM_FONT_FILE); strcpy(fontPath, "/C/");
strncat(fontPath, SM_SYSTEM_FONT_FILE, MAXPATHLEN);
FixPath(fontPath); FixPath(fontPath);