fixed an issue in Fileprintf() with too short buffer for vsprintf. switched to more secure version vsnprintf() (that is, in fact avail since VS6 but not as secure as vsprintf_s()).

Also inflated the buffer to fit the messages from XML-Writer code (is executed in debug mode only).
The inflation has nothing to do with the securing, its only for comfort of the XML writers log messages.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@1071 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Sergeant_Kolja
2007-07-17 20:18:02 +00:00
parent cab825a382
commit 883557c87d
+9 -2
View File
@@ -777,9 +777,15 @@ BOOLEAN FileLoad( STR strFilename, PTR pDest, UINT32 uiBytesToRead, UINT32 *puiB
// 9 Feb 98 DEF - modified to work with the library system
//
//**************************************************************************
#ifndef DIM
# define DIM(x) (sizeof(x)/sizeof(x[0])) /* made StringLen Save, Sergeant_Kolja, 2007-06-10 */
#endif
BOOLEAN _cdecl FilePrintf( HWFILE hFile, STR8 strFormatted, ... )
{
CHAR8 strToSend[80];
CHAR8 strToSend[160]; /* itemdescription of item 0 will NOT fit if only 80 Chars per Line!, Sergeant_Kolja, 2007-06-10 */
va_list argptr;
BOOLEAN fRetVal = FALSE;
@@ -792,7 +798,8 @@ BOOLEAN _cdecl FilePrintf( HWFILE hFile, STR8 strFormatted, ... )
if( sLibraryID == REAL_FILE_LIBRARY_ID )
{
va_start(argptr, strFormatted);
vsprintf( strToSend, strFormatted, argptr );
_vsnprintf( strToSend, DIM(strToSend), strFormatted, argptr ); /* made StringLen Save, Sergeant_Kolja, 2007-06-10 */
strToSend[ DIM(strToSend)-1 ] = 0;
va_end(argptr);
fRetVal = FileWrite( hFile, strToSend, strlen(strToSend), NULL );