r1226 - trunk/code/qcommon

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sun Dec 2 19:07:56 EST 2007


Author: tma
Date: 2007-12-02 19:07:56 -0500 (Sun, 02 Dec 2007)
New Revision: 1226

Modified:
   trunk/code/qcommon/common.c
Log:
* (bug 3454) Fix crash in autocompletion due to incorrect strncpy buffer size


Modified: trunk/code/qcommon/common.c
===================================================================
--- trunk/code/qcommon/common.c	2007-12-02 13:30:12 UTC (rev 1225)
+++ trunk/code/qcommon/common.c	2007-12-03 00:07:56 UTC (rev 1226)
@@ -3292,6 +3292,8 @@
 	}
 	else
 	{
+		int completionOffset;
+
 		if( completionString[0] == '\\' || completionString[0] == '/' )
 			completionString++;
 
@@ -3310,10 +3312,11 @@
 		if( matchCount == 0 )
 			return; // no matches
 
-		Q_strncpyz( &completionField->buffer[ strlen( completionField->buffer ) -
-			strlen( completionString ) ], shortestMatch,
-			sizeof( completionField->buffer ) );
+		completionOffset = strlen( completionField->buffer ) - strlen( completionString );
 
+		Q_strncpyz( &completionField->buffer[ completionOffset ], shortestMatch,
+			sizeof( completionField->buffer ) - completionOffset );
+
 		completionField->cursor = strlen( completionField->buffer );
 
 		if( matchCount == 1 )




More information about the quake3-commits mailing list