changeset 6107:b46247236c4f draft

(svn r8843) -Fix -Fix: Off-by-one error in accessing a buffer (if you start at the second byte you have to subtract one from the size) Also avoid an unnecessary buffer copy and strlcpy() abuse NOTE: 0.5 candidate
author tron <tron@openttd.org>
date Thu, 22 Feb 2007 15:01:38 +0000
parents 230764f1a316
children 9cdb931d4e64
files src/newgrf.cpp
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -2729,11 +2729,11 @@
 	 *
 	 * V ignored       Anything following the 0C is ignored */
 
-	static char comment[256];
 	if (len == 1) return;
 
-	ttd_strlcpy(comment, (char*)(buf + 1), minu(sizeof(comment), len));
-	grfmsg(2, "GRFComment: %s", comment);
+	int text_len = len - 1;
+	const char *text = (const char*)(buf + 1);
+	grfmsg(2, "GRFComment: %.*s", text_len, text);
 }
 
 /* Action 0x0D (GLS_SAFETYSCAN) */