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

dtfile: Resolve warnings about format string overflow.s

This commit is contained in:
Peter Howkins 2021-11-25 04:58:01 +00:00
parent 0307f6af82
commit 021a5ef691
2 changed files with 8 additions and 8 deletions

View file

@ -2575,7 +2575,7 @@ SaveSession(
{ {
static char * name_list[] = { DTFILE_CLASS_NAME, NULL, NULL, NULL, static char * name_list[] = { DTFILE_CLASS_NAME, NULL, NULL, NULL,
NULL, NULL}; NULL, NULL};
char view_number[11]; char view_number[12];
char number[5]; char number[5];
char workspaceNumber[11]; char workspaceNumber[11];
int fd; int fd;
@ -2639,13 +2639,13 @@ SaveSession(
if (trashFileMgrData) if (trashFileMgrData)
{ {
if (trashFileMgrData->file_mgr_rec) if (trashFileMgrData->file_mgr_rec)
(void) sprintf (view_number, "%d", view_count + 1); (void) snprintf (view_number, sizeof(view_number), "%d", view_count + 1);
else else
(void) sprintf (view_number, "%d", view_count); (void) snprintf (view_number, sizeof(view_number), "%d", view_count);
} }
else else
{ {
(void) sprintf (view_number, "%d", view_count); (void) snprintf (view_number, sizeof(view_number), "%d", view_count);
} }
(void) write (fd, view_number, strlen (view_number)); (void) write (fd, view_number, strlen (view_number));
(void) write (fd, "\n#\n", strlen ("\n#\n")); (void) write (fd, "\n#\n", strlen ("\n#\n"));
@ -2817,7 +2817,7 @@ SaveSession(
/* Save each of the secondary help dialogs */ /* Save each of the secondary help dialogs */
for (j = 0; j < workspaceInfo->secondaryHelpDialogCount; j++) for (j = 0; j < workspaceInfo->secondaryHelpDialogCount; j++)
{ {
sprintf(number, "%d", j + 1); snprintf(number, sizeof(number), "%d", j + 1);
_DtWriteDialogData(workspaceInfo->secondaryHelpDialogList[j], _DtWriteDialogData(workspaceInfo->secondaryHelpDialogList[j],
fd, name_list); fd, name_list);
} }
@ -2825,7 +2825,7 @@ SaveSession(
/* Save the primary help dialog window */ /* Save the primary help dialog window */
if (workspaceInfo->primaryHelpDialog) if (workspaceInfo->primaryHelpDialog)
{ {
sprintf(number, "%d", 0); snprintf(number, sizeof(number), "%d", 0);
_DtWriteDialogData(workspaceInfo->primaryHelpDialog, _DtWriteDialogData(workspaceInfo->primaryHelpDialog,
fd, name_list); fd, name_list);
} }

View file

@ -209,7 +209,7 @@ configFileOK(void)
{ {
msg1 = GETMESSAGE(21, 22, "Cannot open file manager configuration file: "); msg1 = GETMESSAGE(21, 22, "Cannot open file manager configuration file: ");
msg2 = strerror(errno); msg2 = strerror(errno);
sprintf(g_errorMessage,"%s%s\n %s\n",msg1,fname,msg2); snprintf(g_errorMessage, sizeof(g_errorMessage), "%s%s\n %s\n",msg1,fname,msg2);
_DtSimpleError (application_name, DtError, NULL, g_errorMessage, NULL); _DtSimpleError (application_name, DtError, NULL, g_errorMessage, NULL);
return FALSE; return FALSE;
} }
@ -339,7 +339,7 @@ readConfigFile(const String fsType,
{ {
msg1 = GETMESSAGE(21, 22, "Cannot open file manager configuration file: "); msg1 = GETMESSAGE(21, 22, "Cannot open file manager configuration file: ");
msg2 = strerror(errno); msg2 = strerror(errno);
sprintf(g_errorMessage,"%s%s\n %s\n",msg1,fname,msg2); snprintf(g_errorMessage, sizeof(g_errorMessage), "%s%s\n %s\n",msg1,fname,msg2);
_DtSimpleError (application_name, DtError, NULL, g_errorMessage, NULL); _DtSimpleError (application_name, DtError, NULL, g_errorMessage, NULL);
return; return;
} }