]> git.mxchange.org Git - quix0rs-blobwars.git/commitdiff
Use snprintf() and strncpy().
authorGuus Sliepen <guus@debian.org>
Mon, 28 Jun 2010 21:41:06 +0000 (23:41 +0200)
committerGuus Sliepen <guus@debian.org>
Mon, 28 Jun 2010 21:41:06 +0000 (23:41 +0200)
83 files changed:
src/CAudio.cpp [changed mode: 0755->0644]
src/CBoss.cpp [changed mode: 0755->0644]
src/CCollision.cpp [changed mode: 0755->0644]
src/CConfig.cpp [changed mode: 0755->0644]
src/CCutscene.cpp [changed mode: 0755->0644]
src/CData.cpp [changed mode: 0755->0644]
src/CEffect.cpp [changed mode: 0755->0644]
src/CEngine.cpp [changed mode: 0755->0644]
src/CEntity.cpp [changed mode: 0755->0644]
src/CFileData.cpp [changed mode: 0755->0644]
src/CGame.cpp [changed mode: 0755->0644]
src/CGameData.cpp [changed mode: 0755->0644]
src/CGameObject.cpp [changed mode: 0755->0644]
src/CGraphics.cpp [changed mode: 0755->0644]
src/CHashtable.cpp [changed mode: 0755->0644]
src/CHub.cpp [changed mode: 0755->0644]
src/CJoystick.cpp [changed mode: 0755->0644]
src/CKeyboard.cpp [changed mode: 0755->0644]
src/CLineDef.cpp [changed mode: 0755->0644]
src/CList.cpp [changed mode: 0755->0644]
src/CMap.cpp [changed mode: 0755->0644]
src/CMath.cpp [changed mode: 0755->0644]
src/CMedalServer.cpp
src/CObjective.cpp [changed mode: 0755->0644]
src/CPak.cpp [changed mode: 0755->0644]
src/CParticle.cpp [changed mode: 0755->0644]
src/CPersistData.cpp
src/CPersistant.cpp [changed mode: 0755->0644]
src/CRadarBlip.cpp [changed mode: 0755->0644]
src/CReference.cpp [changed mode: 0755->0644]
src/CReplayData.cpp [changed mode: 0755->0644]
src/CSpawnPoint.cpp [changed mode: 0755->0644]
src/CSprite.cpp [changed mode: 0755->0644]
src/CString.cpp [changed mode: 0755->0644]
src/CSwitch.cpp [changed mode: 0755->0644]
src/CTeleporter.cpp [changed mode: 0755->0644]
src/CTrain.cpp [changed mode: 0755->0644]
src/CTrap.cpp [changed mode: 0755->0644]
src/CWeapon.cpp [changed mode: 0755->0644]
src/CWidget.cpp [changed mode: 0755->0644]
src/aquaBoss.cpp [changed mode: 0755->0644]
src/bosses.cpp [changed mode: 0755->0644]
src/bullets.cpp [changed mode: 0755->0644]
src/cutscene.cpp [changed mode: 0755->0644]
src/droidBoss.cpp [changed mode: 0755->0644]
src/effects.cpp [changed mode: 0755->0644]
src/enemies.cpp [changed mode: 0755->0644]
src/entities.cpp [changed mode: 0755->0644]
src/explosions.cpp [changed mode: 0755->0644]
src/finalBattle.cpp [changed mode: 0755->0644]
src/galdov.cpp [changed mode: 0755->0644]
src/game.cpp [changed mode: 0755->0644]
src/graphics.cpp [changed mode: 0755->0644]
src/hub.cpp [changed mode: 0755->0644]
src/info.cpp [changed mode: 0755->0644]
src/init.cpp [changed mode: 0755->0644]
src/intro.cpp [changed mode: 0755->0644]
src/items.cpp [changed mode: 0755->0644]
src/lineDefs.cpp [changed mode: 0755->0644]
src/loadSave.cpp [changed mode: 0755->0644]
src/main.cpp [changed mode: 0755->0644]
src/map.cpp [changed mode: 0755->0644]
src/mapData.cpp [changed mode: 0755->0644]
src/mapEditor.cpp [changed mode: 0755->0644]
src/mias.cpp [changed mode: 0755->0644]
src/mission.cpp [changed mode: 0755->0644]
src/objectives.cpp [changed mode: 0755->0644]
src/obstacles.cpp [changed mode: 0755->0644]
src/options.cpp [changed mode: 0755->0644]
src/pak.cpp [changed mode: 0755->0644]
src/particles.cpp [changed mode: 0755->0644]
src/player.cpp [changed mode: 0755->0644]
src/resources.cpp [changed mode: 0755->0644]
src/spawnPoints.cpp [changed mode: 0755->0644]
src/switches.cpp [changed mode: 0755->0644]
src/tankBoss.cpp [changed mode: 0755->0644]
src/teleporters.cpp [changed mode: 0755->0644]
src/title.cpp [changed mode: 0755->0644]
src/trains.cpp [changed mode: 0755->0644]
src/traps.cpp [changed mode: 0755->0644]
src/triggers.cpp [changed mode: 0755->0644]
src/weapons.cpp [changed mode: 0755->0644]
src/widgets.cpp [changed mode: 0755->0644]

old mode 100755 (executable)
new mode 100644 (file)
index 1a39fbf..c985f5e
@@ -34,7 +34,7 @@ Audio::Audio()
        music = NULL;
        quickSound = NULL;
        
-       strcpy(levelMusicName, "");
+       levelMusicName[0] = 0;
 }
 
 void Audio::setSoundVolume(int soundVolume)
@@ -97,7 +97,7 @@ bool Audio::loadMusic(const char *filename)
 {
        char tempPath[PATH_MAX];
        
-       sprintf(tempPath, "%smusic.mod", engine->userHomeDirectory);
+       snprintf(tempPath, sizeof tempPath, "%smusic.mod", engine->userHomeDirectory);
        
        if (!engine->useAudio)
        {
@@ -129,7 +129,7 @@ bool Audio::loadMusic(const char *filename)
                return false;
        }
                
-       strcpy(levelMusicName, filename);
+       strncpy(levelMusicName, filename, sizeof levelMusicName);
 
        return true;
 }
@@ -183,7 +183,7 @@ bool Audio::loadGameOverMusic()
 {
        char tempPath[PATH_MAX];
        
-       sprintf(tempPath, "%smusic.mod", engine->userHomeDirectory);
+       snprintf(tempPath, sizeof tempPath, "%smusic.mod", engine->userHomeDirectory);
        
        if (!engine->useAudio)
        {
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 5507f0f..a2bc4ee
@@ -89,7 +89,7 @@ void Config::doPause()
 bool Config::loadJoystickConfig()\r
 {\r
        char filename[PATH_MAX];\r
-       sprintf(filename, "%sjoystick.cfg", engine->userHomeDirectory);\r
+       snprintf(filename, sizeof filename, "%sjoystick.cfg", engine->userHomeDirectory);\r
        \r
        debug(("Loading joystick config from %s\n", filename));\r
        \r
@@ -114,7 +114,7 @@ bool Config::loadJoystickConfig()
 bool Config::saveJoystickConfig()\r
 {\r
        char filename[PATH_MAX];\r
-       sprintf(filename, "%sjoystick.cfg", engine->userHomeDirectory);\r
+       snprintf(filename, sizeof filename, "%sjoystick.cfg", engine->userHomeDirectory);\r
        \r
        debug(("Saving joystick config to %s\n", filename));\r
        \r
@@ -136,7 +136,7 @@ bool Config::saveJoystickConfig()
 bool Config::loadKeyConfig()\r
 {\r
        char filename[PATH_MAX];\r
-       sprintf(filename, "%skeyboard.cfg", engine->userHomeDirectory);\r
+       snprintf(filename, sizeof filename, "%skeyboard.cfg", engine->userHomeDirectory);\r
        \r
        debug(("Loading keyboard config from %s\n", filename));\r
        \r
@@ -164,7 +164,7 @@ bool Config::loadKeyConfig()
 bool Config::saveKeyConfig()\r
 {\r
        char filename[PATH_MAX];\r
-       sprintf(filename, "%skeyboard.cfg", engine->userHomeDirectory);\r
+       snprintf(filename, sizeof filename, "%skeyboard.cfg", engine->userHomeDirectory);\r
        \r
        debug(("Saving keyboard config to %s\n", filename));\r
        \r
old mode 100755 (executable)
new mode 100644 (file)
index 5fb0376..e92daae
@@ -22,12 +22,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 Cutscene::Cutscene()
 {
-       strcpy(sprite, "");
-       strcpy(text, "");
+       sprite[0] = 0;
+       text[0] = 0;
        waitTime = 0;
 }
 
 void Cutscene::appendText(const char *line)
 {
-       sprintf(text, "%s %s", text, line);
+       snprintf(text, sizeof text, "%s %s", text, line);
 }
old mode 100755 (executable)
new mode 100644 (file)
index 419a619..12642ed
@@ -22,8 +22,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 Data::Data()
 {
-       strcpy(key, "");
-       strcpy(value, "");
+       key[0] = 0;
+       value[0] = 0;
        current = 0;
        target = 1;
 }
@@ -36,8 +36,8 @@ void Data::set(const char *key, const char *value, int current, int target)
                return;
        }
 
-       strcpy(this->key, key);
-       strcpy(this->value, value);
+       strncpy(this->key, key, sizeof this->key);
+       strncpy(this->value, value, sizeof this->value);
        this->current = current;
        this->target = target;
 }
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 13a5409..a84d257
@@ -40,7 +40,7 @@ Engine::Engine()
        
        allowJoypad = true;
 
-       strcpy(lastKeyPressed, "");
+       lastKeyPressed[0] = 0;
 
        fullScreen = 0;
 
@@ -54,7 +54,7 @@ Engine::Engine()
 
        highlightedWidget = NULL;
 
-       strcpy(message, "");
+       message[0] = 0;
        messageTime = -1;
 
        // Development Stuff
@@ -234,7 +234,7 @@ void Engine::getInput()
                                }
 
                                keyState[event.key.keysym.sym] = 1;
-                               strcpy(lastKeyPressed, SDL_GetKeyName(event.key.keysym.sym));
+                               strncpy(lastKeyPressed, SDL_GetKeyName(event.key.keysym.sym), sizeof lastKeyPressed);
                                addKeyEvent();
                                break;
 
@@ -319,7 +319,7 @@ void Engine::clearInput()
 
 void Engine::setUserHome(const char *path)
 {
-       strcpy(userHomeDirectory, path);
+       strncpy(userHomeDirectory, path, sizeof userHomeDirectory);
        debug(("User Home = %s\n", path));
 }
 
@@ -384,13 +384,13 @@ bool Engine::unpack(const char *filename, int fileType)
 
                if (fileType == PAK_MUSIC)
                {
-                       sprintf(tempPath, "%smusic.mod", userHomeDirectory);
+                       snprintf(tempPath, sizeof tempPath, "%smusic.mod", userHomeDirectory);
                        fp = fopen(tempPath, "wb");
                }
 
                if (fileType == PAK_FONT)
                {
-                       sprintf(tempPath, "%sfont.ttf", userHomeDirectory);
+                       snprintf(tempPath, sizeof tempPath, "%sfont.ttf", userHomeDirectory);
                        fp = fopen(tempPath, "wb");
                }
 
@@ -493,7 +493,7 @@ void Engine::setInfoMessage(const char *message, int priority, int type)
 {
        if (priority >= messagePriority)
        {
-               strcpy(this->message, message);
+               strncpy(this->message, message, sizeof this->message);
                messageTime = 180;
                messagePriority = priority;
                messageType = type;
@@ -961,7 +961,7 @@ int Engine::getValueOfFlagTokens(const char *realLine)
        char line[1024];
        bool found;
        int value;
-       strcpy(line, realLine);
+       strncpy(line, realLine, sizeof line);
 
        int flags = 0;
 
old mode 100755 (executable)
new mode 100644 (file)
index 988b6d1..e1575ca
@@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 Entity::Entity()
 {
-       strcpy(name, "");
+       name[0] = 0;
        x = y = dx = dy = tx = ty = width = height = 0;
        id = 0;
        health = 0;
@@ -52,7 +52,7 @@ Entity::Entity()
 
 void Entity::setName(const char *name)
 {
-       strcpy(this->name, name);
+       strncpy(this->name, name, sizeof this->name);
 }
 
 void Entity::setSprites(Sprite *sprite1, Sprite *sprite2, Sprite *sprite3)
old mode 100755 (executable)
new mode 100644 (file)
index c9b989c..f3ebe92
@@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 FileData::FileData()
 {
-       strcpy(filename, "");
+       filename[0] = 0;
        fSize = 0;
        cSize = 0;
        location = 0;
@@ -36,7 +36,7 @@ void FileData::set(const char *filename, Uint32 fSize, Uint32 cSize, Uint32 loca
                return;
        }
        
-       strcpy(this->filename, filename);
+       strncpy(this->filename, filename, sizeof this->filename);
        
        this->fSize = fSize;
        this->cSize = cSize;
old mode 100755 (executable)
new mode 100644 (file)
index 7741b6d..a5fa060
@@ -66,8 +66,8 @@ void Game::clear()
                bulletsHit[i] = bulletsFired[i] = 0;
        }
 
-       strcpy(mapName, "data/grasslands1");
-       strcpy(stageName, "Grasslands");
+       strncpy(mapName, "data/grasslands1", sizeof mapName);
+       strncpy(stageName, "Grasslands", sizeof stageName);
 
        continuesUsed = 0;
        levelsStarted = 0;
@@ -221,12 +221,12 @@ void Game::totalUpStats()
 
 void Game::setStageName(const char *name)
 {
-       strcpy(stageName, name);
+       strncpy(stageName, name, sizeof stageName);
 }
 
 void Game::setMapName(const char *name)
 {
-       strcpy(mapName, name);
+       strncpy(mapName, name, sizeof mapName);
 }
 
 void Game::setMissionOver(int reason)
old mode 100755 (executable)
new mode 100644 (file)
index c722461..a7d17cf
@@ -83,14 +83,14 @@ void GameData::setMIARescueCount(const char *key, int rescues, int total)
        Data *data = (Data*)dataList.getHead();
 
        char newKey[100];
-       sprintf(newKey, "%s MIAs", key);
+       snprintf(newKey, sizeof newKey, "%s MIAs", key);
 
        while (data->next != NULL)
        {
                data = (Data*)data->next;
                if (strcmp(newKey, data->key) == 0)
                {
-                       strcpy(data->value, "MIAs");
+                       strncpy(data->value, "MIAs", sizeof data->value);
                        data->current = rescues;
                        data->target = total;
                        return;
@@ -109,7 +109,7 @@ bool GameData::MIARescued(const char *stageName, char *name)
        Data *data = (Data*)dataList.getHead();
 
        char newName[100];
-       sprintf(newName, "MIA_%s", name);
+       snprintf(newName, sizeof newName, "MIA_%s", name);
 
        while (data->next != NULL)
        {
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index e93d324..390214e
@@ -194,7 +194,7 @@ void Graphics::updateScreen()
        {
                if ((Math::prand() % 500) == 0)
                {
-                       sprintf(screenshot, "screenshots/screenshot%.3d.bmp", screenShotNumber);
+                       snprintf(screenshot, sizeof screenshot, "screenshots/screenshot%.3d.bmp", screenShotNumber);
                        SDL_SaveBMP(screen, screenshot);
                        screenShotNumber++;
                }
@@ -204,7 +204,7 @@ void Graphics::updateScreen()
 
        if (engine->keyState[SDLK_F12])
        {
-               sprintf(screenshot, "screenshots/screenshot%.3d.bmp", screenShotNumber);
+               snprintf(screenshot, sizeof screenshot, "screenshots/screenshot%.3d.bmp", screenShotNumber);
                SDL_SaveBMP(screen, screenshot);
                screenShotNumber++;
 
@@ -476,7 +476,7 @@ void Graphics::loadMapTiles(const char *baseDir)
 {
        bool found, autoAlpha;
        char filename[255];
-       strcpy(filename, "");
+       filename[0] = 0;
 
        autoAlpha = false;
        
@@ -493,7 +493,7 @@ void Graphics::loadMapTiles(const char *baseDir)
        {
                found = true;
 
-               sprintf(filename, "%s/%d.png", baseDir, i);
+               snprintf(filename, sizeof filename, "%s/%d.png", baseDir, i);
 
                #if USEPAK
                
@@ -551,7 +551,7 @@ void Graphics::loadFont(int i, const char *filename, int pixelSize)
        
        char tempPath[PATH_MAX];
        
-       sprintf(tempPath, "%sfont.ttf", engine->userHomeDirectory);
+       snprintf(tempPath, sizeof tempPath, "%sfont.ttf", engine->userHomeDirectory);
 
        bool found = false;
        int size = 0;
@@ -613,7 +613,7 @@ void Graphics::loadFont(int i, const char *filename, int pixelSize)
 Sprite *Graphics::addSprite(const char *name)
 {
        Sprite *sprite = new Sprite;
-       strcpy(sprite->name, name);
+       strncpy(sprite->name, name, sizeof sprite->name);
 
        spriteList.add(sprite);
 
@@ -906,12 +906,12 @@ void Graphics::drawString(const char *in, int x, int y, int alignment, SDL_Surfa
 
 void Graphics::clearChatString()
 {
-       strcpy(chatString, "");
+       chatString[0] = 0;
 }
 
 void Graphics::createChatString(const char *in)
 {
-       sprintf(chatString, "%s %s", chatString, in);
+       snprintf(chatString, sizeof chatString, "%s %s", chatString, in);
 }
 
 void Graphics::drawChatString(SDL_Surface *surface, int y)
@@ -947,7 +947,7 @@ void Graphics::drawChatString(SDL_Surface *surface, int y)
                        continue;
                }
 
-               sprintf(wordWithSpace, "%s ", word);
+               snprintf(wordWithSpace, sizeof wordWithSpace, "%s ", word);
 
                wordSurface = getString(wordWithSpace, false);
 
@@ -1004,12 +1004,12 @@ void Graphics::showMedalMessage(int type, const char *in)
        medalType = type - 1; // for indexing on the image
        if (type != -1)
        {
-               sprintf(message, "  Medal Earned - %s  ", in);
+               snprintf(message, sizeof message, "  Medal Earned - %s  ", in);
                medalMessage = getString(message, true);
        }
        else
        {
-               sprintf(message, "  %s  ", in);
+               snprintf(message, sizeof message, "  %s  ", in);
                medalMessage = getString(message, true);
        }
        medalMessageTimer = (5 * 60);
@@ -1136,7 +1136,7 @@ void Graphics::showErrorAndExit(const char *error, const char *param)
        }
 
        char message[256];
-       sprintf(message, error, param);
+       snprintf(message, sizeof message, error, param);
 
        setFontSize(3); setFontColor(0xff, 0x00, 0x00, 0x00, 0x00, 0x00);
        drawString("An unforseen error has occurred", 320, 50, true, screen);
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 2a85fef..4c8192e
@@ -22,8 +22,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 HubLevel::HubLevel()
 {
-       strcpy(stageName, "");
-       strcpy(filename, "");
+       stageName[0] = 0;
+       filename[0] = 0;
        x = y = 0;
 
        levelNameImage = NULL;
@@ -33,8 +33,8 @@ HubLevel::HubLevel()
 
 void HubLevel::set(const char *stageName, const char *filename, int x, int y)
 {
-       strcpy(this->stageName, stageName);
-       strcpy(this->filename, filename);
+       strncpy(this->stageName, stageName, sizeof this->stageName);
+       strncpy(this->filename, filename, sizeof this->filename);
        this->x = x;
        this->y = y;
 }
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 1874317..b9bc5bc
@@ -41,7 +41,7 @@ void Keyboard::setDefaultKeys()
 const char *Keyboard::translateKey(int key)
 {
        static char keyName[50];
-       strcpy(keyName, "");
+       keyName[0] = 0;
        keyName[0] = '\0';
        
        if (key <= 0)
@@ -49,7 +49,7 @@ const char *Keyboard::translateKey(int key)
                return "...";
        }
        
-       strcpy(keyName, _(SDL_GetKeyName((SDLKey)key)));
+       strncpy(keyName, _(SDL_GetKeyName((SDLKey)key)), sizeof keyName);
        
        /*
        This is not really neccessary, but it just makes
old mode 100755 (executable)
new mode 100644 (file)
index e47757f..916bdf6
@@ -24,18 +24,18 @@ LineDef::LineDef()
 {
        x = y = 0;
        width = height = 0;
-       strcpy(name, "");
-       strcpy(linkName, "");
-       strcpy(activateMessage, "");
+       name[0] = 0;
+       linkName[0] = 0;
+       activateMessage[0] = 0;
        activated = false;
        next = NULL;
 }
 
 void LineDef::set(const char *name, const char *linkName, const char *activateMessage, int x, int y, int width, int height)
 {
-       strcpy(this->name, name);
-       strcpy(this->linkName, linkName);
-       strcpy(this->activateMessage, activateMessage);
+       strncpy(this->name, name, sizeof this->name);
+       strncpy(this->linkName, linkName, sizeof this->linkName);
+       strncpy(this->activateMessage, activateMessage, sizeof this->activateMessage);
        this->x = x;
        this->y = y;
        this->width = width;
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 5f60ad1..72ce787
@@ -44,7 +44,7 @@ void Map::clear()
        limitRight = ((MAPWIDTH - 40) * BRICKSIZE);
        limitDown = ((MAPHEIGHT - 30) * BRICKSIZE);
 
-       strcpy(name, "");
+       name[0] = 0;
 
        for (int x = 0 ; x < MAPWIDTH ; x++)
                for (int y = 0 ; y < MAPHEIGHT ; y++)
@@ -220,7 +220,7 @@ void Map::destroyPersistant(const char *name)
                
                if (strcmp(p->stageName, name) == 0)
                {
-                       strcpy(p->stageName, "@none@");
+                       strncpy(p->stageName, "@none@", sizeof p->stageName);
                        p->clear();
                        return;
                }
@@ -229,7 +229,7 @@ void Map::destroyPersistant(const char *name)
 
 void Map::setName(const char *name)
 {
-       strcpy(this->name, name);
+       strncpy(this->name, name, sizeof this->name);
        
        if (strstr(name, "BioMech"))
        {
old mode 100755 (executable)
new mode 100644 (file)
index 76aa6cc..78be8e8
@@ -140,13 +140,13 @@ char *Math::formatTime(int t)
 {
        static char time[1024];
        
-       strcpy(time, "");
+       time[0] = 0;
        
        int hours = t / 3600;
        int minutes = (t % 3600) / 60;
        int seconds = (t % 60);
        
-       sprintf(time, "%dh %dm %ds", hours, minutes, seconds);
+       snprintf(time, sizeof time, "%dh %dm %ds", hours, minutes, seconds);
        
        return time;
 }
index 0cd6272fa8200173f41c75135191f40492d6bdd1..fc9e9b61996f522e0900a135a2c8c169a8e4e50f 100644 (file)
@@ -28,8 +28,8 @@ MedalServer::MedalServer()
        connected = false;
        gotRuby = false;
        
-       strcpy(message, "");
-       strcpy(rubyMessage, "");
+       message[0] = 0;
+       rubyMessage[0] = 0;
 }
 
 MedalServer::~MedalServer()
@@ -50,7 +50,7 @@ bool MedalServer::connect(const char *privateKey)
        
        debug(("Connected %s to %s:%d\n", privateKey, MEDAL_SERVER_HOST, MEDAL_SERVER_PORT));
        
-       strcpy(this->privateKey, privateKey);
+       strncpy(this->privateKey, privateKey, sizeof this->privateKey);
        connected = true;
        
        return true;
@@ -70,7 +70,7 @@ int MedalServer::postMedal(const char *str)
        char *store;
        
        char medal[128];
-       strcpy(medal, str);
+       strncpy(medal, str, sizeof medal);
        
        for (unsigned int i = 0 ; i < strlen(medal) ; i++)
        {
@@ -93,7 +93,7 @@ int MedalServer::postMedal(const char *str)
        char *in = new char[1024];
        char out[1024];
        
-       sprintf(out, "GET /addMedal/%s/MBS_%s HTTP/1.1\nHost: %s\nUser-Agent:BWMBS%.2f-%d\n\n", privateKey, medal, MEDAL_SERVER_HOST, VERSION, RELEASE);
+       snprintf(out, sizeof out, "GET /addMedal/%s/MBS_%s HTTP/1.1\nHost: %s\nUser-Agent:BWMBS%.2f-%d\n\n", privateKey, medal, MEDAL_SERVER_HOST, VERSION, RELEASE);
        
        //printf("%s\n", out);
        
@@ -123,7 +123,7 @@ int MedalServer::postMedal(const char *str)
                        
                        if (response == 4)
                        {
-                               strcpy(rubyMessage, message);
+                               strncpy(rubyMessage, message, sizeof rubyMessage);
                                gotRuby = true;
                        }
                        else
old mode 100755 (executable)
new mode 100644 (file)
index a1ca9cc..9bf75f3
@@ -22,8 +22,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 Objective::Objective()
 {
-       strcpy(this->description, "");
-       strcpy(this->target, "");
+       this->description[0] = 0;
+       this->target[0] = 0;
        this->currentValue = 0;
        this->targetValue = 0;
        this->required = false;
@@ -34,8 +34,8 @@ Objective::Objective()
 
 Objective::Objective(const char *description, const char *target, int targetValue, bool required)
 {
-       strcpy(this->description, description);
-       strcpy(this->target, target);
+       strncpy(this->description, description, sizeof this->description);
+       strncpy(this->target, target, sizeof this->target);
        this->targetValue = targetValue;
        this->required = required;
 
old mode 100755 (executable)
new mode 100644 (file)
index 65f4ab0..6c4c16a
@@ -29,8 +29,8 @@ Pak::Pak()
        listPos = 0;
        currentFile = NULL;
 
-       strcpy(pakFilename, "");
-       strcpy(filename, "");
+       pakFilename[0] = 0;
+       filename[0] = 0;
 }
 
 Pak::~Pak()
@@ -61,7 +61,7 @@ void Pak::showPakErrorAndExit()
 void Pak::setPakFile(const char *pakFilename)
 {
        #if USEPAK
-       strcpy(this->pakFilename, pakFilename);
+       strncpy(this->pakFilename, pakFilename, sizeof this->pakFilename);
        
        debug(("Pak : Filename set to %s\n", pakFilename));
 
old mode 100755 (executable)
new mode 100644 (file)
index 9150c003add61e315d8fc13488e552a6c7963ce4..cd4bf141fe7ecba819cd4e9693c43dbafa4db63b 100644 (file)
@@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 PersistData::PersistData()
 {
-       strcpy(data, "");
+       data[0] = 0;
 }
 
 PersistData::~PersistData()
@@ -37,7 +37,7 @@ bool PersistData::setData(const char *data)
                return false;
        }
        
-       strcpy(this->data, data);
+       strncpy(this->data, data, sizeof this->data);
        
        return true;
 }
old mode 100755 (executable)
new mode 100644 (file)
index 5161f1f..82f03d6
@@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 Persistant::Persistant()
 {
-       strcpy(stageName, "");
+       stageName[0] = 0;
        numberOfLines = 0;
 }
 
@@ -34,7 +34,7 @@ Persistant::~Persistant()
 
 void Persistant::setName(const char *name)
 {
-       strcpy(this->stageName, name);
+       strncpy(this->stageName, name, sizeof this->stageName);
 }
 
 void Persistant::clear()
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 218fff1..6af8492
@@ -13,7 +13,7 @@ ReplayData::ReplayData()
        header.version = VERSION;
        header.release = RELEASE;
        
-       strcpy(filename, "");
+       filename[0] = 0;
 }
 
 ReplayData::~ReplayData()
old mode 100755 (executable)
new mode 100644 (file)
index 0d41551..c7c91e5
@@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 SpawnPoint::SpawnPoint()
 {
-       strcpy(name, "");
+       name[0] = 0;
        active = false;
        x = y = 0;
 
@@ -42,7 +42,7 @@ void SpawnPoint::reset()
 
 void SpawnPoint::create(const char *name, int x, int y, int spawnType, int spawnSubType, int minInterval, int maxInterval, bool active)
 {
-       strcpy(this->name, name);
+       strncpy(this->name, name, sizeof this->name);
        this->x = x;
        this->y = y;
        this->spawnType = spawnType;
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 31eda9f..bc70827
@@ -31,7 +31,7 @@ String::String(char *text)
 
        this->text = new char[size + 1];
 
-       strcpy(this->text, text);
+       strncpy(this->text, text, sizeof this->text);
 
        this->length = size;
 }
@@ -65,7 +65,7 @@ void String::trim()
                c++; // LOL!!! :)
        }
 
-       strcpy(tempText, c);
+       strncpy(tempText, c, sizeof tempText);
 
        int len = strlen(tempText);
        
@@ -97,7 +97,7 @@ void String::operator= (char *text)
 
        this->text = new char[size + 1];
 
-       strcpy(this->text, text);
+       strncpy(this->text, text, sizeof this->text);
 
        this->length = size;
 }
@@ -144,18 +144,18 @@ bool String::operator!= (String string)
 
 void String::setText(char *text, ...)
 {
-       strcpy(tmpString, "");
+       tmpString[0] = 0;
        
        va_list argp;
        va_start(argp, text);
-       vsprintf(tmpString, text, argp);
+       vsnprintf(tmpString, sizeof tmpString, text, argp);
        va_end(argp);
        
        int size = strlen(tmpString);
 
        this->text = new char[size + 1];
 
-       strcpy(this->text,  tmpString);
+       strncpy(this->text,  tmpString, sizeof this->text);
 }
 
 char *String::getText()
old mode 100755 (executable)
new mode 100644 (file)
index ae39a2a..d5492f4
@@ -22,10 +22,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 Switch::Switch()
 {
-       strcpy(this->name, "");
-       strcpy(this->linkName, "");
-       strcpy(this->requiredObjectName, "");
-       strcpy(this->activateMessage, "");
+       this->name[0] = 0;
+       this->linkName[0] = 0;
+       this->requiredObjectName[0] = 0;
+       this->activateMessage[0] = 0;
 
        type = 0;
        x = y = 0;
@@ -37,10 +37,10 @@ Switch::Switch()
 
 void Switch::set(const char *name, const char *linkName, const char *requiredObjectName, const char *activateMessage, int type, int x, int y, bool activated)
 {
-       strcpy(this->name, name);
-       strcpy(this->linkName, linkName);
-       strcpy(this->requiredObjectName, requiredObjectName);
-       strcpy(this->activateMessage, activateMessage);
+       strncpy(this->name, name, sizeof this->name);
+       strncpy(this->linkName, linkName, sizeof this->linkName);
+       strncpy(this->requiredObjectName, requiredObjectName, sizeof this->requiredObjectName);
+       strncpy(this->activateMessage, activateMessage, sizeof this->activateMessage);
        this->type = type;
        this->x = x;
        this->y = y;
old mode 100755 (executable)
new mode 100644 (file)
index 50a9a2c..9f213aa
@@ -29,7 +29,7 @@ Teleporter::Teleporter()
 
 void Teleporter::setName(const char *name)
 {
-       strcpy(this->name, name);
+       strncpy(this->name, name, sizeof this->name);
 }
 
 void Teleporter::set(int x, int y, int destX, int destY)
old mode 100755 (executable)
new mode 100644 (file)
index 91f6b3d..b385278
@@ -76,7 +76,7 @@ bool Train::waitsForPlayer()
 
 void Train::setName(const char *name)
 {
-       strcpy(this->name, name);
+       strncpy(this->name, name, sizeof this->name);
 }
 
 void Train::set(int startX, int startY, int endX, int endY, int pause, bool fromStart)
old mode 100755 (executable)
new mode 100644 (file)
index ce6a791..224f924
@@ -30,7 +30,7 @@ Trap::Trap()
 
 void Trap::setName(const char *name)
 {
-       strcpy(this->name, name);
+       strncpy(this->name, name, sizeof this->name);
 }
 
 void Trap::setTrapType(int type)
old mode 100755 (executable)
new mode 100644 (file)
index 0fecc46..7268b8b
@@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 Weapon::Weapon()
 {
-       strcpy(name, "");
+       name[0] = 0;
        id = 0;
        damage = 0;
        reload = 0;
@@ -34,7 +34,7 @@ Weapon::Weapon()
 
 void Weapon::setName(const char *name)
 {
-       strcpy(this->name, name);
+       strncpy(this->name, name, sizeof this->name);
 }
 
 int Weapon::getSpeed(int face)
old mode 100755 (executable)
new mode 100644 (file)
index 85c7e40..fbf8c38
@@ -22,10 +22,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 Widget::Widget()
 {
-       strcpy(name, "");
-       strcpy(groupName, "");
-       strcpy(label, "");
-       strcpy(options, "");
+       name[0] = 0;
+       groupName[0] = 0;
+       label[0] = 0;
+       options[0] = 0;
        x = y = type = min = max = 0;
        enabled = visible = true;
        changed = false;
@@ -43,10 +43,10 @@ void Widget::setProperties(const char *name, const char *groupName, const char *
                exit(1);
        }
 
-       strcpy(this->name, name);
-       strcpy(this->groupName, groupName);
-       strcpy(this->label, label);
-       strcpy(this->options, options);
+       strncpy(this->name, name, sizeof this->name);
+       strncpy(this->groupName, groupName, sizeof this->groupName);
+       strncpy(this->label, label, sizeof this->label);
+       strncpy(this->options, options, sizeof this->options);
        this->x = x;
        this->y = y;
        this->min = min;
old mode 100755 (executable)
new mode 100644 (file)
index 34c5a9e..73df1ab
@@ -287,7 +287,7 @@ void aquaBossMainInit()
        debug(("aquaBossMainInit\n"));
        
        map.boss[0] = new Boss();
-       strcpy(map.boss[0]->name, "BioMech Aqua Blob");
+       strncpy(map.boss[0]->name, "BioMech Aqua Blob", sizeof map.boss[0]->name);
        map.boss[0]->health = 45 * game.skill;
        map.boss[0]->maxHealth = 45 * game.skill;
        map.boss[0]->setSprites(graphics.getSprite("AquaBossRight", true), graphics.getSprite("AquaBossLeft", true), graphics.getSprite("AquaBossLeft", true));
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 586e5b2..3542842
@@ -51,7 +51,7 @@ void createSceneList()
                        line = strtok(NULL, "\n");
                        if (strcmp(line, "@none@") != 0)
                        {
-                               strcpy(scene->sprite, line);
+                               strncpy(scene->sprite, line, sizeof scene->sprite);
                                debug(("Loading cutscene image %s\n", scene->sprite));
                                graphics.quickSprite(scene->sprite, graphics.loadImage(scene->sprite));
                        }
@@ -219,7 +219,7 @@ void checkStartCutscene()
        audio.loadMusic("music/daisyChain2.mod");
        
        char sceneName[1024];
-       sprintf(sceneName, "%s Start", game.stageName);
+       snprintf(sceneName, sizeof sceneName, "%s Start", game.stageName);
        
        if (setupScene(sceneName))
        {
@@ -248,7 +248,7 @@ void checkEndCutscene()
        }
        
        char sceneName[1024];
-       sprintf(sceneName, "%s End", game.stageName);
+       snprintf(sceneName, sizeof sceneName, "%s End", game.stageName);
        
        debug(("%s\n", sceneName));
        
old mode 100755 (executable)
new mode 100644 (file)
index 353f7ea..69e8aa3
@@ -365,7 +365,7 @@ void droidBossInit()
        debug(("droidBossInit\n"));
        
        map.boss[0] = new Boss();
-       strcpy(map.boss[0]->name, "BioMech Jetpack Blob");
+       strncpy(map.boss[0]->name, "BioMech Jetpack Blob", sizeof map.boss[0]->name);
        map.boss[0]->health = 30 * game.skill;
        map.boss[0]->maxHealth = 30 * game.skill;
        map.boss[0]->setSprites(graphics.getSprite("JetpackBlobRight1", true), graphics.getSprite("JetpackBlobLeft1", true), graphics.getSprite("JetpackBlobLeft1", true));
@@ -387,7 +387,7 @@ void droidBossInit()
        for (int i = 1 ; i < 6 ; i++)
        {
                map.boss[i] = new Boss();
-               strcpy(map.boss[i]->name, "Orb Bomb");
+               strncpy(map.boss[i]->name, "Orb Bomb", sizeof map.boss[i]->name);
                map.boss[i]->setSprites(graphics.getSprite("DroidOrb", true), graphics.getSprite("DroidOrb", true), graphics.getSprite("DroidOrb", true));
                map.boss[i]->active = false;
                map.boss[i]->face = 1;
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 9179ebc..1e59f83
@@ -377,7 +377,7 @@ void enemyBulletCollisions(Entity *bullet)
 
                if ((bullet->owner == &player) || (bullet->owner == &engine.world) || (bullet->flags & ENT_BOSS))
                {
-                       sprintf(comboString, "Combo-%s", bullet->name);
+                       snprintf(comboString, sizeof comboString, "Combo-%s", bullet->name);
 
                        if (Collision::collision(enemy, bullet))
                        {
@@ -514,7 +514,7 @@ void enemyBulletCollisions(Entity *bullet)
                                if (game.currentComboHits >= 3)
                                {
                                        char message[50];
-                                       sprintf(message, _("%d Hit Combo!"), game.currentComboHits);
+                                       snprintf(message, sizeof message, _("%d Hit Combo!"), game.currentComboHits);
                                        engine.setInfoMessage(message, 0, INFO_NORMAL);
                                }
 
@@ -848,7 +848,7 @@ void loadDefEnemies()
 {
        for (int i = 0 ; i < MAX_ENEMIES ; i++)
        {
-               strcpy(defEnemy[i].name, "");
+               defEnemy[i].name[0] = 0;
        }
 
        int enemy = 0;
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index cf06372..e69b96f
@@ -147,7 +147,7 @@ void galdovInitBlackDroids()
                        map.boss[i] = new Boss();
                }
                debug(("BlackDroid %d init\n", i));
-               strcpy(map.boss[i]->name, "BlackDrod");
+               strncpy(map.boss[i]->name, "BlackDrod", sizeof map.boss[i]->name);
                map.boss[i]->health = -90;
                map.boss[i]->maxHealth = -90;
                map.boss[i]->setSprites(graphics.getSprite("BlackDroidRight", true), graphics.getSprite("BlackDroidLeft", true), graphics.getSprite("BlackDroidDie", true));
@@ -493,7 +493,7 @@ void galdovFinalSplit()
                if (map.boss[i] == NULL)
                {
                        map.boss[i] = new Boss();
-                       strcpy(map.boss[i]->name, "MiniGaldov");
+                       strncpy(map.boss[i]->name, "MiniGaldov", sizeof map.boss[i]->name);
                        map.boss[i]->health = 10 * game.skill;
                        map.boss[i]->maxHealth = 10 * game.skill;
                }
@@ -556,7 +556,7 @@ void galdovFinalInit()
        debug(("galdovFinalInit\n"));
        
        map.boss[0] = new Boss();
-       strcpy(map.boss[0]->name, "Galdov");
+       strncpy(map.boss[0]->name, "Galdov", sizeof map.boss[0]->name);
        map.boss[0]->health = 45 * game.skill;
        map.boss[0]->maxHealth = 45 * game.skill;
        map.boss[0]->setSprites(graphics.getSprite("GaldovRight", true), graphics.getSprite("GaldovLeft", true), graphics.getSprite("GaldovDie", true));
@@ -680,7 +680,7 @@ void galdovFinalShieldInit()
                        delete map.boss[i];
                }
                map.boss[i] = new Boss();
-               strcpy(map.boss[i]->name, "OrbBomb");
+               strncpy(map.boss[i]->name, "OrbBomb", sizeof map.boss[i]->name);
                map.boss[i]->setSprites(graphics.getSprite("DroidOrb", true), graphics.getSprite("DroidOrb", true), graphics.getSprite("DroidOrb", true));
                map.boss[i]->health = 999999;
                map.boss[i]->maxHealth = 99999;
old mode 100755 (executable)
new mode 100644 (file)
index 6ef5762..5de463f
@@ -456,7 +456,7 @@ void galdovInit()
        debug(("galdovInit\n"));
        
        map.boss[0] = new Boss();
-       strcpy(map.boss[0]->name, "Galdov");
+       strncpy(map.boss[0]->name, "Galdov", sizeof map.boss[0]->name);
        map.boss[0]->health = 45 * game.skill;
        map.boss[0]->maxHealth = 45 * game.skill;
        map.boss[0]->setSprites(graphics.getSprite("GaldovRight", true), graphics.getSprite("GaldovLeft", true), graphics.getSprite("GaldovLeft", true));
@@ -480,7 +480,7 @@ void galdovInit()
        for (int i = 1 ; i < 10 ; i++)
        {
                map.boss[i] = new Boss();
-               strcpy(map.boss[i]->name, "Fake");
+               strncpy(map.boss[i]->name, "Fake", sizeof map.boss[i]->name);
                map.boss[i]->setSprites(graphics.getSprite("GaldovRight", true), graphics.getSprite("GaldovLeft", true), graphics.getSprite("GaldovLeft", true));
                map.boss[i]->x = 9999;
                map.boss[i]->y = 9999;
old mode 100755 (executable)
new mode 100644 (file)
index cff9414..b10c68a
@@ -316,7 +316,7 @@ int gameover()
        if (game.canContinue > 1)
        {
                Widget *widget = engine.getWidgetByName("gameOverNo");
-               sprintf(widget->label, "%s (%d)", widget->label, game.canContinue);
+               snprintf(widget->label, sizeof widget->label, "%s (%d)", widget->label, game.canContinue);
        }
 
        while (true)
@@ -408,13 +408,13 @@ void showMissionInformation()
        if (map.totalMIAs > 0)
        {
                graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
-               sprintf(message, _("Rescue %d MIAs"), map.requiredMIAs);
+               snprintf(message, sizeof message, _("Rescue %d MIAs"), map.requiredMIAs);
                graphics.drawString(message, col1, y, TXT_LEFT, panel);
 
                if (map.foundMIAs < map.requiredMIAs)
                {
                        graphics.setFontColor(0xff, 0x00, 0x00, 0x00, 0x00, 0x00);
-                       sprintf(message, "%d / %d", map.foundMIAs, map.requiredMIAs);
+                       snprintf(message, sizeof message, "%d / %d", map.foundMIAs, map.requiredMIAs);
                        graphics.drawString(message, col2, y, TXT_RIGHT, panel);
                }
                else
@@ -458,7 +458,7 @@ void showMissionInformation()
                        }
                        else
                        {
-                               sprintf(message, "%d / %d", objective->currentValue, objective->targetValue);
+                               snprintf(message, sizeof message, "%d / %d", objective->currentValue, objective->targetValue);
                                graphics.drawString(message, col2, y, TXT_RIGHT, panel);
                        }
                }
@@ -472,7 +472,7 @@ void showMissionInformation()
        if (game.skill == 3)
        {
                graphics.setFontColor(0xff, 0xff, 0x00, 0x00, 0x00, 0x00);
-               sprintf(message, _("Time Limit - %d:%.2d Minutes"), map.remainingMinutes, map.remainingSeconds);
+               snprintf(message, sizeof message, _("Time Limit - %d:%.2d Minutes"), map.remainingMinutes, map.remainingSeconds);
                graphics.drawString(message, 200, 260, TXT_CENTERED, panel);
        }
        
@@ -572,7 +572,7 @@ int doGame()
        #if !USEPAK
        Uint32 now;
        char fps[10];
-       strcpy(fps, "fps");
+       strncpy(fps, "fps", sizeof fps);
        #endif
 
        engine.messageTime = -1;
@@ -845,7 +845,7 @@ int doGame()
                if (SDL_GetTicks() > frameCounter + 500)
                {
                        now = SDL_GetTicks();
-                       sprintf(fps, "%2.2f fps", ((double)frames*1000)/(now - then));
+                       snprintf(fps, sizeof fps, "%2.2f fps", ((double)frames*1000)/(now - then));
                        then = frameCounter = SDL_GetTicks();
                        frames = 0;
                }
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index f6540ef..ad7d382
@@ -43,31 +43,31 @@ void createStatsPanel(int page)
        {
                case 0:
                        graphics.drawString(_("Skill Level:"), x1, y += 20, false, image);
-                       sprintf(string, "%s", _(skill[game.skill]));
+                       snprintf(string, sizeof string, "%s", _(skill[game.skill]));
                        graphics.drawString(string, x2, y, false, image);
 
                        graphics.drawString(_("Score:"), x1, y += 20, false, image);
-                       sprintf(string, "%d", game.score);
+                       snprintf(string, sizeof string, "%d", game.score);
                        graphics.drawString(string, x2, y, false, image);
 
                        graphics.drawString(_("MIAs Saved:"), x1, y += 20, false, image);
-                       sprintf(string, "%d", game.totalMIAsRescued);
+                       snprintf(string, sizeof string, "%d", game.totalMIAsRescued);
                        graphics.drawString(string, x2, y, false, image);
 
                        graphics.drawString(_("Objectives Completed:"), x1, y += 20, false, image);
-                       sprintf(string, "%d", game.totalObjectivesCompleted);
+                       snprintf(string, sizeof string, "%d", game.totalObjectivesCompleted);
                        graphics.drawString(string, x2, y, false, image);
 
                        // Don't do this on Extreme or it will always say 100%
                        if (game.skill < 3)
                        {
                                graphics.drawString(_("Percentage Complete:"), x1, y += 20, false, image);
-                               sprintf(string, "%d%%", gameData.getPercentageComplete());
+                               snprintf(string, sizeof string, "%d%%", gameData.getPercentageComplete());
                                graphics.drawString(string, x2, y, false, image);
                        }
 
-                       sprintf(string, "%s", _("Total Game Time"));
-                       sprintf(string, "%s - %.2d:%.2d:%.2d", string, game.totalHours, game.totalMinutes, game.totalSeconds);
+                       snprintf(string, sizeof string, "%s", _("Total Game Time"));
+                       snprintf(string, sizeof string, "%s - %.2d:%.2d:%.2d", string, game.totalHours, game.totalMinutes, game.totalSeconds);
                        graphics.drawString(string, 200, y += 110, true, image);
 
                        break;
@@ -75,38 +75,38 @@ void createStatsPanel(int page)
                case 1:
 
                        graphics.drawString(_("Enemies Defeated:"), x1, y += 20, false, image);
-                       sprintf(string, "%d", game.totalEnemiesDefeated);
+                       snprintf(string, sizeof string, "%d", game.totalEnemiesDefeated);
                        graphics.drawString(string, x2, y, false, image);
 
                        graphics.drawString(_("Items Collected:"), x1, y += 20, false, image);
-                       sprintf(string, "%d", game.totalItemsCollected);
+                       snprintf(string, sizeof string, "%d", game.totalItemsCollected);
                        graphics.drawString(string, x2, y, false, image);
 
                        graphics.drawString(_("Bonuses Picked Up:"), x1, y += 20, false, image);
-                       sprintf(string, "%d", game.totalBonusesCollected);
+                       snprintf(string, sizeof string, "%d", game.totalBonusesCollected);
                        graphics.drawString(string, x2, y, false, image);
 
                        graphics.drawString(_("Best Combo:"), x1, y += 20, false, image);
-                       sprintf(string, _("%d Hits"), game.maxComboHits);
+                       snprintf(string, sizeof string, _("%d Hits"), game.maxComboHits);
                        graphics.drawString(string, x2, y, false, image);
                        
                        graphics.drawString(_("Missions Started:"), x1, y += 20, false, image);
-                       sprintf(string, "%d", game.levelsStarted);
+                       snprintf(string, sizeof string, "%d", game.levelsStarted);
                        graphics.drawString(string, x2, y, false, image);
 
                        graphics.drawString(_("Continues Used:"), x1, y += 20, false, image);
-                       sprintf(string, "%d", game.continuesUsed);
+                       snprintf(string, sizeof string, "%d", game.continuesUsed);
                        graphics.drawString(string, x2, y, false, image);
                        
                        if ((game.continuesUsed > 0) && (game.levelsStarted > 0))
                        {
                                graphics.drawString(_("Average Continue Usage:"), x1, y += 20, false, image);
-                               sprintf(string, "%d", (game.continuesUsed / game.levelsStarted));
+                               snprintf(string, sizeof string, "%d", (game.continuesUsed / game.levelsStarted));
                                graphics.drawString(string, x2, y, false, image);
                        }
 
                        graphics.drawString(_("Escapes Used:"), x1, y += 20, false, image);
-                       sprintf(string, "%d", game.escapes);
+                       snprintf(string, sizeof string, "%d", game.escapes);
                        graphics.drawString(string, x2, y, false, image);
 
                        break;
@@ -122,42 +122,42 @@ void createStatsPanel(int page)
                        graphics.drawString(_("Accuracy"), x3, y, false, image);
 
                        graphics.drawString(_("Pistol"), x1, y += 30, false, image);
-                       sprintf(string, "%d", game.bulletsFired[WP_PISTOL]);
+                       snprintf(string, sizeof string, "%d", game.bulletsFired[WP_PISTOL]);
                        graphics.drawString(string, x2, y, false, image);
-                       sprintf(string, "%d%%", game.getWeaponAccuracy(WP_PISTOL));
+                       snprintf(string, sizeof string, "%d%%", game.getWeaponAccuracy(WP_PISTOL));
                        graphics.drawString(string, x3, y, false, image);
 
                        graphics.drawString(_("Machine Gun"), x1, y += 20, false, image);
-                       sprintf(string, "%d", game.bulletsFired[WP_MACHINEGUN]);
+                       snprintf(string, sizeof string, "%d", game.bulletsFired[WP_MACHINEGUN]);
                        graphics.drawString(string, x2, y, false, image);
-                       sprintf(string, "%d%%", game.getWeaponAccuracy(WP_MACHINEGUN));
+                       snprintf(string, sizeof string, "%d%%", game.getWeaponAccuracy(WP_MACHINEGUN));
                        graphics.drawString(string, x3, y, false, image);
 
                        graphics.drawString(_("Laser Cannon"), x1, y += 20, false, image);
-                       sprintf(string, "%d", game.bulletsFired[WP_LASER]);
+                       snprintf(string, sizeof string, "%d", game.bulletsFired[WP_LASER]);
                        graphics.drawString(string, x2, y, false, image);
-                       sprintf(string, "%d%%", game.getWeaponAccuracy(WP_LASER));
+                       snprintf(string, sizeof string, "%d%%", game.getWeaponAccuracy(WP_LASER));
                        graphics.drawString(string, x3, y, false, image);
                        
                        graphics.drawString(_("Grenades"), x1, y += 20, false, image);
-                       sprintf(string, "%d", game.bulletsFired[WP_GRENADES]);
+                       snprintf(string, sizeof string, "%d", game.bulletsFired[WP_GRENADES]);
                        graphics.drawString(string, x2, y, false, image);
-                       sprintf(string, "%d%%", game.getWeaponAccuracy(WP_GRENADES));
+                       snprintf(string, sizeof string, "%d%%", game.getWeaponAccuracy(WP_GRENADES));
                        graphics.drawString(string, x3, y, false, image);
 
                        graphics.drawString(_("Spread Gun"), x1, y += 20, false, image);
-                       sprintf(string, "%d", game.bulletsFired[WP_SPREAD]);
+                       snprintf(string, sizeof string, "%d", game.bulletsFired[WP_SPREAD]);
                        graphics.drawString(string, x2, y, false, image);
-                       sprintf(string, "%d%%", game.getWeaponAccuracy(WP_SPREAD));
+                       snprintf(string, sizeof string, "%d%%", game.getWeaponAccuracy(WP_SPREAD));
                        graphics.drawString(string, x3, y, false, image);
                        
                        graphics.drawString(_("Total"), x1, y += 30, false, image);
-                       sprintf(string, "%d", game.getTotalBulletsFired());
+                       snprintf(string, sizeof string, "%d", game.getTotalBulletsFired());
                        graphics.drawString(string, x2, y, false, image);
-                       sprintf(string, "%d%%", game.getTotalAccuracy());
+                       snprintf(string, sizeof string, "%d%%", game.getTotalAccuracy());
                        graphics.drawString(string, x3, y, false, image);
 
-                       sprintf(string, "%s - %s", _("Most Used Weapon"), _(weapon[game.getMostUsedWeapon()].name));
+                       snprintf(string, sizeof string, "%s - %s", _("Most Used Weapon"), _(weapon[game.getMostUsedWeapon()].name));
                        graphics.drawString(string, 200, y += 50, true, image);
 
                        break;
@@ -244,11 +244,11 @@ void createObjectivesPanel(const char *levelName)
        int x2 = 260;
        int y = 15;
        
-       sprintf(levelMIAKey, "%s MIAs", levelName);
+       snprintf(levelMIAKey, sizeof levelMIAKey, "%s MIAs", levelName);
 
        graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
 
-       sprintf(string, _("Information for %s"), _(levelName));
+       snprintf(string, sizeof string, _("Information for %s"), _(levelName));
        graphics.drawString(string, 200, y, true, image);
        y += 10;
 
@@ -266,7 +266,7 @@ void createObjectivesPanel(const char *levelName)
                                if (strcmp(data->value, "0 / 0"))
                                {
                                        graphics.drawString(_("MIAs Rescued"), x1, y += 20, false, image);
-                                       sprintf(string, "%d / %d", data->current, data->target);
+                                       snprintf(string, sizeof string, "%d / %d", data->current, data->target);
                                        (data->isComplete()) ? graphics.setFontColor(0x00, 0xff, 0x00, 0x00, 0x00, 0x00) : graphics.setFontColor(0xff, 0x00, 0x00, 0x00, 0x00, 0x00);
                                        graphics.drawString(string, x2, y, false, image);
                                }
@@ -279,7 +279,7 @@ void createObjectivesPanel(const char *levelName)
                                }
                                else
                                {
-                                       strcpy(string, _(data->value));
+                                       strncpy(string, _(data->value), sizeof string);
                                        
                                        if (strlen(string) >= 25)
                                        {
@@ -301,11 +301,11 @@ void createObjectivesPanel(const char *levelName)
                                
                                if (data->target == 1)
                                {
-                                       sprintf(string, "%s", (data->isComplete()) ? _("Completed") : _("Incomplete"));
+                                       snprintf(string, sizeof string, "%s", (data->isComplete()) ? _("Completed") : _("Incomplete"));
                                }
                                else
                                {
-                                       sprintf(string, "%d / %d", data->current, data->target);
+                                       snprintf(string, sizeof string, "%d / %d", data->current, data->target);
                                }
                                
                                (data->isComplete()) ? graphics.setFontColor(0x00, 0xff, 0x00, 0x00, 0x00, 0x00) : graphics.setFontColor(0xff, 0x00, 0x00, 0x00, 0x00, 0x00);
@@ -360,22 +360,22 @@ void createMIAPanel(int start, int max)
                                continue;
                        }
 
-                       sprintf(name, "%s", data->value);
+                       snprintf(name, sizeof name, "%s", data->value);
                        strtok(name, "_");
 
-                       sprintf(string, "%s", strtok(NULL, "_"));
+                       snprintf(string, sizeof string, "%s", strtok(NULL, "_"));
                        graphics.drawString(string, x1, y += 20, false, image);
 
                        graphics.drawString(_(data->key), x2, y, false, image);
 
                        if (data->isComplete())
                        {
-                               sprintf(string, "%s", _("Found"));
+                               snprintf(string, sizeof string, "%s", _("Found"));
                                graphics.setFontColor(0x00, 0xff, 0x00, 0x00, 0x00, 0x00);
                        }
                        else
                        {
-                               sprintf(string, "%s", _("Missing"));
+                               snprintf(string, sizeof string, "%s", _("Missing"));
                                graphics.setFontColor(0xff, 0x00, 0x00, 0x00, 0x00, 0x00);
                        }
 
@@ -455,7 +455,7 @@ int doHub()
        Sprite *cursor = graphics.addSprite("Cursor");
        for (int i = 0 ; i < 6 ; i++)
        {
-               sprintf(string, "gfx/main/cursor%d.png", i + 1);
+               snprintf(string, sizeof string, "gfx/main/cursor%d.png", i + 1);
                cursor->setFrame(i, graphics.loadImage(string), 10);
        }
 
@@ -464,7 +464,7 @@ int doHub()
        
        for (int i = 0 ; i < 5 ; i++)
        {
-               sprintf(string, "gfx/sprites/miaSignal%d.png", i + 1);
+               snprintf(string, sizeof string, "gfx/sprites/miaSignal%d.png", i + 1);
                
                newTarget->setFrame(i, graphics.loadImage(string, -60, 0, 0), 15);
                visitedTarget->setFrame(i, graphics.loadImage(string, 0, 0, 0), 15);
@@ -473,7 +473,7 @@ int doHub()
        Sprite *hubIcons = graphics.addSprite("HubIcons");
        for (int i = 0 ; i < 6 ; i++)
        {
-               sprintf(string, "gfx/main/hubIcon%d.png", i + 1);
+               snprintf(string, sizeof string, "gfx/main/hubIcon%d.png", i + 1);
                hubIcons->setFrame(i, graphics.loadImage(string), 60);
        }
 
@@ -545,8 +545,8 @@ int doHub()
 
        int rtn = -1;
        
-       strcpy(level, "@none@");
-       strcpy(game.stageName, "@none@");
+       strncpy(level, "@none@", sizeof level);
+       strncpy(game.stageName, "@none@", sizeof game.stageName);
 
        bool showData = false;
        bool showStats = false;
@@ -575,7 +575,7 @@ int doHub()
        if ((numberOfHubs == 0) && (gameData.completedWorld))
        {
                game.setMapName("data/spaceStation");
-               strcpy(game.stageName, "Space Station");
+               strncpy(game.stageName, "Space Station", sizeof game.stageName);
                createObjectivesPanel("Space Station");
                showData = true;
                showStats = showMIAs = false;
@@ -608,15 +608,15 @@ int doHub()
                if (validStage)
                {
                        graphics.drawRect(10, 400, 620, 20, graphics.black, graphics.white, graphics.screen);
-                       sprintf(string, "%s", _("Selected Destination"));
-                       sprintf(string, "%s : %s", string, _(game.stageName));
+                       snprintf(string, sizeof string, "%s", _("Selected Destination"));
+                       snprintf(string, sizeof string, "%s : %s", string, _(game.stageName));
                        graphics.drawString(string, 320, 409, true, graphics.screen);
                }
                
                graphics.drawRect(10, 430, 620, 40, graphics.black, graphics.white, graphics.screen);
 
                #if !USEPAK
-               sprintf(pos, "%.3d:%.3d", engine.getMouseX(), engine.getMouseY());
+               snprintf(pos, sizeof pos, "%.3d:%.3d", engine.getMouseX(), engine.getMouseY());
                graphics.drawString(pos, 320, 15, true, graphics.screen);
                #endif
 
old mode 100755 (executable)
new mode 100644 (file)
index 6945f46..8ddcc66
@@ -138,7 +138,7 @@ void doStatusBar()
                        if (engine.messageTime == -1)
                        {
                                engine.messagePriority = -1;
-                               strcpy(engine.message, "");
+                               engine.message[0] = 0;
                        }
        
                        graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
@@ -161,12 +161,12 @@ void doStatusBar()
                }
        }
 
-       sprintf(string, "%s %s", _("Weapon:"), _(player.currentWeapon->name));
+       snprintf(string, sizeof string, "%s %s", _("Weapon:"), _(player.currentWeapon->name));
        graphics.drawString(string, 630, 5, TXT_RIGHT, graphics.screen);
        
        if (game.skill == 3)
        {
-               sprintf(string, _("Time Remaining: %.2d:%.2d"), map.remainingMinutes, map.remainingSeconds);
+               snprintf(string, sizeof string, _("Time Remaining: %.2d:%.2d"), map.remainingMinutes, map.remainingSeconds);
                graphics.blit(graphics.infoBar, 0, 25, graphics.screen, false);
                
                if ((map.remainingMinutes > 0) || (map.remainingSeconds > 0))
@@ -209,31 +209,31 @@ void doPauseInfo()
        graphics.fade(130);
 
        char string[1024];
-       strcpy(string, "");
+       string[0] = 0;
        
        graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
 
        //#if !USEPAK
-       sprintf(string, _("Position = %d:%d"), (int)player.x, (int)player.y);
+       snprintf(string, sizeof string, _("Position = %d:%d"), (int)player.x, (int)player.y);
        graphics.drawString(string, 5, 25, false, graphics.screen);
        //#endif
 
        graphics.drawString(_("*** PAUSED ***"), 320, y, TXT_CENTERED, graphics.screen);
 
        graphics.drawString(_("MIAs in Area"), col1, y += 30, TXT_RIGHT, graphics.screen);
-       sprintf(string, "%d", map.totalMIAs - map.foundMIAs);
+       snprintf(string, sizeof string, "%d", map.totalMIAs - map.foundMIAs);
        graphics.drawString(string, col2, y, TXT_LEFT, graphics.screen);
 
        graphics.drawString(_("Enemies Defeated"), col1, y += 20, TXT_RIGHT, graphics.screen);
-       sprintf(string, "%d", game.currentMissionEnemiesDefeated);
+       snprintf(string, sizeof string, "%d", game.currentMissionEnemiesDefeated);
        graphics.drawString(string, col2, y, TXT_LEFT, graphics.screen);
 
        graphics.drawString(_("Items Collected"), col1, y += 20, TXT_RIGHT, graphics.screen);
-       sprintf(string, "%d / %d", map.foundItems, map.totalItems);
+       snprintf(string, sizeof string, "%d / %d", map.foundItems, map.totalItems);
        graphics.drawString(string, col2, y, TXT_LEFT, graphics.screen);
 
        graphics.drawString(_("Best Combo"), col1, y += 20, TXT_RIGHT, graphics.screen);
-       sprintf(string, _("%d Hits"), game.maxComboHits);
+       snprintf(string, sizeof string, _("%d Hits"), game.maxComboHits);
        graphics.drawString(string, col2, y, TXT_LEFT, graphics.screen);
 
        graphics.drawString(_("++ Inventory ++"), 320, y += 40, TXT_CENTERED, graphics.screen);
@@ -248,13 +248,13 @@ void doPauseInfo()
        if (map.totalMIAs > 0)
        {
                graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
-               sprintf(message, _("Rescue %d MIAs"), map.requiredMIAs);
+               snprintf(message, sizeof message, _("Rescue %d MIAs"), map.requiredMIAs);
                graphics.drawString(message, col1, y, TXT_RIGHT, graphics.screen);
 
                if (map.foundMIAs < map.requiredMIAs)
                {
                        graphics.setFontColor(0xff, 0x00, 0x00, 0x00, 0x00, 0x00);
-                       sprintf(message, "%d / %d", map.foundMIAs, map.requiredMIAs);
+                       snprintf(message, sizeof message, "%d / %d", map.foundMIAs, map.requiredMIAs);
                        graphics.drawString(message, col2, y, TXT_LEFT, graphics.screen);
                }
                else
@@ -296,7 +296,7 @@ void doPauseInfo()
                        }
                        else
                        {
-                               sprintf(message, "%d / %d", objective->currentValue, objective->targetValue);
+                               snprintf(message, sizeof message, "%d / %d", objective->currentValue, objective->targetValue);
                        graphics.drawString(message, col2, y, TXT_LEFT, graphics.screen);
                        }
 
@@ -317,6 +317,6 @@ void doPauseInfo()
 
        y += 10;
 
-       sprintf(string, "%s - %.2d:%.2d:%.2d", _("Mission Time"), game.currentMissionHours, game.currentMissionMinutes, game.currentMissionSeconds);
+       snprintf(string, sizeof string, "%s - %.2d:%.2d:%.2d", _("Mission Time"), game.currentMissionHours, game.currentMissionMinutes, game.currentMissionSeconds);
        graphics.drawString(string, 320, 430, TXT_CENTERED, graphics.screen);
 }
old mode 100755 (executable)
new mode 100644 (file)
index cf555ca..f0a140c
@@ -103,16 +103,16 @@ void setupUserHomeDirectory()
        debug(("User Home = %s\n", userHome));
        
        char dir[PATH_MAX];
-       strcpy(dir, "");
+       dir[0] = 0;
 
-       sprintf(dir, "%s/.parallelrealities", userHome);
+       snprintf(dir, sizeof dir, "%s/.parallelrealities", userHome);
        if ((mkdir(dir, S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH) != 0) && (errno != EEXIST))
        {
                printf("Couldn't create required directory '%s'", dir);
                exit(1);
        }
 
-       sprintf(dir, "%s/.parallelrealities/blobwars", userHome);
+       snprintf(dir, sizeof dir, "%s/.parallelrealities/blobwars", userHome);
        if ((mkdir(dir, S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH) != 0) && (errno != EEXIST))
        {
                printf("Couldn't create required directory '%s'", dir);
@@ -120,7 +120,7 @@ void setupUserHomeDirectory()
        }
 
        char gameSavePath[PATH_MAX];
-       sprintf(gameSavePath, "%s/.parallelrealities/blobwars/", userHome);
+       snprintf(gameSavePath, sizeof gameSavePath, "%s/.parallelrealities/blobwars/", userHome);
        engine.setUserHome(gameSavePath);
 }
 #endif
@@ -133,7 +133,7 @@ bool loadConfig()
 
        char configPath[PATH_MAX];
 
-       sprintf(configPath, "%sconfig", engine.userHomeDirectory);
+       snprintf(configPath, sizeof configPath, "%sconfig", engine.userHomeDirectory);
 
        debug(("Loading Config from %s\n", configPath));
 
@@ -177,7 +177,7 @@ void saveConfig()
 {
        char configPath[PATH_MAX];
 
-       sprintf(configPath, "%sconfig", engine.userHomeDirectory);
+       snprintf(configPath, sizeof configPath, "%sconfig", engine.userHomeDirectory);
 
        FILE *fp = fopen(configPath, "wb");
 
@@ -203,14 +203,14 @@ int initMedalService(void *data)
        SDL_mutexP(medalServer.lock);
        
        char connectMessage[1024];
-       sprintf(connectMessage, "Contacting Medal Server - %s:%d", MEDAL_SERVER_HOST, MEDAL_SERVER_PORT);
+       snprintf(connectMessage, sizeof connectMessage, "Contacting Medal Server - %s:%d", MEDAL_SERVER_HOST, MEDAL_SERVER_PORT);
        
        graphics.showMedalMessage(-1, connectMessage);
        
        char keyPath[PATH_MAX];
        char privateKey[20];
 
-       sprintf(keyPath, "%smedalKey", engine.userHomeDirectory);
+       snprintf(keyPath, sizeof keyPath, "%smedalKey", engine.userHomeDirectory);
        
        debug(("Loading private key from %s\n", keyPath));
        
@@ -337,7 +337,7 @@ void initSystem()
        #if USEPAK
                        
                char tempPath[PATH_MAX];
-               sprintf(tempPath, "%sfont.ttf", engine.userHomeDirectory);      
+               snprintf(tempPath, sizeof tempPath, "%sfont.ttf", engine.userHomeDirectory);    
                remove(tempPath);
                
                SDL_Delay(1000); // wait one second, just to be sure!
@@ -432,7 +432,7 @@ void cleanup()
        audio.destroy();
 
        debug(("Removing Music...\n"));
-       sprintf(tempPath, "%smusic.mod", engine.userHomeDirectory);
+       snprintf(tempPath, sizeof tempPath, "%smusic.mod", engine.userHomeDirectory);
        remove(tempPath);
 
        debug(("Freeing Game Info...\n"));
@@ -454,7 +454,7 @@ void cleanup()
        }
 
        debug(("Removing Font File...\n"));
-       sprintf(tempPath, "%sfont.ttf", engine.userHomeDirectory);
+       snprintf(tempPath, sizeof tempPath, "%sfont.ttf", engine.userHomeDirectory);
        remove(tempPath);
        
        if (SDL_NumJoysticks() > 0)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 4db5fc8..67aae9e
@@ -278,10 +278,10 @@ void pickUpItem(Entity *item)
                        case 'o':
                        case 'U':
                        case 'u':
-                               sprintf(string, _("Picked up an %s"), item->name);
+                               snprintf(string, sizeof string, _("Picked up an %s"), item->name);
                                break;
                        default:
-                               sprintf(string, _("Picked up a %s"), item->name);
+                               snprintf(string, sizeof string, _("Picked up a %s"), item->name);
                                break;
                }
 
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index cfb509d..7d2792c
@@ -36,25 +36,25 @@ void initSaveSlots()
        //READ SAVE GAME DATA
        for (int i = 0 ; i < 5 ; i++)
        {
-               sprintf(filename, "%ssave%d.dat", engine.userHomeDirectory, i);
+               snprintf(filename, sizeof filename, "%ssave%d.dat", engine.userHomeDirectory, i);
 
                fp = fopen(filename, "rb");
 
                if (!fp)
                {
-                       strcpy(string, "%.2d - %s");
-                       sprintf(engine.saveSlot[i], string, (i + 1), _("Empty"));
+                       strncpy(string, "%.2d - %s", sizeof string);
+                       snprintf(engine.saveSlot[i], sizeof engine.saveSlot[i], string, (i + 1), _("Empty"));
                }
                else
                {
                        if (fread(&tempGame, sizeof(Game), 1, fp) != 1)
                        {
-                               strcpy(string, "%.2d - %s");
-                               sprintf(engine.saveSlot[i], string, (i + 1), _("Corrupt Save Data"));
+                               strncpy(string, "%.2d - %s", sizeof string);
+                               snprintf(engine.saveSlot[i], sizeof engine.saveSlot[i], string, (i + 1), _("Corrupt Save Data"));
                        }
                        else
                        {
-                               sprintf(engine.saveSlot[i], "%.2d - %s (%.2d:%.2d:%.2d)", (i + 1), _(tempGame.stageName), tempGame.totalHours, tempGame.totalMinutes, tempGame.totalSeconds);
+                               snprintf(engine.saveSlot[i], sizeof engine.saveSlot[i], "%.2d - %s (%.2d:%.2d:%.2d)", (i + 1), _(tempGame.stageName), tempGame.totalHours, tempGame.totalMinutes, tempGame.totalSeconds);
                        }
 
                        if (stat(filename, &fileInfo) != -1)
@@ -94,7 +94,7 @@ bool loadGame(int slot)
        
        int sanity = 0;
 
-       sprintf(filename, "%ssave%d.dat", engine.userHomeDirectory, slot);
+       snprintf(filename, sizeof filename, "%ssave%d.dat", engine.userHomeDirectory, slot);
 
        fp = fopen(filename, "rb");
        
@@ -111,7 +111,7 @@ bool loadGame(int slot)
        
        fclose(fp);
        
-       sprintf(filename, "%spersistant%d.dat", engine.userHomeDirectory, slot);
+       snprintf(filename, sizeof filename, "%spersistant%d.dat", engine.userHomeDirectory, slot);
 
        fp = fopen(filename, "rb");
        
@@ -163,7 +163,7 @@ bool loadGame(int slot)
                fgets(line, 1024, fp);
                
                sscanf(line, "%[^\n\r]", string[0]);
-               strcpy(stageName, string[0]);
+               strncpy(stageName, string[0], sizeof stageName);
                
                if (strcmp(stageName, "@EOF@") == 0)
                {
@@ -183,7 +183,7 @@ bool loadGame(int slot)
                        
                        fgets(line, 1024, fp);
                        
-                       strcpy(persistData->data, line);
+                       strncpy(persistData->data, line, sizeof persistData->data);
                        
                        //debug(("Read %d: %s", i, persistData->data));
                        
@@ -232,12 +232,12 @@ int confirmSave()
        engine.setWidgetVariable("contno", &quitNo);
        
        char widgetName[10];
-       strcpy(widgetName, "");
+       widgetName[0] = 0;
        
        for (int i = 0 ; i < 5 ; i++)
        {
-               sprintf(widgetName, "slot%d", i + 1);
-               strcpy(engine.getWidgetByName(widgetName)->label, engine.saveSlot[i]);
+               snprintf(widgetName, sizeof widgetName, "slot%d", i + 1);
+               strncpy(engine.getWidgetByName(widgetName)->label, engine.saveSlot[i], sizeof engine.getWidgetByName(widgetName)->label);
        }
        
        engine.highlightWidget("slot1");
@@ -329,7 +329,7 @@ void saveGame()
 
        graphics.setFontSize(1);
        graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
-       sprintf(message, _("Saving Game to Save Slot #%d. Please Wait..."), slot + 1);
+       snprintf(message, sizeof message, _("Saving Game to Save Slot #%d. Please Wait..."), slot + 1);
        graphics.drawString(message, 320, 220, true, graphics.screen);
        graphics.updateScreen();
 
@@ -337,7 +337,7 @@ void saveGame()
 
        FILE *fp;
 
-       sprintf(filename, "%ssave%d.dat", engine.userHomeDirectory, slot);
+       snprintf(filename, sizeof filename, "%ssave%d.dat", engine.userHomeDirectory, slot);
 
        fp = fopen(filename, "wb");
        
@@ -350,7 +350,7 @@ void saveGame()
        
        fclose(fp);
        
-       sprintf(filename, "%spersistant%d.dat", engine.userHomeDirectory, slot);
+       snprintf(filename, sizeof filename, "%spersistant%d.dat", engine.userHomeDirectory, slot);
 
        fp = fopen(filename, "wt");
        
old mode 100755 (executable)
new mode 100644 (file)
index 020724c..33838ac
@@ -126,8 +126,8 @@ int main(int argc, char *argv[])
                else if (strcmp(argv[i], "-mono") == 0) engine.useAudio = 1;
                else if (strcmp(argv[i], "-version") == 0) showVersion();
                else if (strcmp(argv[i], "--help") == 0) showHelp();
-               else if (strcmp(argv[i], "-record") == 0) {recordMode = REPLAY_MODE::RECORD; strcpy(replayData.filename, argv[++i]);}
-               else if (strcmp(argv[i], "-playback") == 0) {recordMode = REPLAY_MODE::PLAYBACK; strcpy(replayData.filename, argv[++i]);}
+               else if (strcmp(argv[i], "-record") == 0) {recordMode = REPLAY_MODE::RECORD; strncpy(replayData.filename, argv[++i], sizeof replayData.filename);}
+               else if (strcmp(argv[i], "-playback") == 0) {recordMode = REPLAY_MODE::PLAYBACK; strncpy(replayData.filename, argv[++i], sizeof replayData.filename);}
                else if (strcmp(argv[i], "-map") == 0) {game.setMapName(argv[++i]); requiredSection = SECTION_GAME;}
                else if (strcmp(argv[i], "-listmaps") == 0) listMaps();
                
@@ -148,7 +148,7 @@ int main(int argc, char *argv[])
                        
                case REPLAY_MODE::RECORD:
                        requiredSection = SECTION_GAME;
-                       strcpy(replayData.header.map, game.mapName);
+                       strncpy(replayData.header.map, game.mapName, sizeof replayData.header.map);
                        replayData.header.skill = game.skill = 3;
                        replayData.setMode(REPLAY_MODE::RECORD);
                        break;
old mode 100755 (executable)
new mode 100644 (file)
index e7083c8..eb86f17
@@ -393,7 +393,7 @@ void showMap(int centerX, int centerY)
        graphics.drawString(_("Enemies"), 430, 410, TXT_LEFT, graphics.screen);
 
        graphics.setFontSize(1);
-       sprintf(string, "%s - %.2d:%.2d:%.2d", _("Mission Time"), game.currentMissionHours, game.currentMissionMinutes, game.currentMissionSeconds);
+       snprintf(string, sizeof string, "%s - %.2d:%.2d:%.2d", _("Mission Time"), game.currentMissionHours, game.currentMissionMinutes, game.currentMissionSeconds);
        graphics.drawString(string, 320, 60, TXT_CENTERED, graphics.screen);
        graphics.drawString(_("Press Button to Continue..."), 320, 450, TXT_CENTERED, graphics.screen);
 
old mode 100755 (executable)
new mode 100644 (file)
index 1ccef79..dfe8514
@@ -364,7 +364,7 @@ void createPersistantMapData()
        }
        
        char line[1024];
-       strcpy(line, "");
+       line[0] = 0;
        
        char skill;
        
@@ -381,7 +381,7 @@ void createPersistantMapData()
                        break;
        }
        
-       sprintf(line, "%c START %d %d\n", skill, (int)game.checkPointX, (int)game.checkPointY);
+       snprintf(line, sizeof line, "%c START %d %d\n", skill, (int)game.checkPointX, (int)game.checkPointY);
        persistant->addLine(line);
 
        Entity *ent;
@@ -399,7 +399,7 @@ void createPersistantMapData()
        while (ent->next != NULL)
        {
                ent = (Entity*)ent->next;
-               sprintf(line, "%c ENEMY \"%s\" %d %d\n", skill, ent->name, (int)ent->x, (int)ent->y);
+               snprintf(line, sizeof line, "%c ENEMY \"%s\" %d %d\n", skill, ent->name, (int)ent->x, (int)ent->y);
                persistant->addLine(line);
        }
        
@@ -415,7 +415,7 @@ void createPersistantMapData()
                        continue;
                }
                
-               sprintf(line, "%c ITEM %d \"%s\" %d %d %s\n", skill, ent->id, ent->name, (int)ent->x, (int)ent->y, ent->sprite[0]->name);
+               snprintf(line, sizeof line, "%c ITEM %d \"%s\" %d %d %s\n", skill, ent->id, ent->name, (int)ent->x, (int)ent->y, ent->sprite[0]->name);
                persistant->addLine(line);
        }
        
@@ -424,7 +424,7 @@ void createPersistantMapData()
        while (ent->next != NULL)
        {
                ent = (Entity*)ent->next;
-               sprintf(line, "%c OBSTACLE \"%s\" %d %d %s\n", skill, ent->name, (int)ent->x, (int)ent->y, ent->sprite[0]->name);
+               snprintf(line, sizeof line, "%c OBSTACLE \"%s\" %d %d %s\n", skill, ent->name, (int)ent->x, (int)ent->y, ent->sprite[0]->name);
                persistant->addLine(line);
        }
        
@@ -436,7 +436,7 @@ void createPersistantMapData()
                define[0] = engine.getDefineOfValue("SWT_", swt->type);
                define[1] = (char*)getActiveState(swt->activated);
                
-               sprintf(line, "%c SWITCH \"%s\" %s \"%s\" \"%s\" %s %d %d %s\n", skill, swt->name, swt->linkName, swt->requiredObjectName, swt->activateMessage, define[0], (int)swt->x, (int)swt->y, define[1]);
+               snprintf(line, sizeof line, "%c SWITCH \"%s\" %s \"%s\" \"%s\" %s %d %d %s\n", skill, swt->name, swt->linkName, swt->requiredObjectName, swt->activateMessage, define[0], (int)swt->x, (int)swt->y, define[1]);
                
                persistant->addLine(line);
        }
@@ -459,13 +459,13 @@ void createPersistantMapData()
                        }
                        
                        define[1] = (char*)getActiveState(train->active);
-                       sprintf(line, "%c DOOR %s %s %d %d %d %d %s\n", skill, train->name, define[0], train->startX, train->startY, train->endX, train->endY, define[1]);
+                       snprintf(line, sizeof line, "%c DOOR %s %s %d %d %d %d %s\n", skill, train->name, define[0], train->startX, train->startY, train->endX, train->endY, define[1]);
                }
                else
                {
                        define[0] = engine.getDefineOfValue("TR_A", train->waitAtStart);
                        define[1] = (char*)getActiveState(train->active);
-                       sprintf(line, "%c TRAIN %s %d %d %d %d %d %s %s\n", skill, train->name, train->startX, train->startY, train->endX, train->endY, train->getPause(), define[0], define[1]);
+                       snprintf(line, sizeof line, "%c TRAIN %s %d %d %d %d %d %s %s\n", skill, train->name, train->startX, train->startY, train->endX, train->endY, train->getPause(), define[0], define[1]);
                }
                                
                persistant->addLine(line);
@@ -478,7 +478,7 @@ void createPersistantMapData()
                trap = (Trap*)trap->next;
                define[0] = engine.getDefineOfValue("TRAP_TYPE", trap->type);
                define[1] = (char*)getActiveState(trap->active);
-               sprintf(line, "%c TRAP %s %s %d %d %d %d %d %d %d %d %s %s\n", skill, trap->name, define[0], (int)trap->damage, (int)trap->speed, (int)trap->startX, (int)trap->startY, (int)trap->endX, (int)trap->endY, (int)trap->waitTime[0], (int)trap->waitTime[1], trap->sprite->name, define[1]);
+               snprintf(line, sizeof line, "%c TRAP %s %s %d %d %d %d %d %d %d %d %s %s\n", skill, trap->name, define[0], (int)trap->damage, (int)trap->speed, (int)trap->startX, (int)trap->startY, (int)trap->endX, (int)trap->endY, (int)trap->waitTime[0], (int)trap->waitTime[1], trap->sprite->name, define[1]);
                persistant->addLine(line);
        }
        
@@ -488,7 +488,7 @@ void createPersistantMapData()
        {
                teleporter = (Teleporter*)teleporter->next;
                define[0] = (char*)getActiveState(teleporter->active);
-               sprintf(line, "%c TELEPORTER %s %d %d %d %d %s\n", skill, teleporter->name, (int)teleporter->x, (int)teleporter->y, (int)teleporter->destX, (int)teleporter->destY, define[0]);
+               snprintf(line, sizeof line, "%c TELEPORTER %s %d %d %d %d %s\n", skill, teleporter->name, (int)teleporter->x, (int)teleporter->y, (int)teleporter->destX, (int)teleporter->destY, define[0]);
                persistant->addLine(line);
        }
        
@@ -498,7 +498,7 @@ void createPersistantMapData()
        {
                lineDef = (LineDef*)lineDef->next;
                define[0] = (char*)getActiveState(lineDef->activated);
-               sprintf(line, "%c LINEDEF \"%s\" %s \"%s\" %d %d %d %d %s\n", skill, lineDef->name, lineDef->linkName, lineDef->activateMessage, (int)lineDef->x, (int)lineDef->y, (int)lineDef->width, (int)lineDef->height, define[0]);
+               snprintf(line, sizeof line, "%c LINEDEF \"%s\" %s \"%s\" %d %d %d %d %s\n", skill, lineDef->name, lineDef->linkName, lineDef->activateMessage, (int)lineDef->x, (int)lineDef->y, (int)lineDef->width, (int)lineDef->height, define[0]);
                persistant->addLine(line);
        }
        
@@ -519,7 +519,7 @@ void createPersistantMapData()
                }
                        
                define[2] = (char*)getActiveState(spawnPoint->active);
-               sprintf(line, "%c SPAWNPOINT %s %d %d %s %s %d %d %s\n", skill, spawnPoint->name, (int)spawnPoint->x, (int)spawnPoint->y, define[0], define[1], (int)(spawnPoint->minInterval / 60), (int)(spawnPoint->maxInterval / 60), define[2]);
+               snprintf(line, sizeof line, "%c SPAWNPOINT %s %d %d %s %s %d %d %s\n", skill, spawnPoint->name, (int)spawnPoint->x, (int)spawnPoint->y, define[0], define[1], (int)(spawnPoint->minInterval / 60), (int)(spawnPoint->maxInterval / 60), define[2]);
                persistant->addLine(line);
        }
        
@@ -527,14 +527,14 @@ void createPersistantMapData()
        {
                if (map.getSpawnableEnemy(i) != NULL)
                {
-                       sprintf(line, "%c SPAWNABLE_ENEMY \"%s\"\n", skill, map.getSpawnableEnemy(i));
+                       snprintf(line, sizeof line, "%c SPAWNABLE_ENEMY \"%s\"\n", skill, map.getSpawnableEnemy(i));
                        persistant->addLine(line);
                }
        }
        
        if (map.waterLevel != -1)
        {
-               sprintf(line, "%c WATERLEVEL %d\n", skill, (int)map.waterLevel);
+               snprintf(line, sizeof line, "%c WATERLEVEL %d\n", skill, (int)map.waterLevel);
                persistant->addLine(line);
        }
        
old mode 100755 (executable)
new mode 100644 (file)
index 5810419..fb00004
@@ -264,7 +264,7 @@ void collectMapData()
                if (!strstr(string, " ENEMY \""))
                {
                        str = new String;
-                       strcpy(str->string, string);
+                       strncpy(str->string, string, sizeof str->string);
                        stringTail->next = str;
                        stringTail = str;
                }
@@ -617,11 +617,11 @@ int main(int argc, char *argv[])
                if (mapY > MAPHEIGHT - 30) mapY = MAPHEIGHT - 30;
 
                if (editing == 0)
-                       sprintf(string, "Index : %d:%d ; Screen %d:%d ; Tile %d", mapX + x, mapY + y, (mapX + x) * BRICKSIZE, (mapY + y) * BRICKSIZE, currentBlock);
+                       snprintf(string, sizeof string, "Index : %d:%d ; Screen %d:%d ; Tile %d", mapX + x, mapY + y, (mapX + x) * BRICKSIZE, (mapY + y) * BRICKSIZE, currentBlock);
                else if (editing == 1)
-                       sprintf(string, "Index : %d:%d ; Screen %d:%d ; %s", mapX + x, mapY + y, (mapX + x) * BRICKSIZE, (mapY + y) * BRICKSIZE, defEnemy[currentMonster].name);
+                       snprintf(string, sizeof string, "Index : %d:%d ; Screen %d:%d ; %s", mapX + x, mapY + y, (mapX + x) * BRICKSIZE, (mapY + y) * BRICKSIZE, defEnemy[currentMonster].name);
                else if (editing == 2)
-                       sprintf(string, "Index : %d:%d ; Screen %d:%d ; %s", mapX + x, mapY + y, (mapX + x) * BRICKSIZE, (mapY + y) * BRICKSIZE, defItem[currentItem].name);
+                       snprintf(string, sizeof string, "Index : %d:%d ; Screen %d:%d ; %s", mapX + x, mapY + y, (mapX + x) * BRICKSIZE, (mapY + y) * BRICKSIZE, defItem[currentItem].name);
 
                r.x = 0;
                r.w = 640;
old mode 100755 (executable)
new mode 100644 (file)
index 5936f9b..e8df50d
@@ -22,20 +22,20 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 void initMIAPhrases()
 {
-       strcpy(mia_scared[0], "help me...");
-       strcpy(mia_scared[1], "i don't wanna die...");
-       strcpy(mia_scared[2], "please... someone help...");
-       strcpy(mia_scared[3], "i... i'm scared...");
-       strcpy(mia_scared[4], "i wanna go home...");
-       strcpy(mia_scared[5], "what was that?!");
-       strcpy(mia_scared[6], "i don't like it here...");
+       strncpy(mia_scared[0], "help me...", sizeof mia_scared[0]);
+       strncpy(mia_scared[1], "i don't wanna die...", sizeof mia_scared[1]);
+       strncpy(mia_scared[2], "please... someone help...", sizeof mia_scared[2]);
+       strncpy(mia_scared[3], "i... i'm scared...", sizeof mia_scared[3]);
+       strncpy(mia_scared[4], "i wanna go home...", sizeof mia_scared[4]);
+       strncpy(mia_scared[5], "what was that?!", sizeof mia_scared[5]);
+       strncpy(mia_scared[6], "i don't like it here...", sizeof mia_scared[6]);
 }
 
 void addMIA(const char *name, int x, int y, int type)
 {
        Entity *mia = new Entity();
 
-       strcpy(mia->name, name);
+       strncpy(mia->name, name, sizeof mia->name);
        mia->id = type;
        mia->baseThink = 60;
        mia->health = 180;
@@ -140,17 +140,17 @@ void doMIAs()
 
                                        if ((map.foundMIAs == (map.requiredMIAs / 2)) || (game.skill == 0))
                                        {
-                                               sprintf(message, _("Rescued %s - Checkpoint Reached!"), mia->name);
+                                               snprintf(message, sizeof message, _("Rescued %s - Checkpoint Reached!"), mia->name);
                                                game.setObjectiveCheckPoint();
                                        }
                                        else
                                        {
-                                               sprintf(message, _("Rescued %s!"), mia->name);
+                                               snprintf(message, sizeof message, _("Rescued %s!"), mia->name);
                                        }
 
                                        if (map.foundMIAs == map.requiredMIAs)
                                        {
-                                               sprintf(message, _("Rescue %d MIAs - Objective Complete - Checkpoint Reached!"), map.requiredMIAs);
+                                               snprintf(message, sizeof message, _("Rescue %d MIAs - Objective Complete - Checkpoint Reached!"), map.requiredMIAs);
                                                game.setObjectiveCheckPoint();
                                        }
                                        
old mode 100755 (executable)
new mode 100644 (file)
index 4d6e989..d562df8
@@ -98,7 +98,7 @@ void processPostMissionData()
                if (mia->health > 0)
                        miaFound = false;
 
-               sprintf(string, "MIA_%s", mia->name);
+               snprintf(string, sizeof string, "MIA_%s", mia->name);
                
                if (miaFound)
                {
@@ -127,7 +127,7 @@ void clearAllMissionData()
 {
        char levelMIAKey[100];
        
-       sprintf(levelMIAKey, "%s MIAs", game.stageName);
+       snprintf(levelMIAKey, sizeof levelMIAKey, "%s MIAs", game.stageName);
        
        Data *data = (Data*)gameData.dataList.getHead();
        Data *previous = data;
@@ -231,13 +231,13 @@ void showMissionClear()
        if (map.totalMIAs > 0)
        {
                graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
-               sprintf(message, _("Rescue %d MIAs"), map.requiredMIAs);
+               snprintf(message, sizeof message, _("Rescue %d MIAs"), map.requiredMIAs);
                graphics.drawString(message, col1, y, TXT_RIGHT, graphics.background);
 
                if (map.foundMIAs < map.requiredMIAs)
                {
                        graphics.setFontColor(0xff, 0x00, 0x00, 0x00, 0x00, 0x00);
-                       sprintf(message, "%d / %d", map.foundMIAs, map.requiredMIAs);
+                       snprintf(message, sizeof message, "%d / %d", map.foundMIAs, map.requiredMIAs);
                        graphics.drawString(message, col2, y, TXT_LEFT, graphics.background);
                }
                else
@@ -278,7 +278,7 @@ void showMissionClear()
                        else
                        {
                                graphics.setFontColor(0xff, 0x00, 0x00, 0x00, 0x00, 0x00);
-                               sprintf(message, "%d / %d", objective->currentValue, objective->targetValue);
+                               snprintf(message, sizeof message, "%d / %d", objective->currentValue, objective->targetValue);
                                graphics.drawString(message, col2, y, TXT_LEFT, graphics.background);
                        }
                }
@@ -365,7 +365,7 @@ void showMissionClear()
                        }
                }
 
-               sprintf(message, "%s - %.2d:%.2d:%.2d", _("Mission Time"), game.currentMissionHours, game.currentMissionMinutes, game.currentMissionSeconds);
+               snprintf(message, sizeof message, "%s - %.2d:%.2d:%.2d", _("Mission Time"), game.currentMissionHours, game.currentMissionMinutes, game.currentMissionSeconds);
                graphics.drawString(message, 320, 420, true, graphics.screen);
 
                engine.delay(frameLimit);
old mode 100755 (executable)
new mode 100644 (file)
index edc5ad4..f9e92f7
@@ -269,24 +269,24 @@ void checkObjectives(const char *name, bool alwaysInform)
                                {
                                        if (!map.isBossMission)
                                        {
-                                               sprintf(message, _("%s - Objective Completed - Check Point Reached!"), _(objective->description));
+                                               snprintf(message, sizeof message, _("%s - Objective Completed - Check Point Reached!"), _(objective->description));
                                                game.setObjectiveCheckPoint();
                                        }
                                        else
                                        {
-                                               sprintf(message, _("%s - Objective Completed"), _(objective->description));
+                                               snprintf(message, sizeof message, _("%s - Objective Completed"), _(objective->description));
                                        }
 
                                        if (strcmp(objective->description, "Get the Aqua Lung") == 0)
                                        {
-                                               sprintf(message, "Got the Aqua Lung! You can now swim forever!");
+                                               snprintf(message, sizeof message, "Got the Aqua Lung! You can now swim forever!");
                                                game.hasAquaLung = true;
                                                presentPlayerMedal("Aqua_Lung");
                                        }
 
                                        if (strcmp(objective->description, "Get the Jetpack") == 0)
                                        {
-                                               sprintf(message, "Got the Jetpack! Press SPACE to Activate!");
+                                               snprintf(message, sizeof message, "Got the Jetpack! Press SPACE to Activate!");
                                                game.hasJetPack = true;
                                                presentPlayerMedal("Jetpack");
                                        }
@@ -303,13 +303,13 @@ void checkObjectives(const char *name, bool alwaysInform)
                                                switch (Math::prand() % 3)
                                                {
                                                        case 0:
-                                                               sprintf(message, _("%s - %d more to go..."), _(objective->description), requiredValue);
+                                                               snprintf(message, sizeof message, _("%s - %d more to go..."), _(objective->description), requiredValue);
                                                                break;
                                                        case 1:
-                                                               sprintf(message, _("%s - need %d more"), _(objective->description), requiredValue);
+                                                               snprintf(message, sizeof message, _("%s - need %d more"), _(objective->description), requiredValue);
                                                                break;
                                                        case 2:
-                                                               sprintf(message, _("%s - %d of %d"), _(objective->description), objective->currentValue, objective->targetValue);
+                                                               snprintf(message, sizeof message, _("%s - %d of %d"), _(objective->description), objective->currentValue, objective->targetValue);
                                                                break;
                                                }
                                                
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 36d5a19..ee254c7
@@ -55,7 +55,7 @@ void countFiles(const char *dirName)
                        continue;
                }
 
-               sprintf(filename, "%s/%s", dirName, dfile->d_name);
+               snprintf(filename, sizeof filename, "%s/%s", dirName, dfile->d_name);
                
                if (strlen(filename) > PAK_MAX_FILENAME - 1)
                {
@@ -108,7 +108,7 @@ void recurseDirectory(const char *dirName)
                        continue;
                }
 
-               sprintf(filename, "%s/%s", dirName, dfile->d_name);
+               snprintf(filename, sizeof filename, "%s/%s", dirName, dfile->d_name);
 
                dirp2 = opendir(filename);
 
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 4ce9892..6b7eb29
@@ -66,7 +66,7 @@ void presentPlayerMedal(const char *tname)
        // Copy the input, so that threading
        // doesn't trip us up!
        char *data = new char[128];
-       strcpy(data, tname);
+       strncpy(data, tname, sizeof data);
        
        SDL_Thread *thread = SDL_CreateThread(medalWorker, (void*)data);
        
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index a7543dd..96d74d9
@@ -65,15 +65,15 @@ void checkSwitchContact(Entity *ent)
                                        
                                        if (swt->type == SWT_PRESSURE)
                                        {
-                                               strcpy(swt->requiredObjectName, "@none@");
+                                               strncpy(swt->requiredObjectName, "@none@", sizeof swt->requiredObjectName);
                                        }
                                        
                                        checkObjectives(swt->name, true);
-                                       strcpy(swt->name, "Switch");
+                                       strncpy(swt->name, "Switch", sizeof swt->name);
                                }
                                else
                                {
-                                       sprintf(message, "%s required", swt->requiredObjectName);
+                                       snprintf(message, sizeof message, "%s required", swt->requiredObjectName);
                                        engine.setInfoMessage(message, 1, INFO_HINT);
                                }
                        }
old mode 100755 (executable)
new mode 100644 (file)
index 05120f9..6db897f
@@ -382,7 +382,7 @@ void tankBossMGInit()
        debug(("tankBossMGInit\n"));
        
        map.boss[0] = new Boss();
-       strcpy(map.boss[0]->name, "BioMech Tank V1.1");
+       strncpy(map.boss[0]->name, "BioMech Tank V1.1", sizeof map.boss[0]->name);
        map.boss[0]->health = 65 * game.skill;
        map.boss[0]->maxHealth = 65 * game.skill;
        map.boss[0]->setSprites(graphics.getSprite("BlobTankCannonRight", true), graphics.getSprite("BlobTankCannonLeft", true), graphics.getSprite("BlobTankCannonLeft", true));
@@ -604,7 +604,7 @@ void tankBossGLInit()
        debug(("tankBossGLInit\n"));
        
        map.boss[1] = new Boss();
-       strcpy(map.boss[1]->name, "BioMech Tank V2.6");
+       strncpy(map.boss[1]->name, "BioMech Tank V2.6", sizeof map.boss[1]->name);
        map.boss[1]->health = 65 * game.skill;
        map.boss[1]->maxHealth = 65 * game.skill;
        map.boss[1]->setSprites(graphics.getSprite("BlobTankGrenadeRight", true), graphics.getSprite("BlobTankGrenadeLeft", true), graphics.getSprite("BlobTankGrenadeLeft", true));
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 777b142..29dcd86
@@ -111,20 +111,20 @@ void showTitleWidgets()
 void setupSaveWidgets()
 {
        char widgetName[10];
-       strcpy(widgetName, "");
+       widgetName[0] = 0;
        
        for (int i = 0 ; i < 5 ; i++)
        {
-               sprintf(widgetName, "save%d", i + 1);
-               strcpy(engine.getWidgetByName(widgetName)->label, engine.saveSlot[i]);
+               snprintf(widgetName, sizeof widgetName, "save%d", i + 1);
+               strncpy(engine.getWidgetByName(widgetName)->label, engine.saveSlot[i], sizeof engine.getWidgetByName(widgetName)->label);
                
                if ((strstr(engine.saveSlot[i], _("Empty"))) || (strstr(engine.saveSlot[i], _("Corrupt"))))
                {
                        engine.enableWidget(widgetName, false);
                }
                
-               sprintf(widgetName, "slot%d", i + 1);
-               strcpy(engine.getWidgetByName(widgetName)->label, engine.saveSlot[i]);
+               snprintf(widgetName, sizeof widgetName, "slot%d", i + 1);
+               strncpy(engine.getWidgetByName(widgetName)->label, engine.saveSlot[i], sizeof engine.getWidgetByName(widgetName)->label);
        }
 }
 
@@ -143,7 +143,7 @@ void loadTitleWidgets()
        setupSaveWidgets();
        
        Widget *widget = engine.getWidgetByName("labelManual");
-       strcpy(widget->label, GAMEPLAYMANUAL);
+       strncpy(widget->label, GAMEPLAYMANUAL, sizeof widget->label);
 
        showTitleWidgets();
 }
@@ -192,7 +192,7 @@ int title()
        char v[50];
        #define STRINGIFY_VALUE(x) STRINGIFY(x)
        #define STRINGIFY(x) #x
-       sprintf(v, _("Version %s"), STRINGIFY_VALUE(VERSION));
+       snprintf(v, sizeof v, _("Version %s"), STRINGIFY_VALUE(VERSION));
        SDL_Surface *version = graphics.quickSprite("Version", graphics.getString(v, true));
 
        SDL_SetAlpha(title, SDL_SRCALPHA|SDL_RLEACCEL, 0);
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index eeeb841..5591204
@@ -126,21 +126,21 @@ void drawJoypadButtonOption(Widget *widget)
        int x = 300;
        
        char text[25];
-       strcpy(text, "");
+       text[0] = 0;
        
        // joysticks have a button 0 so we can't
        // do the same thing as the keyboard(!)
        if (*widget->value <= -1000)
        {
-               sprintf(text, "...");
+               snprintf(text, sizeof text, "...");
        }
        else if (*widget->value == -2)
        {
-               sprintf(text, "N/A");
+               snprintf(text, sizeof text, "N/A");
        }
        else
        {
-               sprintf(text, "Button #%d", *widget->value);
+               snprintf(text, sizeof text, "Button #%d", *widget->value);
        }
        
        graphics.drawString(text, x, widget->y, TXT_LEFT, graphics.screen);