mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-01-31 12:30:32 +00:00
- fixed buffer overflow in saved game comment
https://forum.zdoom.org/viewtopic.php?t=61465
This commit is contained in:
parent
e9041c0697
commit
269ca3155a
1 changed files with 4 additions and 11 deletions
|
@ -2177,32 +2177,25 @@ static void PutSaveWads (FSerializer &arc)
|
||||||
|
|
||||||
static void PutSaveComment (FSerializer &arc)
|
static void PutSaveComment (FSerializer &arc)
|
||||||
{
|
{
|
||||||
char comment[256];
|
|
||||||
const char *readableTime;
|
const char *readableTime;
|
||||||
uint16_t len;
|
|
||||||
int levelTime;
|
int levelTime;
|
||||||
|
|
||||||
// Get the current date and time
|
// Get the current date and time
|
||||||
readableTime = myasctime ();
|
readableTime = myasctime ();
|
||||||
|
|
||||||
strncpy (comment, readableTime, 10);
|
FString comment;
|
||||||
strncpy (comment+10, readableTime+19, 5);
|
comment.Format("%.10s%.5s%.9s", readableTime, &readableTime[19], &readableTime[10]);
|
||||||
strncpy (comment+15, readableTime+10, 9);
|
|
||||||
comment[24] = 0;
|
|
||||||
|
|
||||||
arc.AddString("Creation Time", comment);
|
arc.AddString("Creation Time", comment);
|
||||||
|
|
||||||
// Get level name
|
// Get level name
|
||||||
//strcpy (comment, level.level_name);
|
//strcpy (comment, level.level_name);
|
||||||
mysnprintf(comment, countof(comment), "%s - %s", level.MapName.GetChars(), level.LevelName.GetChars());
|
comment.Format("%s - %s\n", level.MapName.GetChars(), level.LevelName.GetChars());
|
||||||
len = (uint16_t)strlen (comment);
|
|
||||||
comment[len] = '\n';
|
|
||||||
|
|
||||||
// Append elapsed time
|
// Append elapsed time
|
||||||
levelTime = level.time / TICRATE;
|
levelTime = level.time / TICRATE;
|
||||||
mysnprintf (comment + len + 1, countof(comment) - len - 1, "time: %02d:%02d:%02d",
|
comment.AppendFormat("time: %02d:%02d:%02d",
|
||||||
levelTime/3600, (levelTime%3600)/60, levelTime%60);
|
levelTime/3600, (levelTime%3600)/60, levelTime%60);
|
||||||
comment[len+16] = 0;
|
|
||||||
|
|
||||||
// Write out the comment
|
// Write out the comment
|
||||||
arc.AddString("Comment", comment);
|
arc.AddString("Comment", comment);
|
||||||
|
|
Loading…
Reference in a new issue