From bc082166596597b894b169ea82d06129c690e8bb Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 17 Oct 2013 13:43:21 +0300 Subject: DRASCULA: Fix potential buffer overrun. CID 1003310 --- engines/drascula/graphics.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'engines/drascula') diff --git a/engines/drascula/graphics.cpp b/engines/drascula/graphics.cpp index b28de669b6..a28ca8a1cb 100644 --- a/engines/drascula/graphics.cpp +++ b/engines/drascula/graphics.cpp @@ -336,7 +336,7 @@ void DrasculaEngine::centerText(const char *message, int textX, int textY) { // original starts printing 4 lines above textY int y = CLIP(textY - (4 * CHAR_HEIGHT), 0, 320); - strcpy(msg, message); + strlcpy(msg, message, 200); // If the message fits on screen as-is, just print it here if (textFitsCentered(msg, textX)) { @@ -363,8 +363,8 @@ void DrasculaEngine::centerText(const char *message, int textX, int textY) { while (curWord != NULL) { // Check if the word and the current line fit on screen if (tmpMessageLine[0] != '\0') - strcat(tmpMessageLine, " "); - strcat(tmpMessageLine, curWord); + strlcat(tmpMessageLine, " ", 200); + strlcat(tmpMessageLine, curWord, 200); if (textFitsCentered(tmpMessageLine, textX)) { // Line fits, so add the word to the current message line strcpy(messageLine, tmpMessageLine); @@ -374,8 +374,8 @@ void DrasculaEngine::centerText(const char *message, int textX, int textY) { // If it goes off screen, print_abc will adjust it x = CLIP(textX - strlen(messageLine) * CHAR_WIDTH / 2, 60, 255); print_abc(messageLine, x, y + curLine * CHAR_HEIGHT); - strcpy(messageLine, curWord); - strcpy(tmpMessageLine, curWord); + strlcpy(messageLine, curWord, 200); + strlcpy(tmpMessageLine, curWord, 200); curLine++; } -- cgit v1.2.3