diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2022-09-26 16:12:18 +0200 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2022-09-26 16:12:18 +0200 |
| commit | 2ffd4e4f1af16b17a286ff354603a717f5d828a5 (patch) | |
| tree | 99e2d4a7e2fde8e3abb027eb687901440750ee00 /src/Fl_Native_File_Chooser_Kdialog.cxx | |
| parent | 53d9614adbb728fc4db983c9bb817c6eea870994 (diff) | |
Replace all calls to sprintf() by calls to snprintf().
Diffstat (limited to 'src/Fl_Native_File_Chooser_Kdialog.cxx')
| -rw-r--r-- | src/Fl_Native_File_Chooser_Kdialog.cxx | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/Fl_Native_File_Chooser_Kdialog.cxx b/src/Fl_Native_File_Chooser_Kdialog.cxx index 820a6cbd8..7347331ec 100644 --- a/src/Fl_Native_File_Chooser_Kdialog.cxx +++ b/src/Fl_Native_File_Chooser_Kdialog.cxx @@ -111,14 +111,20 @@ int Fl_Kdialog_Native_File_Chooser_Driver::show() { const char *preset = "."; if (_preset_file) preset = _preset_file; else if (_directory) preset = _directory; - char *command = new char[strlen(option) + strlen(preset) + (_title?strlen(_title)+11:0) + - (_parsedfilt?strlen(_parsedfilt):0) + 50]; + const int com_size = strlen(option) + strlen(preset) + + (_title?strlen(_title)+11:0) + (_parsedfilt?strlen(_parsedfilt):0) + 50; + char *command = new char[com_size]; strcpy(command, "kdialog "); if (_title) { - sprintf(command+strlen(command), " --title '%s'", _title); + snprintf(command+strlen(command), com_size - strlen(command), + " --title '%s'", _title); + } + snprintf(command+strlen(command), com_size - strlen(command), + " %s %s ", option, preset); + if (_parsedfilt) { + snprintf(command+strlen(command), com_size - strlen(command), + " \"%s\" ", _parsedfilt); } - sprintf(command+strlen(command), " %s %s ", option, preset); - if (_parsedfilt) sprintf(command+strlen(command), " \"%s\" ", _parsedfilt); strcat(command, "2> /dev/null"); // get rid of stderr output //puts(command); FILE *pipe = popen(command, "r"); |
