r955 - in branches/1.34/code: botlib client unix

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Thu Oct 26 11:13:52 EDT 2006


Author: ludwig
Date: 2006-10-26 11:13:52 -0400 (Thu, 26 Oct 2006)
New Revision: 955

Modified:
   branches/1.34/code/botlib/l_precomp.c
   branches/1.34/code/client/cl_main.c
   branches/1.34/code/client/qal.c
   branches/1.34/code/unix/unix_main.c
Log:
fix wrong use of strncat


Modified: branches/1.34/code/botlib/l_precomp.c
===================================================================
--- branches/1.34/code/botlib/l_precomp.c	2006-10-26 15:09:42 UTC (rev 954)
+++ branches/1.34/code/botlib/l_precomp.c	2006-10-26 15:13:52 UTC (rev 955)
@@ -469,9 +469,9 @@
 	strcat(token->string, "\"");
 	for (t = tokens; t; t = t->next)
 	{
-		strncat(token->string, t->string, MAX_TOKEN - strlen(token->string));
+		strncat(token->string, t->string, MAX_TOKEN - strlen(token->string) - 1);
 	} //end for
-	strncat(token->string, "\"", MAX_TOKEN - strlen(token->string));
+	strncat(token->string, "\"", MAX_TOKEN - strlen(token->string) - 1);
 	return qtrue;
 } //end of the function PC_StringizeTokens
 //============================================================================
@@ -1015,7 +1015,7 @@
 				break;
 			} //end if
 			if (token.type == TT_PUNCTUATION && *token.string == '>') break;
-			strncat(path, token.string, MAX_PATH);
+			strncat(path, token.string, MAX_PATH - 1);
 		} //end while
 		if (*token.string != '>')
 		{

Modified: branches/1.34/code/client/cl_main.c
===================================================================
--- branches/1.34/code/client/cl_main.c	2006-10-26 15:09:42 UTC (rev 954)
+++ branches/1.34/code/client/cl_main.c	2006-10-26 15:13:52 UTC (rev 955)
@@ -2784,7 +2784,7 @@
 	Q_strncpyz( info, MSG_ReadString( msg ), MAX_INFO_STRING );
 	if (strlen(info)) {
 		if (info[strlen(info)-1] != '\n') {
-			strncat(info, "\n", sizeof(info));
+			strncat(info, "\n", sizeof(info) - 1);
 		}
 		Com_Printf( "%s: %s", NET_AdrToString( from ), info );
 	}

Modified: branches/1.34/code/client/qal.c
===================================================================
--- branches/1.34/code/client/qal.c	2006-10-26 15:09:42 UTC (rev 954)
+++ branches/1.34/code/client/qal.c	2006-10-26 15:13:52 UTC (rev 955)
@@ -176,8 +176,8 @@
 #else
 		char fn[1024];
 		getcwd(fn, sizeof(fn));
-		strncat(fn, "/", sizeof(fn));
-		strncat(fn, libname, sizeof(fn));
+		strncat(fn, "/", sizeof(fn) - strlen(fn) - 1);
+		strncat(fn, libname, sizeof(fn) - strlen(fn) - 1);
 
 		if( (OpenALLib = OBJLOAD(fn)) == 0 )
 		{

Modified: branches/1.34/code/unix/unix_main.c
===================================================================
--- branches/1.34/code/unix/unix_main.c	2006-10-26 15:09:42 UTC (rev 954)
+++ branches/1.34/code/unix/unix_main.c	2006-10-26 15:13:52 UTC (rev 955)
@@ -1236,7 +1236,7 @@
     if( msg[ i ] == '\n' )
     {
       Com_sprintf( tempBuffer, 7, "%c[0m\n", 0x1B );
-      strncat( buffer, tempBuffer, bufferSize );
+      strncat( buffer, tempBuffer, bufferSize - 1);
       i++;
     }
     else if( msg[ i ] == Q_COLOR_ESCAPE )
@@ -1258,7 +1258,7 @@
         if( escapeCode )
         {
           Com_sprintf( tempBuffer, 7, "%c[%sm", 0x1B, escapeCode );
-          strncat( buffer, tempBuffer, bufferSize );
+          strncat( buffer, tempBuffer, bufferSize - 1);
         }
 
         i++;
@@ -1267,7 +1267,7 @@
     else
     {
       Com_sprintf( tempBuffer, 7, "%c", msg[ i++ ] );
-      strncat( buffer, tempBuffer, bufferSize );
+      strncat( buffer, tempBuffer, bufferSize - 1);
     }
   }
 }




More information about the quake3-commits mailing list