$OpenBSD: patch-gtk_SciTEGTK_cxx,v 1.2 2007/01/18 10:56:27 steven Exp $
--- gtk/SciTEGTK.cxx.orig	Thu Jan 18 09:11:18 2007
+++ gtk/SciTEGTK.cxx	Thu Jan 18 09:11:18 2007
@@ -495,7 +495,7 @@ SciTEGTK::SciTEGTK(Extension *ext) : Sci
 	triedKill = false;
 	exitStatus = 0;
 	pollID = 0;
-	sprintf(resultsFile, "/tmp/SciTE%x.results",
+	snprintf(resultsFile, sizeof(resultsFile), "/tmp/SciTE%x.results",
 	        static_cast<int>(getpid()));
 	inputHandle = 0;
 
@@ -614,9 +614,9 @@ GtkWidget *SciTEGTK::AddMBButton(GtkWidg
 // This is an internally used function to create pixmaps.
 GdkPixbuf *SciTEGTK::CreatePixbuf(const char *filename) {
 	char path[MAX_PATH + 20];
-	strncpy(path, PIXMAP_PATH, sizeof(path));
-	strcat(path, pathSepString);
-	strcat(path, filename);
+	strlcpy(path, PIXMAP_PATH, sizeof(path));
+	strlcat(path, pathSepString, sizeof(path));
+	strlcat(path, filename, sizeof(path));
 
 	GError *error = NULL;
 	GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(path, &error);
@@ -688,11 +688,11 @@ FilePath SciTEGTK::GetSciteUserHome() {
 
 void SciTEGTK::ShowFileInStatus() {
 	char sbText[1000];
-	sprintf(sbText, " File: ");
+	snprintf(sbText, sizeof(sbText), " File: ");
 	if (filePath.IsUntitled())
-		strcat(sbText, "Untitled");
+		strlcat(sbText, "Untitled", sizeof(sbText));
 	else
-		strcat(sbText, filePath.AsInternal());
+		strlcat(sbText, filePath.AsInternal(), sizeof(sbText));
 	SetStatusBarText(sbText);
 }
 
@@ -2854,7 +2854,7 @@ void SciTEGTK::CreateTranslatedMenu(int 
 				accelKey.clear();	// Allow user to clear accelerator key
 			}
 			userDefinedAccels[i] = new char[accLength + 1];
-			strncpy(userDefinedAccels[i], accelKey.c_str(), accLength + 1);
+			strlcpy(userDefinedAccels[i], accelKey.c_str(), accLength + 1);
 			items[i].accelerator = userDefinedAccels[i];
 		} else {
 			userDefinedAccels[i] = NULL;
@@ -3600,10 +3600,10 @@ int main(int argc, char *argv[]) {
 
 #ifdef __vms
 	// Store the path part of the module name
-	strcpy(g_modulePath, argv[0]);
+	strlcpy(g_modulePath, argv[0], sizeof(g_modulePath));
 	char *p = strstr(g_modulePath, "][");
 	if (p != NULL) {
-		strcpy (p, p + 2);
+		memmove(p, p+2, strlen(p + 2) + 1);
 	}
 	p = strchr(g_modulePath, ']');
 	if (p == NULL) {
@@ -3615,8 +3615,11 @@ int main(int argc, char *argv[]) {
 	if (p != NULL) {
 		*(p + 1) = '\0';
 	}
-	strcpy(g_modulePath, VMSToUnixStyle(g_modulePath));
-	g_modulePath[strlen(g_modulePath) - 1] = '\0';  // remove trailing "/"
+	strlcpy(g_modulePath, VMSToUnixStyle(g_modulePath), sizeof(g_modulePath));
+	// remove trailing "/"
+	size_t last = strlen(g_modulePath) - 1;
+	if (last && g_modulePath[last] = '/';
+		g_modulePath[last] = 0;
 #endif
 
 	gtk_set_locale();
