summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-11-30 19:38:04 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-11-30 19:38:04 +0000
commit1bb83288c063ce1864e46f6f675751c8c631b530 (patch)
treef493e890ea5a1a2e1019fe3e2d51d5329243bf86 /src
parent450894ec572814925c03c7c1cdf3e977d32f839f (diff)
safer implementation of *n functions using *_s functions
git-svn-id: http://svn.miranda-ng.org/main/trunk@11178 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r--src/mir_core/utils.cpp36
1 files changed, 16 insertions, 20 deletions
diff --git a/src/mir_core/utils.cpp b/src/mir_core/utils.cpp
index 28d48f7f33..6c584e9c82 100644
--- a/src/mir_core/utils.cpp
+++ b/src/mir_core/utils.cpp
@@ -305,12 +305,11 @@ MIR_CORE_DLL(char*) mir_strncpy(char *dest, const char *src, size_t len)
if (dest == NULL)
return NULL;
- if (src == NULL) {
+ if (src == NULL)
*dest = 0;
- return dest;
- }
-
- return strncpy(dest, src, len);
+ else
+ strncpy_s(dest, len, src, _TRUNCATE);
+ return dest;
}
MIR_CORE_DLL(wchar_t*) mir_wstrncpy(wchar_t *dest, const wchar_t *src, size_t len)
@@ -318,12 +317,11 @@ MIR_CORE_DLL(wchar_t*) mir_wstrncpy(wchar_t *dest, const wchar_t *src, size_t le
if (dest == NULL)
return NULL;
- if (src == NULL) {
+ if (src == NULL)
*dest = 0;
- return dest;
- }
-
- return wcsncpy(dest, src, len);
+ else
+ wcsncpy_s(dest, len, src, _TRUNCATE);
+ return dest;
}
MIR_CORE_DLL(char*) mir_strcat(char *dest, const char *src)
@@ -357,12 +355,11 @@ MIR_CORE_DLL(char*) mir_strncat(char *dest, const char *src, size_t len)
if (dest == NULL)
return NULL;
- if (src == NULL) {
+ if (src == NULL)
*dest = 0;
- return dest;
- }
-
- return strncat(dest, src, len);
+ else
+ strncat_s(dest, len, src, _TRUNCATE);
+ return dest;
}
MIR_CORE_DLL(wchar_t*) mir_wstrncat(wchar_t *dest, const wchar_t *src, size_t len)
@@ -370,10 +367,9 @@ MIR_CORE_DLL(wchar_t*) mir_wstrncat(wchar_t *dest, const wchar_t *src, size_t le
if (dest == NULL)
return NULL;
- if (src == NULL) {
+ if (src == NULL)
*dest = 0;
- return dest;
- }
-
- return wcsncat(dest, src, len);
+ else
+ wcsncat_s(dest, len, src, _TRUNCATE);
+ return dest;
}