Skip to content

Commit

Permalink
Use string to avoid a buffer overflow (fixes #36)
Browse files Browse the repository at this point in the history
  • Loading branch information
drfiemost committed Mar 25, 2023
1 parent 0f72ebd commit 5f5039d
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions Hurrican/src/Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2173,12 +2173,10 @@ void MenuClass::DoMenu() {
(int)ptm->tm_hour,
(int)ptm->tm_min);
*/
char timestr[20];

strcpy_s(timestr, asctime(ptm));
std::string timestr(asctime(ptm));

strcpy_s(Savegames[AktuellerPunkt].Name, 1, "");
strcpy_s(Savegames[AktuellerPunkt].Name, 40-1, timestr);
strcpy_s(Savegames[AktuellerPunkt].Name, 40-1, timestr.c_str());

Savegames[AktuellerPunkt].Players = NUMPLAYERS;
Savegames[AktuellerPunkt].Score = Player[0].Score;
Expand Down Expand Up @@ -2230,6 +2228,7 @@ void MenuClass::DoMenu() {

// Fehler beim Öffnen ? Dann leeren Slot erzeugen
if (!Datei) {
// TODO log message
}

// Ansonsten Slot speichern
Expand Down

0 comments on commit 5f5039d

Please sign in to comment.