[Sphere-axis-commits] CVS: axissvr gwhogsvr.cpp,1.10,1.11
Brought to you by:
pesterle
From: Philip E. <pes...@us...> - 2002-05-15 03:22:32
|
Update of /cvsroot/sphere-axis/axissvr In directory usw-pr-cvs1:/tmp/cvs-serv25507 Modified Files: gwhogsvr.cpp Log Message: Validating length of incoming packets. Index: gwhogsvr.cpp =================================================================== RCS file: /cvsroot/sphere-axis/axissvr/gwhogsvr.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** gwhogsvr.cpp 8 May 2002 18:33:46 -0000 1.10 --- gwhogsvr.cpp 15 May 2002 03:22:29 -0000 1.11 *************** *** 39,43 **** #endif ! #define SVR_VERSION "0.13" #ifdef WIN32 #define SVR_PLATFORM "Win32" --- 39,43 ---- #endif ! #define SVR_VERSION "0.13.0.1" #ifdef WIN32 #define SVR_PLATFORM "Win32" *************** *** 1216,1222 **** { memset(szBuf, 0x00, sizeof(szBuf)); ! memcpy(szBuf, g_pszSpawns + dwBytesSent, MAX_BUFFER); ! dwBytesSent += strlen(szBuf); ! Send(sock, szBuf, strlen(szBuf)); } sprintf(szBuf, ".%c%c", 0x0d, 0x0a ); --- 1216,1225 ---- { memset(szBuf, 0x00, sizeof(szBuf)); ! int bytesToCopy = MAX_BUFFER; ! if ( dwBytesSent + MAX_BUFFER > strlen(g_pszSpawns) ) ! bytesToCopy = strlen(g_pszSpawns) - dwBytesSent; ! memcpy(szBuf, g_pszSpawns + dwBytesSent, bytesToCopy); ! dwBytesSent += bytesToCopy; ! Send(sock, szBuf, bytesToCopy); } sprintf(szBuf, ".%c%c", 0x0d, 0x0a ); *************** *** 1790,1793 **** --- 1793,1802 ---- } i = 0; + // Make sure the length is valid + if ( iLength > iMaxLength ) + { + SysMessage("Error receiving data from socket %ld. The packet length (%ld) is greater than the buffer length.(%ld)", sock, iLength, iMaxLength); + return -4; + } while ( nBytes < iLength ) { |