--- src/tX_mastergui.cc-dist	2004-11-03 14:25:50.000000000 +0100
+++ src/tX_mastergui.cc	2005-01-21 13:42:32.325461404 +0100
@@ -357,14 +357,15 @@ void load_tt_part(char * buffer)
 #endif	
 	
 	tx_mg_have_setname=true;
-	strcpy(tx_mg_current_setname, buffer);
+	strncpy(tx_mg_current_setname, buffer, sizeof(tx_mg_current_setname));
+	tx_mg_current_setname[sizeof(tx_mg_current_setname)-1] = 0;
 	
 	tX_seqpar :: init_all_graphics();
 	vg_init_all_non_seqpars();
 		
 	gtk_adjustment_set_value(volume_adj, globals.volume);
 	gtk_adjustment_set_value(pitch_adj, globals.pitch);
-	sprintf(wbuf,"terminatorX - %s", strip_path(buffer));
+	snprintf(wbuf, sizeof(wbuf), "terminatorX - %s", strip_path(buffer));
 #ifdef USE_ALSA_MIDI_IN
 	if (globals.auto_assign_midi) tX_midiin::auto_assign_midi_mappings(NULL, NULL);
 #endif	
@@ -376,7 +377,8 @@ void do_load_tables(GtkWidget *wid)
 {
 	char buffer[PATH_MAX];
 	
-	strcpy(buffer, gtk_file_selection_get_filename(GTK_FILE_SELECTION(load_dialog)));
+	strncpy(buffer, gtk_file_selection_get_filename(GTK_FILE_SELECTION(load_dialog)), sizeof(buffer)-1);
+	buffer[PATH_MAX-1] = 0;
 	
 	gtk_widget_destroy(load_dialog);
 	
@@ -529,9 +531,12 @@ GtkSignalFunc drop_set(GtkWidget *widget
 {
 	char filename[PATH_MAX];
 	char *fn;
-	
-	strncpy(filename, (char *) selection_data->data, (size_t) selection_data->length);
-	filename[selection_data->length]=0;
+	size_t len = sizeof(filename) - 1;
+
+	if (len > (size_t) selection_data->length)
+		len = (size_t) selection_data->length;
+	strncpy(filename, (char *) selection_data->data, len);
+	filename[len]=0;
 
 	fn = strchr (filename, '\r');
 	*fn=0;	
@@ -560,7 +565,8 @@ gboolean do_save_from_selection(GtkWidge
 	char buffer[PATH_MAX];
 	
 	if (wid) {
-		strcpy(buffer, gtk_file_selection_get_filename(GTK_FILE_SELECTION(save_dialog)));
+		strncpy(buffer, gtk_file_selection_get_filename(GTK_FILE_SELECTION(save_dialog)), sizeof(buffer));
+		buffer[sizeof(buffer)-1] = 0;
 		int len=strlen(buffer);
 		if (!len || (buffer[len-1]=='/')) {			
 			tx_note("Invalid filename for set file.", true);			
@@ -588,14 +594,11 @@ void do_save_tables(char *buffer)
 	
 	ext=strrchr(buffer, '.');
 	
-	if (ext) {
-		if (strcmp(ext, ".tX")) strcat(buffer, ".tX");
-	} else {
-		strcat(buffer, ".tX");
-	}
+	snprintf(tx_mg_current_setname, sizeof(tx_mg_current_setname), "%s%s",
+		 buffer, (ext == NULL || strcmp(ext, ".tX")) ? ".tX" : "");
+	buffer = tx_mg_current_setname;
 
 	tx_mg_have_setname=true;
-	strcpy(tx_mg_current_setname, buffer);
 	strcpy(globals.tables_filename, buffer);
 	
 	if (globals.compress_set_files) {
@@ -634,7 +637,8 @@ GtkSignalFunc save_tables_as()
 	if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) {
     	char buffer[PATH_MAX];
 		char *filename=gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
-		strcpy(buffer, filename);
+		strncpy(buffer, filename, sizeof(buffer));
+		buffer[sizeof(buffer)-1] = 0;
 		g_free(filename);
 		do_save_tables(buffer);
 	}	
@@ -782,7 +786,8 @@ void do_rec(GtkWidget *wid)
 {
 	char buffer[PATH_MAX];
 	
-	strcpy(buffer, gtk_file_selection_get_filename(GTK_FILE_SELECTION(rec_dialog)));
+	strncpy(buffer, gtk_file_selection_get_filename(GTK_FILE_SELECTION(rec_dialog)), sizeof(buffer));
+	buffer[sizeof(buffer)-1] = 0;
 
 	if (strlen(buffer)) {
 		strcpy(globals.record_filename, buffer);		
@@ -1699,8 +1704,8 @@ void tx_note(const char *message, bool i
 
 void tx_l_note(const char *message)
 {
-	char buffer[4096]="Plugin info:\n\n";
-	strcat(buffer, message);
+	char buffer[4096];
+	snprintf(buffer, sizeof(buffer), "Plugin info:\n\n%s", message);
 	
 	GtkWidget *dialog=gtk_message_dialog_new(GTK_WINDOW(main_window),
 		GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE, "%s", message);
--- src/tX_global.h-dist	2004-11-03 14:25:50.000000000 +0100
+++ src/tX_global.h	2005-01-21 13:35:47.328135921 +0100
@@ -196,7 +196,7 @@ extern char *decode_xml(char *dest, cons
 /* some ugly XML macros... */
 #define restore_int(s, i); if ((!elementFound) && (!xmlStrcmp(cur->name, (const xmlChar *) s))) { elementFound=1; if (xmlNodeListGetString(doc, cur->xmlChildrenNode, 1)) { sscanf((char *) xmlNodeListGetString(doc, cur->xmlChildrenNode, 1), "%i", &i); }}
 #define restore_float(s, i); if ((!elementFound) && (!xmlStrcmp(cur->name, (const xmlChar *) s))) { elementFound=1; if  (xmlNodeListGetString(doc, cur->xmlChildrenNode, 1)) {sscanf((char *) xmlNodeListGetString(doc, cur->xmlChildrenNode, 1), "%lf", &dvalue); i=dvalue;}}
-#define restore_string(s, i); if ((!elementFound) && (!xmlStrcmp(cur->name, (const xmlChar *) s))) { elementFound=1; if (xmlNodeListGetString(doc, cur->xmlChildrenNode, 1)) {strcpy(i, decode_xml(tmp_xml_buffer, (const char *)  xmlNodeListGetString(doc, cur->xmlChildrenNode, 1))); }}
+#define restore_string(s, i); if ((!elementFound) && (!xmlStrcmp(cur->name, (const xmlChar *) s))) { elementFound=1; if (xmlNodeListGetString(doc, cur->xmlChildrenNode, 1)) {strncpy(i, decode_xml(tmp_xml_buffer, (const char *)  xmlNodeListGetString(doc, cur->xmlChildrenNode, 1)), sizeof(i)); i[sizeof(i)-1] = 0;}}
 #define restore_bool(s, i); if ((!elementFound) && (!xmlStrcmp(cur->name, (const xmlChar *) s))) { elementFound=1; if (xmlNodeListGetString(doc, cur->xmlChildrenNode, 1)) {if (xmlStrcmp(xmlNodeListGetString(doc, cur->xmlChildrenNode, 1),  (const xmlChar *) "true")==0) i=true; else i=false; }}
 #define restore_id(s, sp); if ((!elementFound) && (!xmlStrcmp(cur->name, (const xmlChar *) s))) { elementFound=1; pid_attr=(char* ) xmlGetProp(cur, (xmlChar *) "id"); if (pid_attr) { sscanf(pid_attr, "%i",  &pid); sp.set_persistence_id(pid); }}
 
--- src/main.cc-dist	2004-03-26 20:13:24.000000000 +0100
+++ src/main.cc	2005-01-21 13:35:47.330135547 +0100
@@ -139,6 +139,8 @@ int parse_args(int *argc, char **argv)
 		if ((strcmp(argv[i], "-f") == 0) || (strcmp(argv[i], "--file") == 0)) {
 			++i;
 			globals.startup_set = argv[i];
+			if (strlen(globals.startup_set) >= PATH_MAX)
+				globals.startup_set[PATH_MAX] = 0;
 		} else if (((strcmp(argv[i], "-r") == 0) || (strcmp(argv[i], "--rc-file") == 0)) && (argv[i+1])) {
 			++i;
 			globals.alternate_rc = argv[i];
