Skip to content

[GEN][ZH] Fix several potential buffer overruns in game code #849

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
May 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions Core/Libraries/Source/WWVegas/WW3D2/dynamesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -587,9 +587,6 @@ DynamicMeshClass::DynamicMeshClass(const DynamicMeshClass & src) :

MultiVertexMaterial[pass] = src.MultiVertexMaterial[pass];
VertexMaterialIdx[pass] = src.VertexMaterialIdx[pass];

MultiVertexColor[pass] = src.MultiVertexColor[pass];
CurVertexColor[pass] = src.CurVertexColor[pass];
}

for (int color_array_index = 0; color_array_index < MAX_COLOR_ARRAYS; color_array_index++) {
Expand Down
2 changes: 1 addition & 1 deletion Core/Libraries/Source/WWVegas/WWDownload/ftp.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class Cftp
char m_szRemoteFilePath[128];
char m_szRemoteFileName[128];
char m_szLocalFilePath[128];
char m_szLocalFileName[128];
char m_szLocalFileName[256];
char m_szServerName[128];
char m_szUserName[128];
char m_szPassword[128];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ UnicodeString getUnicodeDateBuffer(SYSTEMTIME timeVal)
DATE_SHORTDATE,
&timeVal,
NULL,
dateBuffer, sizeof(dateBuffer) );
dateBuffer, ARRAY_SIZE(dateBuffer) );
displayDateBuffer.set(dateBuffer);
return displayDateBuffer;
//displayDateBuffer.format( L"%ls", dateBuffer );
Expand Down Expand Up @@ -270,7 +270,7 @@ UnicodeString getUnicodeTimeBuffer(SYSTEMTIME timeVal)
&timeVal,
NULL,
timeBuffer,
sizeof(timeBuffer) );
ARRAY_SIZE(timeBuffer) );
displayTimeBuffer.set(timeBuffer);
return displayTimeBuffer;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ void reallySaveReplay(void)
if(DeleteFile(filename.str()) == 0)
{
wchar_t buffer[1024];
FormatMessageW ( FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, buffer, sizeof(buffer), NULL);
FormatMessageW ( FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, buffer, ARRAY_SIZE(buffer), NULL);
UnicodeString errorStr;
errorStr.set(buffer);
errorStr.trim();
Expand All @@ -313,7 +313,7 @@ void reallySaveReplay(void)
if(CopyFile(oldFilename.str(),filename.str(), FALSE) == 0)
{
wchar_t buffer[1024];
FormatMessageW( FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, buffer, sizeof(buffer), NULL);
FormatMessageW( FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, buffer, ARRAY_SIZE(buffer), NULL);
UnicodeString errorStr;
errorStr.set(buffer);
errorStr.trim();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ void copyReplay( void )
if(CopyFile(filename.str(),newFilename.str(), FALSE) == 0)
{
wchar_t buffer[1024];
FormatMessageW( FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, buffer, sizeof(buffer), NULL);
FormatMessageW( FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, buffer, ARRAY_SIZE(buffer), NULL);
UnicodeString errorStr;
errorStr.set(buffer);
errorStr.trim();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,11 @@ void W3DMouse::initD3DAssets(void)
for (Int j=0; j < MAX_2D_CURSOR_ANIM_FRAMES; j++)
{
cursorTextures[i][j]=NULL;//am->Get_Texture(m_cursorInfo[i].textureName.str());
m_currentD3DSurface[i]=NULL;
}
}

for (Int x = 0; x < MAX_2D_CURSOR_ANIM_FRAMES; x++)
m_currentD3DSurface[x]=NULL;
}
}

Expand Down
2 changes: 1 addition & 1 deletion Generals/Code/Libraries/Source/WWVegas/WW3D2/rinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ MaterialPassClass * RenderInfoClass::Peek_Additional_Pass(int i)
void RenderInfoClass::Push_Override_Flags(RINFO_OVERRIDE_FLAGS flg)
{
// copy to the end of the array
WWASSERT(OverrideFlagLevel<MAX_OVERRIDE_FLAG_LEVEL);
WWASSERT(OverrideFlagLevel<MAX_OVERRIDE_FLAG_LEVEL - 1);
OverrideFlagLevel++;
OverrideFlag[OverrideFlagLevel]=flg;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ UnicodeString getUnicodeDateBuffer(SYSTEMTIME timeVal)
DATE_SHORTDATE,
&timeVal,
NULL,
dateBuffer, sizeof(dateBuffer) );
dateBuffer, ARRAY_SIZE(dateBuffer) );
displayDateBuffer.set(dateBuffer);
return displayDateBuffer;
//displayDateBuffer.format( L"%ls", dateBuffer );
Expand Down Expand Up @@ -270,7 +270,7 @@ UnicodeString getUnicodeTimeBuffer(SYSTEMTIME timeVal)
&timeVal,
NULL,
timeBuffer,
sizeof(timeBuffer) );
ARRAY_SIZE(timeBuffer) );
displayTimeBuffer.set(timeBuffer);
return displayTimeBuffer;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ void reallySaveReplay(void)
if(DeleteFile(filename.str()) == 0)
{
wchar_t buffer[1024];
FormatMessageW ( FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, buffer, sizeof(buffer), NULL);
FormatMessageW ( FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, buffer, ARRAY_SIZE(buffer), NULL);
UnicodeString errorStr;
errorStr.set(buffer);
errorStr.trim();
Expand All @@ -313,7 +313,7 @@ void reallySaveReplay(void)
if(CopyFile(oldFilename.str(),filename.str(), FALSE) == 0)
{
wchar_t buffer[1024];
FormatMessageW( FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, buffer, sizeof(buffer), NULL);
FormatMessageW( FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, buffer, ARRAY_SIZE(buffer), NULL);
UnicodeString errorStr;
errorStr.set(buffer);
errorStr.trim();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ void copyReplay( void )
if(CopyFile(filename.str(),newFilename.str(), FALSE) == 0)
{
wchar_t buffer[1024];
FormatMessageW( FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, buffer, sizeof(buffer), NULL);
FormatMessageW( FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, buffer, ARRAY_SIZE(buffer), NULL);
UnicodeString errorStr;
errorStr.set(buffer);
errorStr.trim();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,11 @@ void W3DMouse::initD3DAssets(void)
for (Int j=0; j < MAX_2D_CURSOR_ANIM_FRAMES; j++)
{
cursorTextures[i][j]=NULL;//am->Get_Texture(m_cursorInfo[i].textureName.str());
m_currentD3DSurface[i]=NULL;
}
}

for (Int x = 0; x < MAX_2D_CURSOR_ANIM_FRAMES; x++)
m_currentD3DSurface[x]=NULL;
}
}

Expand Down
2 changes: 1 addition & 1 deletion GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/rinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ MaterialPassClass * RenderInfoClass::Peek_Additional_Pass(int i)
void RenderInfoClass::Push_Override_Flags(RINFO_OVERRIDE_FLAGS flg)
{
// copy to the end of the array
WWASSERT(OverrideFlagLevel<MAX_OVERRIDE_FLAG_LEVEL);
WWASSERT(OverrideFlagLevel<MAX_OVERRIDE_FLAG_LEVEL - 1);
OverrideFlagLevel++;
OverrideFlag[OverrideFlagLevel]=flg;
}
Expand Down
Loading