$OpenBSD: patch-src_main_Rdynload_c,v 1.3 2007/08/09 22:22:17 steven Exp $
--- src/main/Rdynload.c.orig	Mon Mar 26 18:42:08 2007
+++ src/main/Rdynload.c	Thu Aug  9 00:44:00 2007
@@ -519,7 +519,8 @@ static DllInfo* AddDLL(char *path, int asLocal, int no
 
     DeleteDLL(path);
     if(CountDLL == MAX_NUM_DLLS) {
-	strcpy(DLLerror, _("Maximal number of DLLs reached..."));
+	strlcpy(DLLerror, _("Maximal number of DLLs reached..."),
+	    sizeof(DLLerror));
 	return NULL;
     }
 
@@ -572,11 +573,12 @@ static DllInfo *R_RegisterDLL(HINSTANCE handle, const 
 
     dpath = (char *) malloc(strlen(path)+1);
     if(dpath == NULL) {
-	strcpy(DLLerror, _("could not allocate space for 'path'"));
+	strlcpy(DLLerror, _("could not allocate space for 'path'"),
+	    sizeof(DLLerror));
 	R_osDynSymbol->closeLibrary(handle);
 	return 0;
     }
-    strcpy(dpath, path);
+    strlcpy(dpath, path, strlen(path) + 1);
 
     if(R_osDynSymbol->fixPath)
 	R_osDynSymbol->fixPath(dpath);
@@ -584,7 +586,7 @@ static DllInfo *R_RegisterDLL(HINSTANCE handle, const 
     /* keep only basename from path */
     p = Rf_strrchr(dpath, FILESEP[0]);
     if(!p) p = dpath; else p++;
-    if(strlen(p) < PATH_MAX) strcpy(DLLname, p);
+    if(strlen(p) < PATH_MAX) strlcpy(DLLname, p, sizeof(DLLname));
     else error(_("DLLname '%s' is too long"), p);
 
     /* remove SHLIB_EXT if present */
@@ -606,14 +608,15 @@ addDLL(char *dpath, char *DLLname, HINSTANCE handle)
     int ans = CountDLL;
     char *name = (char *) malloc(strlen(DLLname)+1);
     if(name == NULL) {
-	strcpy(DLLerror, _("could not allocate space for 'name'"));
+	strlcpy(DLLerror, _("could not allocate space for 'name'"),
+	    sizeof(DLLname));
 	if(handle)
 	   R_osDynSymbol->closeLibrary(handle);
 	free(dpath);
 	return 0;
     }
 
-    strcpy(name, DLLname);
+    strlcpy(name, DLLname, strlen(DLLname) + 1);
     LoadedDLL[CountDLL].path = dpath;
     LoadedDLL[CountDLL].name = name;
     LoadedDLL[CountDLL].handle = handle;
