summaryrefslogtreecommitdiff
path: root/src/Fl_Native_File_Chooser_Kdialog.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/Fl_Native_File_Chooser_Kdialog.cxx')
-rw-r--r--src/Fl_Native_File_Chooser_Kdialog.cxx16
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");