dtstyle: fix bugs preventing SM save from working properly

All of the dtstyle session save routines used sprintf/snprintf whereby
the destination buffer was also a source buffer, like so:

snprintf(bufr, sizeof(style.tmpBigStr), "%s*Fonts.x: %d\n", bufr, x);
         ^^^^                            ^^                 ^^^^

That results in undefined behavior, which mainly meant missing or
currupted XRM resources being saved in the session file for dtstyle.
This commit is contained in:
Jon Trulson
2022-02-26 15:09:43 -07:00
parent a52f988e47
commit 383b5e4b59
14 changed files with 124 additions and 108 deletions

View File

@@ -102,21 +102,13 @@ saveSessionCB(
unsigned char *data = NULL;
char *tmpStr;
#ifdef _SUN_OS
char *noCommands = NULL;
#endif /* _SUN_OS */
/* get the root window property of SaveMode */
GetSessionSaveMode(&data );
GetSessionSaveMode(&data);
/* if the property is "home" don't save dtstyle */
if(strcmp((char *)data, "home") == 0)
{
#ifdef _SUN_OS /* Sun doesn't like "NULL" when expecting "char **" */
XSetCommand(style.display, XtWindow(w), &noCommands, 0);
#else
XSetCommand(style.display, XtWindow(w), NULL, 0);
#endif /* _SUN_OS */
return;
}
@@ -151,7 +143,7 @@ saveSessionCB(
saveDtwm(fd);
saveStartup(fd);
saveI18n(fd);
close (fd);
/*If this is a session manager requested saveYrSlf, need to put dialogs in*/