summaryrefslogtreecommitdiff
path: root/src/win32.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-09-29 16:27:02 +0000
committerrubidium <rubidium@openttd.org>2008-09-29 16:27:02 +0000
commit5ab74534da3f94cd1c43bc438dcc0d31b23408e5 (patch)
tree43b0c8873ef3d08bb3099e46a3bc152bc8cd010d /src/win32.cpp
parentd34da3cadbd0e7776244fc45915f23b1e9f28c7f (diff)
downloadopenttd-5ab74534da3f94cd1c43bc438dcc0d31b23408e5.tar.xz
(svn r14414) -Fix: replace instances of strncpy with strecpy as strncpy doesn't guarantee the resulting string is '\0'-terminated.
Diffstat (limited to 'src/win32.cpp')
-rw-r--r--src/win32.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/win32.cpp b/src/win32.cpp
index acdaab87d..4c33bfbd4 100644
--- a/src/win32.cpp
+++ b/src/win32.cpp
@@ -1046,14 +1046,14 @@ void DetermineBasePaths(const char *exe)
TCHAR path[MAX_PATH];
#ifdef WITH_PERSONAL_DIR
SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, path);
- strncpy(tmp, WIDE_TO_MB_BUFFER(path, tmp, lengthof(tmp)), lengthof(tmp));
+ strecpy(tmp, WIDE_TO_MB_BUFFER(path, tmp, lengthof(tmp)), lastof(tmp));
AppendPathSeparator(tmp, MAX_PATH);
ttd_strlcat(tmp, PERSONAL_DIR, MAX_PATH);
AppendPathSeparator(tmp, MAX_PATH);
_searchpaths[SP_PERSONAL_DIR] = strdup(tmp);
SHGetFolderPath(NULL, CSIDL_COMMON_DOCUMENTS, NULL, SHGFP_TYPE_CURRENT, path);
- strncpy(tmp, WIDE_TO_MB_BUFFER(path, tmp, lengthof(tmp)), lengthof(tmp));
+ strecpy(tmp, WIDE_TO_MB_BUFFER(path, tmp, lengthof(tmp)), lastof(tmp));
AppendPathSeparator(tmp, MAX_PATH);
ttd_strlcat(tmp, PERSONAL_DIR, MAX_PATH);
AppendPathSeparator(tmp, MAX_PATH);
@@ -1078,7 +1078,7 @@ void DetermineBasePaths(const char *exe)
DEBUG(misc, 0, "GetFullPathName failed (%d)\n", GetLastError());
_searchpaths[SP_BINARY_DIR] = NULL;
} else {
- strncpy(tmp, WIDE_TO_MB_BUFFER(exec_dir, tmp, lengthof(tmp)), lengthof(tmp));
+ strecpy(tmp, WIDE_TO_MB_BUFFER(exec_dir, tmp, lengthof(tmp)), lastof(tmp));
char *s = strrchr(tmp, PATHSEPCHAR);
*(s + 1) = '\0';
_searchpaths[SP_BINARY_DIR] = strdup(tmp);