From caef8edac0ea6411548420034742957c2fff70f4 Mon Sep 17 00:00:00 2001 From: Peter Howkins Date: Sat, 14 Apr 2018 01:23:48 +0100 Subject: [PATCH] various: You cannot use the destination of snprintf as one of the srcs, undefined --- cde/lib/tt/mini_isam/isrename.c | 30 +++++++++++++------ cde/programs/dthelp/dthelpgen/helpgen.c | 21 +++++++++---- cde/programs/dthelp/dthelpprint/Initialize.c | 8 +++-- .../dthelp/parser/pass1/helptag/help.c | 4 ++- cde/programs/dtlogin/auth.c | 20 +++++++++---- 5 files changed, 59 insertions(+), 24 deletions(-) diff --git a/cde/lib/tt/mini_isam/isrename.c b/cde/lib/tt/mini_isam/isrename.c index 3691f26e..7f2b1be2 100644 --- a/cde/lib/tt/mini_isam/isrename.c +++ b/cde/lib/tt/mini_isam/isrename.c @@ -217,6 +217,7 @@ _rename_datfile(isfname, newname) { char namebuf[MAXPATHLEN]; char newbuf[MAXPATHLEN]; + char newbuftemp[sizeof(newbuf)]; snprintf(namebuf, sizeof(namebuf), "%s", isfname); snprintf(newbuf, sizeof(newbuf), "%s", isfname); @@ -225,9 +226,12 @@ _rename_datfile(isfname, newname) * Replace the last element of the old path with newname. */ _removelast(newbuf); - if (strcmp(newbuf, "/") != 0) - snprintf(newbuf, sizeof(newbuf), "%s/", newbuf); - snprintf(newbuf, sizeof(newbuf), "%s%s", newbuf, newname); + if (strcmp(newbuf, "/") != 0) { + snprintf(newbuftemp, sizeof(newbuftemp), "%s/", newbuf); + strcpy(newbuf, newbuftemp); + } + snprintf(newbuftemp, sizeof(newbuftemp), "%s%s", newbuf, newname); + strcpy(newbuf, newbuftemp); _makedat_isfname(namebuf); _makedat_isfname(newbuf); @@ -242,6 +246,7 @@ _rename_indfile(isfname, newname) { char namebuf[MAXPATHLEN]; char newbuf[MAXPATHLEN]; + char newbuftemp[MAXPATHLEN]; snprintf(namebuf, sizeof(namebuf), "%s", isfname); snprintf(newbuf, sizeof(newbuf), "%s", isfname); @@ -250,9 +255,12 @@ _rename_indfile(isfname, newname) * Replace the last element of the old path with newname. */ _removelast(newbuf); - if (strcmp(newbuf, "/") != 0) - snprintf(newbuf, sizeof(newbuf), "%s/", newbuf); - snprintf(newbuf, sizeof(newbuf), "%s%s", newbuf, newname); + if (strcmp(newbuf, "/") != 0) { + snprintf(newbuftemp, sizeof(newbuftemp), "%s/", newbuf); + strcpy(newbuf, newbuftemp); + } + snprintf(newbuftemp, sizeof(newbuftemp), "%s%s", newbuf, newname); + strcpy(newbuf, newbuftemp); _makeind_isfname(namebuf); _makeind_isfname(newbuf); @@ -267,6 +275,7 @@ _rename_varfile(isfname, newname) { char namebuf[MAXPATHLEN]; char newbuf[MAXPATHLEN]; + char newbuftemp[MAXPATHLEN]; snprintf(namebuf, sizeof(namebuf), "%s", isfname); snprintf(newbuf, sizeof(newbuf), "%s", isfname); @@ -275,9 +284,12 @@ _rename_varfile(isfname, newname) * Replace the last element of the old path with newname. */ _removelast(newbuf); - if (strcmp(newbuf, "/") != 0) - snprintf(newbuf, sizeof(newbuf), "%s/", newbuf); - snprintf(newbuf, sizeof(newbuf), "%s%s", newbuf, newname); + if (strcmp(newbuf, "/") != 0) { + snprintf(newbuftemp, sizeof(newbuftemp), "%s/", newbuf); + strcpy(newbuf, newbuftemp); + } + snprintf(newbuftemp, sizeof(newbuftemp), "%s%s", newbuf, newname); + strcpy(newbuf, newbuftemp); _makevar_isfname(namebuf); _makevar_isfname(newbuf); diff --git a/cde/programs/dthelp/dthelpgen/helpgen.c b/cde/programs/dthelp/dthelpgen/helpgen.c index 05b74af6..2d194199 100644 --- a/cde/programs/dthelp/dthelpgen/helpgen.c +++ b/cde/programs/dthelp/dthelpgen/helpgen.c @@ -389,6 +389,7 @@ CreateFamily ( char *bitmap = NULL; char familyName [20]; /* FAMILY%d */ char bitmapName [MAXPATHLEN + 2]; + char bitmapNameTemp [sizeof(bitmapName)]; XrmDatabase db; char *resType; @@ -537,7 +538,8 @@ CreateFamily ( { ptr++; *ptr = '\0'; - snprintf(bitmapName, sizeof(bitmapName), "%s%s", bitmapName, bitmap); + snprintf(bitmapNameTemp, sizeof(bitmapNameTemp), "%s%s", bitmapName, bitmap); + strcpy(bitmapName, bitmapNameTemp); bitmap = bitmapName; } else @@ -948,11 +950,13 @@ main( int doGen = 0; char tmpVolume [MAXPATHLEN + 2]; + char tmpVolumeTemp[sizeof(tmpVolume)]; char tmpVolume2 [MAXPATHLEN + 2]; char tmpTopic [MAXPATHLEN + 2]; char tmpHeader [MAXPATHLEN + 2]; char headerName [MAXPATHLEN + 2]; char baseName [MAXPATHLEN + 2]; + char baseNameTemp[sizeof(baseName)]; char tempName [MAXPATHLEN + 2]; char **next; char *charSet; @@ -1057,7 +1061,8 @@ main( myName, errno); exit (1); } - snprintf(baseName, sizeof(baseName), "%s/%s", baseName, App_args.dir); + snprintf(baseNameTemp, sizeof(baseNameTemp), "%s/%s", baseName, App_args.dir); + strcpy(baseName, baseNameTemp); } else snprintf(baseName, sizeof(baseName), "%s", App_args.dir); @@ -1076,8 +1081,10 @@ main( } snprintf(tmpVolume, sizeof(tmpVolume), "%s", ptr); - if (tmpVolume[strlen (tmpVolume) - 1] != '/') - snprintf(tmpVolume, sizeof(tmpVolume), "%s", SlashString); + if (tmpVolume[strlen (tmpVolume) - 1] != '/') { + snprintf(tmpVolumeTemp, sizeof(tmpVolumeTemp), "%s%s", tmpVolume, SlashString); + strcpy(tmpVolume, tmpVolumeTemp); + } free (ptr); @@ -1185,12 +1192,14 @@ main( /* * get temporary files for the volume and topic file. */ - snprintf(tmpVolume, sizeof(tmpVolume), "%s%s", tmpVolume, App_args.file); + snprintf(tmpVolumeTemp, sizeof(tmpVolumeTemp), "%s%s", tmpVolume, App_args.file); + strcpy(tmpVolume, tmpVolumeTemp); (void) strcpy (tmpHeader, tmpVolume); (void) strcpy (tmpTopic, tmpVolume); - snprintf(tmpVolume, sizeof(tmpVolume), "%s%s", tmpVolume, Ext_Hv); + snprintf(tmpVolumeTemp, sizeof(tmpVolumeTemp), "%s%s", tmpVolume, Ext_Hv); + strcpy(tmpVolume, tmpVolumeTemp); (void) strcat (tmpHeader, "00.ht"); (void) strcat (tmpTopic , "01.ht"); diff --git a/cde/programs/dthelp/dthelpprint/Initialize.c b/cde/programs/dthelp/dthelpprint/Initialize.c index 381f16a5..c18d5527 100644 --- a/cde/programs/dthelp/dthelpprint/Initialize.c +++ b/cde/programs/dthelp/dthelpprint/Initialize.c @@ -796,7 +796,9 @@ static float dphm = 300.*2540.; int (*stricmp)(const char *,const char *); char *name; char name_prefix[RSRCSPECLEN]; + char name_prefix_temp[sizeof(name_prefix)]; char class_prefix[RSRCSPECLEN]; + char class_prefix_temp[sizeof(class_prefix)]; char resource_name[RSRCSPECLEN]; char resource_class[RSRCSPECLEN]; char *str_type[20]; @@ -825,8 +827,10 @@ static float dphm = 300.*2540.; else name = EMPTY_STR; if (name[0] != EOS) { - snprintf(name_prefix, sizeof(name_prefix), "%s%s%s", name_prefix, DOT_STR, name); /* e.g. dthelpprint.printer. */ - snprintf(class_prefix, sizeof(class_prefix), "%s%s%s", class_prefix, DOT_STR, name); /* e.g. Dthelpprint.Printer. */ + snprintf(name_prefix_temp, sizeof(name_prefix_temp), "%s%s%s", name_prefix, DOT_STR, name); /* e.g. dthelpprint.printer. */ + strcpy(name_prefix, name_prefix_temp); + snprintf(class_prefix_temp, sizeof(class_prefix_temp), "%s%s%s", class_prefix, DOT_STR, name); /* e.g. Dthelpprint.Printer. */ + strcpy(class_prefix, class_prefix_temp); } /**************************/ diff --git a/cde/programs/dthelp/parser/pass1/helptag/help.c b/cde/programs/dthelp/parser/pass1/helptag/help.c index 9c6c235c..2e69b0c9 100644 --- a/cde/programs/dthelp/parser/pass1/helptag/help.c +++ b/cde/programs/dthelp/parser/pass1/helptag/help.c @@ -1501,6 +1501,7 @@ static const char *isoString = "ISO-8859-1"; _DtXlateDb myDb = NULL; char myPlatform[_DtPLATFORM_MAX_LEN+1]; char myLocale[256]; /* arbitrarily large */ +char myLocaleTemp[sizeof(myLocale)]; /* non-arbitrarily the same */ char *locale; char *lang; char *charset; @@ -1511,7 +1512,8 @@ int isStd; snprintf(myLocale, sizeof(myLocale), "%s", pLang); if (*pCharset) { - snprintf(myLocale, sizeof(myLocale), "%s.%s", myLocale, pCharset); + snprintf(myLocaleTemp, sizeof(myLocaleTemp), "%s.%s", myLocale, pCharset); + strcpy(myLocale, myLocaleTemp); } if ((_DtLcxOpenAllDbs(&myDb) != 0) || diff --git a/cde/programs/dtlogin/auth.c b/cde/programs/dtlogin/auth.c index 4b22081b..6802a28b 100644 --- a/cde/programs/dtlogin/auth.c +++ b/cde/programs/dtlogin/auth.c @@ -1140,6 +1140,7 @@ SetUserAuthorization (struct display *d, struct verify_info *verify) { FILE *old, *new; char home_name[1024], backup_name[1024], new_name[1024]; + char home_name_temp[sizeof(home_name)]; char *name; char *home; char *envname = 0; @@ -1159,9 +1160,12 @@ SetUserAuthorization (struct display *d, struct verify_info *verify) lockStatus = LOCK_ERROR; if (home) { snprintf(home_name, sizeof(home_name), "%s", home); - if (home[strlen(home) - 1] != '/') - snprintf(home_name, sizeof(home_name), "%s/", home_name); - snprintf(home_name, sizeof(home_name), "%s.Xauthority", home_name); + if (home[strlen(home) - 1] != '/') { + snprintf(home_name_temp, sizeof(home_name_temp), "%s/", home_name); + strcpy(home_name, home_name_temp); + } + snprintf(home_name_temp, sizeof(home_name_temp), "%s.Xauthority", home_name); + strcpy(home_name, home_name_temp); Debug ("XauLockAuth %s\n", home_name); lockStatus = XauLockAuth (home_name, 1, 2, 10); Debug ("Lock is %d\n", lockStatus); @@ -1319,6 +1323,7 @@ RemoveUserAuthorization (struct display *d, struct verify_info *verify) char *home; Xauth **auths, *entry; char name[1024], new_name[1024]; + char name_temp[sizeof(name)]; int lockStatus; FILE *old, *new; struct stat statb; @@ -1332,9 +1337,12 @@ RemoveUserAuthorization (struct display *d, struct verify_info *verify) return; Debug ("RemoveUserAuthorization\n"); snprintf(name, sizeof(name), "%s", home); - if (home[strlen(home) - 1] != '/') - snprintf(name, sizeof(name), "%s/", name); - snprintf(name, sizeof(name), "%s.Xauthority", name); + if (home[strlen(home) - 1] != '/') { + snprintf(name_temp, sizeof(name_temp), "%s/", name); + strcpy(name, name_temp); + } + snprintf(name_temp, sizeof(name_temp), "%s.Xauthority", name); + strcpy(name, name_temp); Debug ("XauLockAuth %s\n", name); lockStatus = XauLockAuth (name, 1, 2, 10); Debug ("Lock is %d\n", lockStatus); -- 2.25.1