Previous conversion seems to have missed many calls right next to ones that were converted to snprintf already
Signed-off-by: Alan Coopersmith <[email protected]> --- buttons.c | 7 ++++--- handler.c | 18 +++++++++--------- misc.c | 36 ++++++++++++++++++++---------------- vendor.c | 6 +++--- 4 files changed, 36 insertions(+), 31 deletions(-) diff --git a/buttons.c b/buttons.c index ee251d3..9233346 100644 --- a/buttons.c +++ b/buttons.c @@ -522,7 +522,7 @@ CreateSectionMenu(ManpageGlobals * man_globals, Widget parent) for (i = 0 ; i < sections ; i ++) { num_args = 0; XtSetArg(args[num_args], XtNlabel, manual[i].blabel); num_args++; - sprintf(entry_name, "section%d", i); + snprintf(entry_name, sizeof(entry_name), "section%d", i); entry = XtCreateManagedWidget(entry_name, smeBSBObjectClass, menu, args, num_args); @@ -579,7 +579,7 @@ MakeDirectoryBox(ManpageGlobals *man_globals, Widget parent, Widget *dir_disp, i return; name = manual[section].blabel; /* Set the section name */ - sprintf(label_name,"Directory of: %s",name); + snprintf(label_name, sizeof(label_name), "Directory of: %s", name); man_globals->section_name[section] = StrAlloc(label_name); num_args = 0; @@ -745,7 +745,8 @@ ConvertNamesToWidgets(Widget parent, char ** names) if (*temp_ids == NULL) { char error_buf[BUFSIZ]; - sprintf(error_buf, "Could not find widget named '%s'", *names); + snprintf(error_buf, sizeof(error_buf), + "Could not find widget named '%s'", *names); PrintError(error_buf); XtFree((char *)ids); return(NULL); diff --git a/handler.c b/handler.c index c61bd24..4fe291f 100644 --- a/handler.c +++ b/handler.c @@ -330,30 +330,30 @@ SaveFormattedPage(Widget w, XEvent * event, String * params, Cardinal * num_para if (!man_globals->compress) #endif - sprintf(cmdbuf, "%s %s %s", COPY, man_globals->tempfile, - man_globals->save_file); + snprintf(cmdbuf, sizeof(cmdbuf), "%s %s %s", COPY, + man_globals->tempfile, man_globals->save_file); #ifndef NO_COMPRESS else if (man_globals->gzip) - sprintf(cmdbuf, "%s < %s > %s", GZIP_COMPRESS, man_globals->tempfile, - man_globals->save_file); + snprintf(cmdbuf, sizeof(cmdbuf), "%s < %s > %s", GZIP_COMPRESS, + man_globals->tempfile, man_globals->save_file); else - sprintf(cmdbuf, "%s < %s > %s", COMPRESS, man_globals->tempfile, - man_globals->save_file); + snprintf(cmdbuf, sizeof(cmdbuf), "%s < %s > %s", COMPRESS, + man_globals->tempfile, man_globals->save_file); #endif if(! system(cmdbuf)) { /* make sure the formatted man page is fully accessible by the world */ if (chmod(man_globals->save_file, CHMOD_MODE) != 0) { - sprintf(error_buf, + snprintf(error_buf, sizeof(error_buf), "Couldn't set permissions on formatted man page '%s'.\n", man_globals->save_file); PopupWarning( man_globals, error_buf); } } else { - sprintf(error_buf, "Error while executing the command '%s'.\n", - cmdbuf); + snprintf(error_buf, sizeof(error_buf), + "Error while executing the command '%s'.\n", cmdbuf); PopupWarning( man_globals, error_buf); } break; diff --git a/misc.c b/misc.c index 25fc70c..0921307 100644 --- a/misc.c +++ b/misc.c @@ -263,7 +263,7 @@ FindManualFile(ManpageGlobals * man_globals, int section_num, int entry_num) return(file); #endif { - sprintf(filename, "%s/%s%s/%s.%s", path, CAT, + snprintf(filename, sizeof(filename), "%s/%s%s/%s.%s", path, CAT, section + len_cat, page, BZIP2_EXTENSION); if ( (file = Uncompress(man_globals, filename)) != NULL) return(file); @@ -271,7 +271,7 @@ FindManualFile(ManpageGlobals * man_globals, int section_num, int entry_num) #endif #ifdef LZMA_EXTENSION { - sprintf(filename, "%s/%s%s/%s.%s", path, CAT, + snprintf(filename, sizeof(filename), "%s/%s%s/%s.%s", path, CAT, section + len_cat, page, LZMA_EXTENSION); if ( (file = Uncompress(man_globals, filename)) != NULL) return(file); @@ -404,13 +404,13 @@ UncompressNamed(ManpageGlobals * man_globals, char * filename, char * output, #ifdef BZIP2_EXTENSION if (streq(filename + strlen(filename) - strlen(BZIP2_EXTENSION), BZIP2_EXTENSION)) - sprintf(cmdbuf, BUNZIP2_FORMAT, filename, output); + snprintf(cmdbuf, sizeof(cmdbuf), BUNZIP2_FORMAT, filename, output); else #endif #ifdef LZMA_EXTENSION if (streq(filename + strlen(filename) - strlen(LZMA_EXTENSION), LZMA_EXTENSION)) - sprintf(cmdbuf, UNLZMA_FORMAT, filename, output); + snprintf(cmdbuf, sizeof(cmdbuf), UNLZMA_FORMAT, filename, output); else #endif snprintf(cmdbuf, sizeof(cmdbuf), UNCOMPRESS_FORMAT, filename, output); @@ -892,7 +892,7 @@ UncompressUnformatted(ManpageGlobals * man_globals, char * entry, #ifdef BZIP2_EXTENSION { - sprintf(input, "%s.%s", filename, BZIP2_EXTENSION); + snprintf(input, sizeof(input), "%s.%s", filename, BZIP2_EXTENSION); #ifndef HAS_MKSTEMP if ( UncompressNamed(man_globals, input, filename) ) { #else @@ -901,8 +901,9 @@ UncompressUnformatted(ManpageGlobals * man_globals, char * entry, man_globals->compress = TRUE; man_globals->gzip = FALSE; man_globals->bzip2 = TRUE; - sprintf(man_globals->save_file, "%s/%s%s/%s.%s", path, - CAT, section + len_cat, page, BZIP2_EXTENSION); + snprintf(man_globals->save_file, sizeof(man_globals->save_file), + "%s/%s%s/%s.%s", path, CAT, section + len_cat, page, + BZIP2_EXTENSION); return(TRUE); } } @@ -910,7 +911,7 @@ UncompressUnformatted(ManpageGlobals * man_globals, char * entry, #ifdef LZMA_EXTENSION { - sprintf(input, "%s.%s", filename, LZMA_EXTENSION); + snprintf(input, sizeof(input), "%s.%s", filename, LZMA_EXTENSION); #ifndef HAS_MKSTEMP if ( UncompressNamed(man_globals, input, filename) ) { #else @@ -919,8 +920,9 @@ UncompressUnformatted(ManpageGlobals * man_globals, char * entry, man_globals->compress = TRUE; man_globals->gzip = FALSE; man_globals->lzma = TRUE; - sprintf(man_globals->save_file, "%s/%s%s/%s.%s", path, - CAT, section + len_cat, page, LZMA_EXTENSION); + snprintf(man_globals->save_file, sizeof(man_globals->save_file), + "%s/%s%s/%s.%s", path, CAT, section + len_cat, page, + LZMA_EXTENSION); return(TRUE); } } @@ -998,7 +1000,7 @@ UncompressUnformatted(ManpageGlobals * man_globals, char * entry, #ifdef BZIP2_EXTENSION { - sprintf(input, "%s.%s", filename, BZIP2_EXTENSION); + snprintf(input, sizeof(input), "%s.%s", filename, BZIP2_EXTENSION); #ifndef HAS_MKSTEMP if ( UncompressNamed(man_globals, input, filename) ) { #else @@ -1006,8 +1008,9 @@ UncompressUnformatted(ManpageGlobals * man_globals, char * entry, #endif man_globals->compress = TRUE; man_globals->gzip = TRUE; - sprintf(man_globals->save_file, "%s/%s%s/%s.%s", path, - CAT, section + len_cat, page, BZIP2_EXTENSION); + snprintf(man_globals->save_file, sizeof(man_globals->save_file), + "%s/%s%s/%s.%s", path, CAT, section + len_cat, page, + BZIP2_EXTENSION); return(TRUE); } } @@ -1015,7 +1018,7 @@ UncompressUnformatted(ManpageGlobals * man_globals, char * entry, #ifdef LZMA_EXTENSION { - sprintf(input, "%s.%s", filename, LZMA_EXTENSION); + snprintf(input, sizeof(input), "%s.%s", filename, LZMA_EXTENSION); #ifndef HAS_MKSTEMP if ( UncompressNamed(man_globals, input, filename) ) { #else @@ -1023,8 +1026,9 @@ UncompressUnformatted(ManpageGlobals * man_globals, char * entry, #endif man_globals->compress = TRUE; man_globals->lzma = TRUE; - sprintf(man_globals->save_file, "%s/%s%s/%s.%s", path, - CAT, section + len_cat, page, LZMA_EXTENSION); + snprintf(man_globals->save_file, sizeof(man_globals->save_file), + "%s/%s%s/%s.%s", path, CAT, section + len_cat, page, + LZMA_EXTENSION); return(TRUE); } } diff --git a/vendor.c b/vendor.c index 6ba5b0e..79cc8bb 100644 --- a/vendor.c +++ b/vendor.c @@ -187,10 +187,10 @@ char * path) int numSections = sizeof(SectionNames) / sizeof(SectionNames[0]); for (i=0; i < numSections; i++) { - sprintf(file, "%s%s", SEARCHDIR, SectionNames[i].suffix); + snprintf(file, sizeof(file), "%s%s", SEARCHDIR, SectionNames[i].suffix); AddNewSection(list, path, file, SectionNames[i].name, TRUE); #ifdef SEARCHOTHER - sprintf(file, "%s%s", SEARCHOTHER, SectionNames[i].suffix); + snprintf(file, sizeof(file), "%s%s", SEARCHOTHER, SectionNames[i].suffix); AddNewSection(list, path, file, SectionNames[i].name, TRUE); #endif } @@ -251,7 +251,7 @@ char *path) char *message = *p++; int flags = (int) *p++; while (*p != NULL) { - sprintf(file, "%s%s", SEARCHDIR, *p++); + snprintf(file, sizeof(file), "%s%s", SEARCHDIR, *p++); AddNewSection(list, path, file, message, flags); } p++; -- 1.7.3.2 _______________________________________________ [email protected]: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
