Index: /Daodan/src/Daodan.c
===================================================================
--- /Daodan/src/Daodan.c	(revision 680)
+++ /Daodan/src/Daodan.c	(revision 681)
@@ -556,17 +556,20 @@
 	char v6[512]; // [sp+0h] [bp-100h]@1
 	FILE* UUgError_WarningFile = *_UUgError_WarningFile;
-	sprintf_s(
-		v6, 512,
-		"Error %x reported from File: %s, Line: %d (message follows) \r\n%s",
-		errornum,
-		filename,
-		linenumber,
-		message);
-
-	if ( UUgError_WarningFile 
-		|| (UUgError_WarningFile = oni_fopen("debugger.txt", "wb"), UUgError_WarningFile ) )
-	{ 
-		oni_fprintf(UUgError_WarningFile, "%s\r\n", v6);
-		oni_fflush(UUgError_WarningFile);
+
+	if (filename && message && (strlen(filename)+strlen(message))<420) {
+		sprintf(
+			v6,
+			"Error %x reported from File: %s, Line: %d (message follows) \r\n%s",
+			errornum,
+			filename,
+			linenumber,
+			message);
+
+		if ( UUgError_WarningFile 
+			|| (UUgError_WarningFile = oni_fopen("debugger.txt", "wb"), UUgError_WarningFile ) )
+		{ 
+			oni_fprintf(UUgError_WarningFile, "%s\r\n", v6);
+			oni_fflush(UUgError_WarningFile);
+		}
 	}
 	//oni_fprintf(stdout, v6);
Index: /Daodan/src/Daodan_BSL.c
===================================================================
--- /Daodan/src/Daodan_BSL.c	(revision 680)
+++ /Daodan/src/Daodan_BSL.c	(revision 681)
@@ -864,11 +864,14 @@
 	char argfmt2[512];
 	uint16_t errornum;
-	sprintf_s(argfmt2, 512, "%s [|]", argfmt);
-	errornum = SLrScript_Command_Register_ReturnType(name, desc, argfmt2, type, callback);
-	if(errornum)
-	{
-		DDrStartupMessage("Registration of script command %s failed with error %i", name, errornum);
-	}
-
+	if (argfmt && strlen(argfmt) < 507) {
+		sprintf(argfmt2, "%s [|]", argfmt);
+		errornum = SLrScript_Command_Register_ReturnType(name, desc, argfmt2, type, callback);
+		if(errornum)
+		{
+			DDrStartupMessage("Registration of script command %s failed with error %i", name, errornum);
+		}
+	} else {
+		DDrStartupMessage("Registration of script command %s failed because of a too long argfmt", name);
+	}
 }
 
Index: /Daodan/src/Daodan_Utility.c
===================================================================
--- /Daodan/src/Daodan_Utility.c	(revision 680)
+++ /Daodan/src/Daodan_Utility.c	(revision 681)
@@ -160,5 +160,5 @@
 					if(clipboardText && strlen(clipboardText) + charsUsed < 502)
 					{
-						strcpy_s( cons->text_entries[0].text + charsUsed, 502 - charsUsed - 1, clipboardText);
+						strcpy_s( cons->text_entries[0].text + charsUsed, clipboardText);
 						lastPasteTime = ONgGameState->GameTime;
 					}
