Skip to content

Commit 81f6cd7

Browse files
committed
LoadGame: fix another possible format truncation
1 parent efa676f commit 81f6cd7

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

menus/LoadGame.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ void CMenuSavesListModel::Update( void )
199199
{
200200
save_t save;
201201
char comment[256];
202+
char time[CS_TIME];
203+
char date[CS_TIME];
202204

203205
// strip path, leave only filename (empty slots doesn't have savename)
204206
COM_FileBase( filenames[i], save.name, sizeof( save.name ));
@@ -220,7 +222,10 @@ void CMenuSavesListModel::Update( void )
220222

221223
// they are defined by comment string format
222224
// time and date
223-
snprintf( save.date, sizeof( save.date ), "%s %s", comment + CS_SIZE, comment + CS_SIZE + CS_TIME );
225+
Q_strncpy( time, comment + CS_SIZE, CS_TIME );
226+
Q_strncpy( date, comment + CS_SIZE + CS_TIME, CS_TIME );
227+
228+
snprintf( save.date, sizeof( save.date ), "%s %s", time, date );
224229

225230
// ingame time
226231
Q_strncpy( save.elapsed_time, comment + CS_SIZE + CS_TIME * 2, sizeof( save.elapsed_time ));
@@ -253,7 +258,7 @@ void CMenuSavesListModel::Update( void )
253258
Q_strncpy( s, title, sizeof( s ));
254259

255260
if( type )
256-
snprintf( save.comment, sizeof( save.comment ), "[%s]%s", type, L( s ));
261+
snprintf( save.comment, sizeof( save.comment ), "[%.16s]%s", type, L( s ));
257262
else Q_strncpy( save.comment, L( s ), sizeof( save.comment ));
258263
}
259264
else

0 commit comments

Comments
 (0)