author | erik <erik> | 2007-01-24 23:29:42 (UTC) |
---|---|---|
committer | erik <erik> | 2007-01-24 23:29:42 (UTC) |
commit | 0076a11b467dce1233194ce228287a2a127b1f5d (patch) (side-by-side diff) | |
tree | f2136a1a3e9b5fd6bede52251ed7249365838752 /noncore/games/kbill/UI.cpp | |
parent | 48d9219a96096cf44df8ac24413b36d1b718b1d5 (diff) | |
download | opie-0076a11b467dce1233194ce228287a2a127b1f5d.zip opie-0076a11b467dce1233194ce228287a2a127b1f5d.tar.gz opie-0076a11b467dce1233194ce228287a2a127b1f5d.tar.bz2 |
Each file in this commit has the issue where it is possible for code to
overrun static buffers. This could lead to serious problems. Granted it
is almost impossible to do that. But it isn't totally impossible. So this
commit makes it impossible to overrun.
-rw-r--r-- | noncore/games/kbill/UI.cpp | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/noncore/games/kbill/UI.cpp b/noncore/games/kbill/UI.cpp index 611cebf..a49c3c1 100644 --- a/noncore/games/kbill/UI.cpp +++ b/noncore/games/kbill/UI.cpp @@ -63,38 +63,37 @@ void UI::make_mainwin() { main->showMaximized(); field = main->getField(); } void UI::popup_dialog (int dialog) { kill_timer(); switch (dialog) { case Game::ENDGAME: - QMessageBox::message(("Endgame"), QT_TR_NOOP(endgamestr)); - break; + QMessageBox::message(("Endgame"), QT_TR_NOOP(endgamestr)); + break; case Game::HIGHSCORE: - // QMessageBox::message(("HighScore"), highscorestr); - break; - case Game::ENTERNAME: { + break; + case Game::ENTERNAME: + { InputBox b(main, 0, ("Enter Name"), QT_TR_NOOP(enternamestr)); bool state = b.exec() == 2; - char str[20], *nl; - strcpy(str, b.getText()); - if (!str[0] || state) + char str[20], *nl; + strncpy(str, b.getText(), 19); + if (!str[0] || state) strcpy(str, "Anonymous"); - else if ((nl = strchr(str, '\n'))) + else if ((nl = strchr(str, '\n'))) *nl = '\0'; - if (strlen(str) > 20) - str[20] = 0; /* truncate string if too long */ -// scores.recalc(str); - } - break; + if (strlen(str) > 19) + str[19] = '\0'; /* truncate/terminate the string if it is too long */ + } + break; case Game::SCORE: - QMessageBox::message(("Score"), scorestr); - break; + QMessageBox::message(("Score"), scorestr); + break; } restart_timer(); } /*********************/ /* Graphics routines */ /*********************/ |