Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/SoftEtherVPN/SoftEtherVPN_Stable.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/Mayaqua/Str.c')
-rw-r--r--src/Mayaqua/Str.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/Mayaqua/Str.c b/src/Mayaqua/Str.c
index 1e5d14d8..0e1783db 100644
--- a/src/Mayaqua/Str.c
+++ b/src/Mayaqua/Str.c
@@ -3346,6 +3346,54 @@ UINT StrCpy(char *dst, UINT size, char *src)
return len;
}
+UINT StrCpyAllowOverlap(char *dst, UINT size, char *src)
+{
+ UINT len;
+ // Validate arguments
+ if (dst == src)
+ {
+ return StrLen(src);
+ }
+ if (dst == NULL || src == NULL)
+ {
+ if (src == NULL && dst != NULL)
+ {
+ if (size >= 1)
+ {
+ dst[0] = '\0';
+ }
+ }
+ return 0;
+ }
+ if (size == 1)
+ {
+ dst[0] = '\0';
+ return 0;
+ }
+ if (size == 0)
+ {
+ // Ignore the length
+ size = 0x7fffffff;
+ }
+
+ // Check the length
+ len = StrLen(src);
+ if (len <= (size - 1))
+ {
+ Move(dst, src, len + 1);
+ }
+ else
+ {
+ len = size - 1;
+ Move(dst, src, len);
+ dst[len] = '\0';
+ }
+
+ // KS
+ KS_INC(KS_STRCPY_COUNT);
+
+ return len;
+}
// Check whether the string buffer is within the specified size
bool StrCheckSize(char *str, UINT size)