Skip to content

Commit cb0e405

Browse files
authored
Merge pull request #133 from SanyaSho/master
string vulnerabilities
2 parents 006f825 + e368f3e commit cb0e405

File tree

7 files changed

+23
-23
lines changed

7 files changed

+23
-23
lines changed

game/client/message.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,7 @@ void CHudMessage::AddChar( int r, int g, int b, int a, wchar_t ch )
987987
//-----------------------------------------------------------------------------
988988
void CHudMessage::GetTextExtents( int *wide, int *tall, const char *string )
989989
{
990-
*wide = g_pMatSystemSurface->DrawTextLen( m_hFont, (char *)string );
990+
*wide = g_pMatSystemSurface->DrawTextLen( m_hFont, "%s", (char *)string );
991991
*tall = vgui::surface()->GetFontTall( m_hFont );
992992
}
993993

@@ -1067,4 +1067,4 @@ void CHudMessage::PaintCharacters()
10671067
void CHudMessage::GetLength( int *wide, int *tall, const char *string )
10681068
{
10691069
GetTextExtents( wide, tall, string );
1070-
}
1070+
}

game/client/vgui_messagechars.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ int CMessageCharsPanel::AddText(
252252
msg->hCustomFont = m_hFont;
253253

254254
// Return new cursor position
255-
return x + g_pMatSystemSurface->DrawTextLen( msg->hCustomFont, data );
255+
return x + g_pMatSystemSurface->DrawTextLen( msg->hCustomFont, "%s", data );
256256
}
257257

258258
//-----------------------------------------------------------------------------
@@ -272,7 +272,7 @@ void CMessageCharsPanel::GetTextExtents( vgui::HFont hCustomFont, int *wide, int
272272

273273
Assert( hCustomFont );
274274

275-
*wide = g_pMatSystemSurface->DrawTextLen( hCustomFont, (char *)string );
275+
*wide = g_pMatSystemSurface->DrawTextLen( hCustomFont, "%s", (char *)string );
276276
*tall = vgui::surface()->GetFontTall( hCustomFont );
277277
}
278278

@@ -310,7 +310,7 @@ void CMessageCharsPanel::Paint()
310310
CMessageCharsPanel::message_t *msg = m_pActive;
311311
while ( msg )
312312
{
313-
g_pMatSystemSurface->DrawColoredText( msg->hCustomFont, msg->x, msg->y, msg->r, msg->g, msg->b, msg->a, msg->text );
313+
g_pMatSystemSurface->DrawColoredText( msg->hCustomFont, msg->x, msg->y, msg->r, msg->g, msg->b, msg->a, "%s", msg->text );
314314
msg = msg->next;
315315
}
316316

game/client/vgui_netgraphpanel.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -733,8 +733,8 @@ void CNetGraphPanel::DrawTextFields( int graphvalue, int x, int y, int w, netban
733733
int textTall = surface()->GetFontTall( font );
734734

735735
Q_snprintf( sz, sizeof( sz ), "fps:%4i ping: %i ms", (int)(1.0f / m_Framerate), (int)(m_AvgLatency*1000.0f) );
736-
737-
g_pMatSystemSurface->DrawColoredText( font, x, y, GRAPH_RED, GRAPH_GREEN, GRAPH_BLUE, 255, sz );
736+
737+
g_pMatSystemSurface->DrawColoredText( font, x, y, GRAPH_RED, GRAPH_GREEN, GRAPH_BLUE, 255, "%s", sz );
738738

739739
// Draw update rate
740740
DrawUpdateRate( x + w, y );
@@ -752,12 +752,12 @@ void CNetGraphPanel::DrawTextFields( int graphvalue, int x, int y, int w, netban
752752
}
753753

754754
int totalsize = graph[ ( m_IncomingSequence & ( TIMINGS - 1 ) ) ].msgbytes[INetChannelInfo::TOTAL];
755-
755+
756756
Q_snprintf( sz, sizeof( sz ), "in :%4i %2.2f k/s ", totalsize, m_IncomingData );
757757

758758
int textWidth = g_pMatSystemSurface->DrawTextLen( font, "%s", sz );
759759

760-
g_pMatSystemSurface->DrawColoredText( font, x, y, GRAPH_RED, GRAPH_GREEN, GRAPH_BLUE, 255, sz );
760+
g_pMatSystemSurface->DrawColoredText( font, x, y, GRAPH_RED, GRAPH_GREEN, GRAPH_BLUE, 255, "%s", sz );
761761

762762
Q_snprintf( sz, sizeof( sz ), "lerp: %5.1f ms", GetClientInterpAmount() * 1000.0f );
763763

@@ -781,23 +781,23 @@ void CNetGraphPanel::DrawTextFields( int graphvalue, int x, int y, int w, netban
781781
}
782782
}
783783

784-
g_pMatSystemSurface->DrawColoredText( font, x + textWidth, y, interpcolor[ 0 ], interpcolor[ 1 ], interpcolor[ 2 ], 255, sz );
784+
g_pMatSystemSurface->DrawColoredText( font, x + textWidth, y, interpcolor[ 0 ], interpcolor[ 1 ], interpcolor[ 2 ], 255, "%s", sz );
785785

786786
Q_snprintf( sz, sizeof( sz ), "%3.1f/s", m_AvgPacketIn );
787787
textWidth = g_pMatSystemSurface->DrawTextLen( font, "%s", sz );
788788

789-
g_pMatSystemSurface->DrawColoredText( font, x + w - textWidth - 1, y, GRAPH_RED, GRAPH_GREEN, GRAPH_BLUE, 255, sz );
789+
g_pMatSystemSurface->DrawColoredText( font, x + w - textWidth - 1, y, GRAPH_RED, GRAPH_GREEN, GRAPH_BLUE, 255, "%s", sz );
790790

791791
y += textTall;
792792

793793
Q_snprintf( sz, sizeof( sz ), "out:%4i %2.2f k/s", out, m_OutgoingData );
794794

795-
g_pMatSystemSurface->DrawColoredText( font, x, y, GRAPH_RED, GRAPH_GREEN, GRAPH_BLUE, 255, sz );
795+
g_pMatSystemSurface->DrawColoredText( font, x, y, GRAPH_RED, GRAPH_GREEN, GRAPH_BLUE, 255, "%s", sz );
796796

797797
Q_snprintf( sz, sizeof( sz ), "%3.1f/s", m_AvgPacketOut );
798798
textWidth = g_pMatSystemSurface->DrawTextLen( font, "%s", sz );
799799

800-
g_pMatSystemSurface->DrawColoredText( font, x + w - textWidth - 1, y, GRAPH_RED, GRAPH_GREEN, GRAPH_BLUE, 255, sz );
800+
g_pMatSystemSurface->DrawColoredText( font, x + w - textWidth - 1, y, GRAPH_RED, GRAPH_GREEN, GRAPH_BLUE, 255, "%s", sz );
801801

802802
y += textTall;
803803

@@ -809,7 +809,7 @@ void CNetGraphPanel::DrawTextFields( int graphvalue, int x, int y, int w, netban
809809

810810
textWidth = g_pMatSystemSurface->DrawTextLen( font, "%s", sz );
811811

812-
g_pMatSystemSurface->DrawColoredText( font, x, y, GRAPH_RED, GRAPH_GREEN, GRAPH_BLUE, 255, sz );
812+
g_pMatSystemSurface->DrawColoredText( font, x, y, GRAPH_RED, GRAPH_GREEN, GRAPH_BLUE, 255, "%s", sz );
813813

814814
y += textTall;
815815

@@ -832,7 +832,7 @@ void CNetGraphPanel::DrawTextFields( int graphvalue, int x, int y, int w, netban
832832
servercolor[ 2 ] = 0;
833833
}
834834

835-
g_pMatSystemSurface->DrawColoredText( font, x, y, servercolor[ 0 ], servercolor[ 1 ], servercolor[ 2 ], 255, sz );
835+
g_pMatSystemSurface->DrawColoredText( font, x, y, servercolor[ 0 ], servercolor[ 1 ], servercolor[ 2 ], 255, "%s", sz );
836836

837837
y += textTall;
838838
}
@@ -1119,14 +1119,14 @@ void CNetGraphPanel::DrawLargePacketSizes( int x, int w, int graphtype, float wa
11191119
char sz[ 32 ];
11201120
Q_snprintf( sz, sizeof( sz ), "%i", nTotalBytes );
11211121

1122-
int len = g_pMatSystemSurface->DrawTextLen( m_hFont, sz );
1122+
int len = g_pMatSystemSurface->DrawTextLen( m_hFont, "%s", sz );
11231123

11241124
int textx, texty;
11251125

11261126
textx = rcFill.x - len / 2;
11271127
texty = MAX( 0, rcFill.y - 11 );
11281128

1129-
g_pMatSystemSurface->DrawColoredText( m_hFont, textx, texty, 255, 255, 255, 255, sz );
1129+
g_pMatSystemSurface->DrawColoredText( m_hFont, textx, texty, 255, 255, 255, 255, "%s", sz );
11301130
}
11311131
}
11321132
}

game/client/vgui_textmessagepanel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ void CTextMessagePanel::AddChar( int r, int g, int b, int a, wchar_t ch )
238238
//-----------------------------------------------------------------------------
239239
void CTextMessagePanel::GetTextExtents( int *wide, int *tall, const char *string )
240240
{
241-
*wide = g_pMatSystemSurface->DrawTextLen( m_hFont, (char *)string );
241+
*wide = g_pMatSystemSurface->DrawTextLen( m_hFont, "%s", (char *)string );
242242
*tall = vgui::surface()->GetFontTall( m_hFont );
243243
}
244244

game/server/ai_speech.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -885,13 +885,13 @@ void CAI_Expresser::SpeechMsg( CBaseEntity *pFlex, const char *pszFormat, ... )
885885

886886
if ( pFlex->MyNPCPointer() )
887887
{
888-
DevMsg( pFlex->MyNPCPointer(), string );
888+
DevMsg( pFlex->MyNPCPointer(), "%s", string );
889889
}
890890
else
891891
{
892892
DevMsg( "%s", string );
893893
}
894-
UTIL_LogPrintf( string );
894+
UTIL_LogPrintf( "%s", string );
895895
}
896896

897897

@@ -1042,4 +1042,4 @@ void CMultiplayer_Expresser::AllowMultipleScenes()
10421042
void CMultiplayer_Expresser::DisallowMultipleScenes()
10431043
{
10441044
m_bAllowMultipleScenes = false;
1045-
}
1045+
}

game/server/util.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void DBG_AssertFunction( bool fExpr, const char *szExpr, const char *szFile, int
5959
Q_snprintf(szOut,sizeof(szOut), "ASSERT FAILED:\n %s \n(%s@%d)\n%s", szExpr, szFile, szLine, szMessage);
6060
else
6161
Q_snprintf(szOut,sizeof(szOut), "ASSERT FAILED:\n %s \n(%s@%d)\n", szExpr, szFile, szLine);
62-
Warning( szOut);
62+
Warning( "%s", szOut );
6363
}
6464
#endif // DEBUG
6565

vgui2/dme_controls/dmedagrenderpanel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ void CDmeDagRenderPanel::DrawJointNames( CDmeDag *pRoot, CDmeDag *pDag, const ma
263263
{
264264
Q_snprintf( pJointName, sizeof(pJointName), "%s", pJoint->GetName() );
265265
}
266-
g_pMatSystemSurface->DrawColoredText( m_hFont, vecPanelPos.x + 5, vecPanelPos.y, 255, 255, 255, 255, pJointName );
266+
g_pMatSystemSurface->DrawColoredText( m_hFont, vecPanelPos.x + 5, vecPanelPos.y, 255, 255, 255, 255, "%s", pJointName );
267267
}
268268

269269
int nCount = pDag->GetChildCount();

0 commit comments

Comments
 (0)