]> git.mxchange.org Git - quix0rs-blobwars.git/blobdiff - src/CEngine.cpp
Use strlcat() and strlcpy(), #define wrappers when these functions are not available.
[quix0rs-blobwars.git] / src / CEngine.cpp
index 2520ba1d58cdae2c415acca4ac58e67379c232d6..02175277e4df59843a4fd77b278d0aaa7364cd19 100644 (file)
@@ -64,7 +64,7 @@ Engine::Engine()
        binaryBuffer = NULL;
        #ifdef FRAMEWORK_SDL
        char pakPath[PATH_MAX];
-       strncpy(pakPath, PAKFULLPATH, sizeof(pakPath));
+       strlcpy(pakPath, PAKFULLPATH, sizeof(pakPath));
        if (CFBundleGetMainBundle() != NULL) {
                CFURLRef pakURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR(PAKNAME), NULL, NULL);
                if (pakURL != NULL) {
@@ -229,7 +229,7 @@ void Engine::getInput()
                                }
 
                                keyState[event.key.keysym.sym] = 1;
-                               strncpy(lastKeyPressed, SDL_GetKeyName(event.key.keysym.sym), sizeof lastKeyPressed);
+                               strlcpy(lastKeyPressed, SDL_GetKeyName(event.key.keysym.sym), sizeof lastKeyPressed);
                                addKeyEvent();
                                break;
 
@@ -314,7 +314,7 @@ void Engine::clearInput()
 
 void Engine::setUserHome(const char *path)
 {
-       strncpy(userHomeDirectory, path, sizeof userHomeDirectory);
+       strlcpy(userHomeDirectory, path, sizeof userHomeDirectory);
        debug(("User Home = %s\n", path));
 }
 
@@ -489,7 +489,7 @@ void Engine::setInfoMessage(const char *message, int priority, int type)
 {
        if (priority >= messagePriority)
        {
-               strncpy(this->message, message, sizeof this->message);
+               strlcpy(this->message, message, sizeof this->message);
                messageTime = 180;
                messagePriority = priority;
                messageType = type;
@@ -957,7 +957,7 @@ int Engine::getValueOfFlagTokens(const char *realLine)
        char line[1024];
        bool found;
        int value;
-       strncpy(line, realLine, sizeof line);
+       strlcpy(line, realLine, sizeof line);
 
        int flags = 0;