$OpenBSD: patch-src_main_Rdynload_c,v 1.5 2008/10/26 23:04:00 mbalmer Exp $ --- src/main/Rdynload.c.orig Sun Sep 21 22:05:25 2008 +++ src/main/Rdynload.c Sat Oct 25 23:31:38 2008 @@ -533,7 +533,8 @@ static DllInfo* AddDLL(const char *path, int asLocal, 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; } @@ -586,11 +587,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); @@ -598,7 +600,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 */ @@ -620,14 +622,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;